Git commit b60817c871a4cdcfb5219d695b4f854b7296d87d by Leslie Zhai. Committed on 16/07/2016 at 06:02. Pushed by lesliezhai into branch 'master'.
Revert "Merge branch 'kf5'" This reverts commit 8b122fe31192d7d6e2f8167feb42786d72ed7fd2, reversing changes made to 023aa4c436d02de800fc8030c4632d68987e3107. M +20 -38 CMakeLists.txt M +15 -13 cmake/FindMusicBrainz5.cmake M +19 -15 kcmcddb/CMakeLists.txt M +25 -12 kcmcddb/cddbconfigwidget.cpp M +25 -5 kcmcddb/cddbconfigwidget.ui M +2 -1 kcmcddb/doc/CMakeLists.txt M +1 -1 kcmcddb/doc/index.docbook M +16 -13 kcmcddb/kcmcddb.cpp M +2 -2 kcmcddb/kcmcddb.h D +0 -7 kcmcddb/kcmcddbi18n.h M +1 -1 kcmcddb/libkcddb.desktop M +47 -79 libkcddb/CMakeLists.txt M +8 -5 libkcddb/asynccddbplookup.cpp M +1 -0 libkcddb/asynccddbplookup.h M +9 -4 libkcddb/asynchttplookup.cpp M +4 -3 libkcddb/asynchttpsubmit.cpp M +5 -3 libkcddb/asyncsmtpsubmit.cpp M +11 -9 libkcddb/cache.cpp M +4 -2 libkcddb/cache.h M +7 -42 libkcddb/categories.cpp M +7 -12 libkcddb/categories.h M +4 -4 libkcddb/cddb.cpp M +2 -3 libkcddb/cddb.h M +11 -10 libkcddb/cddbplookup.cpp M +2 -2 libkcddb/cddbplookup.h M +8 -9 libkcddb/cdinfo.cpp M +1 -1 libkcddb/cdinfo.h M +27 -26 libkcddb/cdinfodialog.cpp M +2 -2 libkcddb/cdinfodialog.h M +26 -7 libkcddb/cdinfodialog.ui M +7 -6 libkcddb/cdinfoencodingwidget.cpp M +17 -35 libkcddb/cdinfoencodingwidget.ui M +9 -5 libkcddb/client.cpp M +3 -2 libkcddb/client.h M +1 -1 libkcddb/genres.cpp M +1 -1 libkcddb/genres.h M +13 -11 libkcddb/httplookup.cpp M +3 -2 libkcddb/httplookup.h M +3 -3 libkcddb/httpsubmit.cpp M +2 -2 libkcddb/httpsubmit.h M +1 -1 libkcddb/kcddb.cpp A +40 -0 libkcddb/kcddb_export.h [License: LGPL (v2+)] M +2 -2 libkcddb/kcddbconfig.cpp D +0 -7 libkcddb/kcddbi18n.h D +0 -22 libkcddb/logging.cpp D +0 -26 libkcddb/logging.h M +1 -1 libkcddb/lookup.cpp M +2 -3 libkcddb/lookup.h M +5 -2 libkcddb/musicbrainz/asyncmusicbrainzlookup.cpp M +47 -48 libkcddb/musicbrainz/musicbrainzlookup.cpp M +16 -17 libkcddb/sites.cpp M +1 -1 libkcddb/sites.h M +5 -5 libkcddb/smtpsubmit.cpp M +2 -2 libkcddb/smtpsubmit.h M +3 -2 libkcddb/submit.cpp M +1 -1 libkcddb/submit.h M +9 -9 libkcddb/synccddbplookup.cpp M +10 -8 libkcddb/synchttplookup.cpp M +5 -2 libkcddb/synchttpsubmit.cpp M +3 -2 libkcddb/syncsmtpsubmit.cpp M +25 -9 test/CMakeLists.txt M +7 -5 test/asynccddblookuptest.cpp M +1 -1 test/asynccddblookuptest.h M +7 -5 test/asynchttplookuptest.cpp M +1 -1 test/asynchttplookuptest.h M +13 -9 test/asynchttpsubmittest.cpp M +2 -5 test/asynchttpsubmittest.h M +6 -4 test/asyncmusicbrainztest.cpp M +1 -1 test/asyncmusicbrainztest.h M +13 -9 test/asyncsmtpsubmittest.cpp M +2 -5 test/asyncsmtpsubmittest.h M +4 -2 test/cachetest.cpp M +1 -1 test/cachetest.h M +3 -1 test/cdinfotest.cpp M +1 -1 test/cdinfotest.h M +7 -4 test/musicbrainztest-fulldate.cpp M +1 -1 test/musicbrainztest-fulldate.h M +7 -4 test/musicbrainztest-severaldiscs.cpp M +1 -1 test/musicbrainztest-severaldiscs.h M +7 -4 test/musicbrainztest.cpp M +1 -1 test/musicbrainztest.h M +10 -8 test/sitestest.cpp M +4 -2 test/synccddblookuptest.cpp M +1 -1 test/synccddblookuptest.h M +4 -2 test/synchttplookuptest.cpp M +1 -1 test/synchttplookuptest.h M +7 -5 test/synchttpsubmittest.cpp M +7 -5 test/syncsmtpsubmittest.cpp M +4 -2 test/utf8test.cpp M +1 -1 test/utf8test.h http://commits.kde.org/libkcddb/b60817c871a4cdcfb5219d695b4f854b7296d87d diff --git a/CMakeLists.txt b/CMakeLists.txt index 67ffc32..a92ff28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,59 +1,41 @@ project(libkcddb) -cmake_minimum_required(VERSION 2.8.12) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(ECM REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH "${ECM_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -include(KDEInstallDirs) -include(KDECompilerSettings) -include(KDECMakeSettings) -include(FeatureSummary) -include(GenerateExportHeader) -include(ECMSetupVersion) - -find_package(Qt5 REQUIRED COMPONENTS Network Widgets) -find_package(KF5 REQUIRED COMPONENTS Config DocTools Codecs I18n KIO WidgetsAddons) - -ecm_setup_version(${KF5_VERSION} - VARIABLE_PREFIX KCDDB - PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LibkcddbConfigVersion.cmake") +find_package(KDE4 REQUIRED) +include(KDE4Defaults) +include(MacroLibrary) +include_directories(${KDE4_INCLUDES}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -find_package(MusicBrainz5) -set_package_properties(MusicBrainz5 PROPERTIES - DESCRIPTION "Music metadata lookup for KDE multimedia applications through libkcddb. You need version 5.x of libmusicbrainz" - URL "http://www.musicbrainz.org" - TYPE OPTIONAL - PURPOSE "A library that provides access to metadata lookup on the MusicBrainz server") +macro_optional_find_package(MusicBrainz5) +macro_log_feature(MUSICBRAINZ5_FOUND "MusicBrainz5" "A library that provides access to metadata lookup on the MusicBrainz server" "http://www.musicbrainz.org" FALSE "" "Music metadata lookup for KDE multimedia applications through libkcddb. You need version 5.x of libmusicbrainz") if(MUSICBRAINZ5_FOUND) set(HAVE_MUSICBRAINZ5 1) -else() + include_directories(${MUSICBRAINZ5_INCLUDE_DIRS}) + + set(libmusicbrainz_SRCS ${libmusicbrainz_SRCS} + musicbrainz/musicbrainzlookup.cpp + musicbrainz/asyncmusicbrainzlookup.cpp) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}") +else(MUSICBRAINZ5_FOUND) set(HAVE_MUSICBRAINZ5 0) -endif() + set(libmusicbrainz_SRCS) +endif(MUSICBRAINZ5_FOUND) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-musicbrainz.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-musicbrainz.h ) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - +add_subdirectory( test ) add_subdirectory( kcmcddb ) add_subdirectory( libkcddb ) -if(BUILD_TESTING) - find_package(Qt5Test REQUIRED) - add_subdirectory( test ) -endif() - -feature_summary(WHAT PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) - # Figure out the relative path from the installed Config.cmake file to the install prefix (which may be at # runtime different from the chosen CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) # This relative path will be configured into LibkcddbConfig.cmake file(RELATIVE_PATH relInstallDir ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/libkcddb ${CMAKE_INSTALL_PREFIX}) configure_file(LibkcddbConfig.cmake.in ${CMAKE_BINARY_DIR}/LibkcddbConfig.cmake @ONLY) -install(FILES - ${CMAKE_BINARY_DIR}/LibkcddbConfig.cmake - ${CMAKE_BINARY_DIR}/LibkcddbConfigVersion.cmake - DESTINATION ${LIB_INSTALL_DIR}/cmake/libkcddb) +install(FILES ${CMAKE_BINARY_DIR}/LibkcddbConfig.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/libkcddb) install(EXPORT LibkcddbTargets DESTINATION ${LIB_INSTALL_DIR}/cmake/libkcddb/ FILE LibkcddbTargets.cmake NAMESPACE KDE::Libkcddb::) diff --git a/cmake/FindMusicBrainz5.cmake b/cmake/FindMusicBrainz5.cmake index f41eb86..4a223c1 100644 --- a/cmake/FindMusicBrainz5.cmake +++ b/cmake/FindMusicBrainz5.cmake @@ -10,21 +10,23 @@ # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -if(MUSICBRAINZ5_INCLUDE_DIR AND MUSICBRAINZ5_LIBRARIES) - set(MUSICBRAINZ5_FIND_QUIETLY TRUE) -endif() +if(MUSICBRAINZ5_INCLUDE_DIRS AND MUSICBRAINZ5_LIBRARIES) + set(MUSICBRAINZ5_FIND_QUIETLY TRUE) +endif(MUSICBRAINZ5_INCLUDE_DIRS AND MUSICBRAINZ5_LIBRARIES) -find_path(MUSICBRAINZ5_INCLUDE_DIR musicbrainz5/Disc.h) - -find_library(MUSICBRAINZ5_LIBRARIES NAMES musicbrainz5) +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( MUSICBRAINZ5 libmusicbrainz5 ) +ELSE (NOT WIN32) + FIND_PATH( MUSICBRAINZ5_INCLUDE_DIRS musicbrainz5/Disc.h ) + FIND_LIBRARY( MUSICBRAINZ5_LIBRARIES NAMES musicbrainz5 ) +ENDIF (NOT WIN32) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MusicBrainz5 DEFAULT_MSG MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES) +find_package_handle_standard_args( MusicBrainz5 DEFAULT_MSG + MUSICBRAINZ5_INCLUDE_DIRS MUSICBRAINZ5_LIBRARIES) -add_library(musicbrainz SHARED IMPORTED) -set_target_properties(musicbrainz PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MUSICBRAINZ5_INCLUDE_DIR}" - IMPORTED_LOCATION "${MUSICBRAINZ5_LIBRARIES}" -) +MARK_AS_ADVANCED(MUSICBRAINZ5_INCLUDE_DIRS MUSICBRAINZ5_LIBRARIES) -mark_as_advanced(MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES) diff --git a/kcmcddb/CMakeLists.txt b/kcmcddb/CMakeLists.txt index 4e1a2b9..6cd7822 100644 --- a/kcmcddb/CMakeLists.txt +++ b/kcmcddb/CMakeLists.txt @@ -1,23 +1,27 @@ +include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../libkcddb ${CMAKE_CURRENT_BINARY_DIR}/../libkcddb ) + add_subdirectory ( doc ) -ki18n_wrap_ui(ui_sources cddbconfigwidget.ui) +########### next target ############### + +set(kcm_cddb_PART_SRCS cddbconfigwidget.cpp kcmcddb.cpp ) +SET_SOURCE_FILES_PROPERTIES(cddbconfigwidget.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ui_cddbconfigwidget.h) + + +kde4_add_ui_files(kcm_cddb_PART_SRCS cddbconfigwidget.ui ) + +kde4_add_plugin(kcm_cddb ${kcm_cddb_PART_SRCS}) + + + +target_link_libraries(kcm_cddb ${KDE4_KIO_LIBS} kcddb) + +install(TARGETS kcm_cddb DESTINATION ${PLUGIN_INSTALL_DIR} ) -add_library(kcm_cddb MODULE - cddbconfigwidget.cpp - kcmcddb.cpp - ${ui_sources}) -set_source_files_properties(cddbconfigwidget.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ui_cddbconfigwidget.h) +########### install files ############### -target_link_libraries(kcm_cddb PRIVATE - KF5::ConfigWidgets - KF5::I18n - KF5::KIOCore - KF5::KIOWidgets - KF5::WidgetsAddons - kcddbwidgets) +install( FILES libkcddb.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install(TARGETS kcm_cddb DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES libkcddb.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/kcmcddb/cddbconfigwidget.cpp b/kcmcddb/cddbconfigwidget.cpp index f740f60..e7e3758 100644 --- a/kcmcddb/cddbconfigwidget.cpp +++ b/kcmcddb/cddbconfigwidget.cpp @@ -19,20 +19,27 @@ */ #include "cddbconfigwidget.h" -#include "kcmcddbi18n.h" #include "config-musicbrainz.h" +#include <kdemacros.h> // KDE_NO_DEPRECATED + #include "libkcddb/sites.h" #include "libkcddb/lookup.h" -#include <KIOWidgets/KUrlRequester> -#include <KWidgetsAddons/KMessageBox> -#include <KWidgetsAddons/KEditListWidget> - -#include <QtCore/QList> -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QInputDialog> +#include <qlist.h> +#include <kfiledialog.h> +#include <kapplication.h> +#include <klocale.h> +#include <kinputdialog.h> +#include <kmessagebox.h> +#ifndef KDE_NO_DEPRECATED +#include <keditlistbox.h> +#else +#include <keditlistwidget.h> +#endif +#include <kurlrequester.h> +#include <QCheckBox> CDDBConfigWidget::CDDBConfigWidget(QWidget * parent) : QWidget(parent) @@ -53,7 +60,11 @@ CDDBConfigWidget::CDDBConfigWidget(QWidget * parent) QVBoxLayout* gbLayout = new QVBoxLayout(groupBox); gbLayout->setMargin(0); +#ifndef KDE_NO_DEPRECATED + KEditListBox* editListWidget = new KEditListBox(groupBox); +#else KEditListWidget* editListWidget = new KEditListWidget(groupBox); +#endif editListWidget->setCustomEditor(urlReq->customEditor()); editListWidget->setObjectName(QString::fromLatin1("kcfg_cacheLocations")); gbLayout->addWidget(editListWidget); @@ -88,13 +99,13 @@ void CDDBConfigWidget::showMirrorList() return; } - QString result = QInputDialog::getItem(this, i18n("Select mirror"), + QStringList result = KInputDialog::getItemList(i18n("Select mirror"), i18n("Select one of these mirrors"), keys.keys(), - 0, false, &ok); + QStringList(), false, &ok, this); - if (ok) + if (ok && result.count() == 1) { - KCDDB::Mirror m = keys[result]; + KCDDB::Mirror m = keys[*(result.begin())]; kcfg_FreedbLookupTransport->setCurrentIndex(m.transport == KCDDB::Lookup::CDDBP ? 0 : 1); kcfg_hostname->setText(m.address); @@ -120,3 +131,5 @@ void CDDBConfigWidget::needAuthenticationChanged(bool needsAuth) } // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 + +#include "cddbconfigwidget.moc" diff --git a/kcmcddb/cddbconfigwidget.ui b/kcmcddb/cddbconfigwidget.ui index 756e1f7..16fc911 100644 --- a/kcmcddb/cddbconfigwidget.ui +++ b/kcmcddb/cddbconfigwidget.ui @@ -82,7 +82,7 @@ </widget> </item> <item> - <widget class="QSpinBox" name="kcfg_port"> + <widget class="KIntSpinBox" name="kcfg_port"> <property name="sizePolicy"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -132,7 +132,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="mirrorListButton"> + <widget class="KPushButton" name="mirrorListButton"> <property name="text"> <string>Show &Mirror List</string> </property> @@ -193,7 +193,7 @@ <item row="1" column="1"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QLineEdit" name="kcfg_httpSubmitServer"> + <widget class="KLineEdit" name="kcfg_httpSubmitServer"> </widget> </item> <item> @@ -210,7 +210,7 @@ </widget> </item> <item> - <widget class="QSpinBox" name="kcfg_httpSubmitPort"/> + <widget class="KIntSpinBox" name="kcfg_httpSubmitPort"/> </item> </layout> </item> @@ -243,7 +243,7 @@ </widget> </item> <item> - <widget class="QSpinBox" name="kcfg_smtpPort"> + <widget class="KIntSpinBox" name="kcfg_smtpPort"> <property name="sizePolicy"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -316,6 +316,26 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>KIntSpinBox</class> + <extends>QSpinBox</extends> + <header>knuminput.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>KPushButton</class> + <extends>QPushButton</extends> + <header>kpushbutton.h</header> + <container>1</container> + </customwidget> + </customwidgets> <tabstops> <tabstop>kcfg_hostname</tabstop> <tabstop>kcfg_port</tabstop> diff --git a/kcmcddb/doc/CMakeLists.txt b/kcmcddb/doc/CMakeLists.txt index 5839d56..a565b0b 100644 --- a/kcmcddb/doc/CMakeLists.txt +++ b/kcmcddb/doc/CMakeLists.txt @@ -1 +1,2 @@ -kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kcontrol/cddbretrieval) +########### install files ############### +kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kcontrol/cddbretrieval) diff --git a/kcmcddb/doc/index.docbook b/kcmcddb/doc/index.docbook index 19ac32b..96a5bec 100644 --- a/kcmcddb/doc/index.docbook +++ b/kcmcddb/doc/index.docbook @@ -1,5 +1,5 @@ <?xml version="1.0" ?> -<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [ +<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [ <!ENTITY kappname "&kscd;"> <!ENTITY package "kdemultimedia"> <!ENTITY % English "INCLUDE" > <!-- change language only here --> diff --git a/kcmcddb/kcmcddb.cpp b/kcmcddb/kcmcddb.cpp index b6fd00c..00c8b9f 100644 --- a/kcmcddb/kcmcddb.cpp +++ b/kcmcddb/kcmcddb.cpp @@ -19,34 +19,37 @@ */ #include "kcmcddb.h" -#include "kcmcddbi18n.h" #include "cddbconfigwidget.h" #include "libkcddb/lookup.h" #include "libkcddb/cache.h" #include "libkcddb/submit.h" -#include <KCoreAddons/KPluginFactory> -#include <KWidgetsAddons/KMessageBox> +#include <QCheckBox> +#include <qradiobutton.h> +#include <QVBoxLayout> -#include <QtCore/QDebug> -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QRadioButton> -#include <QtWidgets/QVBoxLayout> +#include <kconfig.h> +#include <klocale.h> +#include <kglobal.h> +#include <kgenericfactory.h> +#include <kmessagebox.h> +#include <kconfigdialogmanager.h> K_PLUGIN_FACTORY(KCDDBFactory, registerPlugin<CDDBModule>();) K_EXPORT_PLUGIN(KCDDBFactory( "kcmcddb" )) -CDDBModule::CDDBModule(QWidget *parent, const QVariantList &args) - : KCModule(parent, args) +CDDBModule::CDDBModule(QWidget *parent, const QVariantList &) + : KCModule(KCDDBFactory::componentData(), parent) { + KGlobal::locale()->insertCatalog( QLatin1String( "libkcddb" )); setButtons(Default | Apply | Help); widget_ = new CDDBConfigWidget(this); KCDDB::Config* cfg = new KCDDB::Config(); - cfg->load(); + cfg->readConfig(); addConfig(cfg, widget_); @@ -73,7 +76,7 @@ CDDBModule::checkSettings() const { KCDDB::Config config; - config.load(); + config.readConfig(); if (config.smtpHostname().isEmpty() || config.emailAddress().isEmpty() || !config.emailAddress().contains(QLatin1String( "@" )) || @@ -88,7 +91,7 @@ CDDBModule::checkSettings() const "and try again."), i18n("Incorrect Email Settings")); config.setFreedbSubmitTransport(KCDDB::Submit::HTTP); - config.save(); + config.writeConfig(); } } } @@ -115,7 +118,7 @@ CDDBModule::load() KCModule::load(); KCDDB::Config config; - config.load(); + config.readConfig(); updateWidgetsFromConfig(config); } diff --git a/kcmcddb/kcmcddb.h b/kcmcddb/kcmcddb.h index 6780826..5a9a712 100644 --- a/kcmcddb/kcmcddb.h +++ b/kcmcddb/kcmcddb.h @@ -20,7 +20,7 @@ #ifndef KCMCDDB_H #define KCMCDDB_H -#include <KConfigWidgets/KCModule> +#include <kcmodule.h> #include "libkcddb/kcddbconfig.h" class CDDBConfigWidget; @@ -32,7 +32,7 @@ class CDDBModule : public KCModule public: - CDDBModule(QWidget * parent, const QVariantList & args); + CDDBModule(QWidget * parent, const QVariantList &); public slots: diff --git a/kcmcddb/kcmcddbi18n.h b/kcmcddb/kcmcddbi18n.h deleted file mode 100644 index 1e4703c..0000000 --- a/kcmcddb/kcmcddbi18n.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef KCMCDDBI18N_H -#define KCMCDDBI18N_H - -#define TRANSLATION_DOMAIN "kcmcddb" -#include <KI18n/KLocalizedString> - -#endif // KCMCDDBI18N_H diff --git a/kcmcddb/libkcddb.desktop b/kcmcddb/libkcddb.desktop index afda94e..d9224bf 100644 --- a/kcmcddb/libkcddb.desktop +++ b/kcmcddb/libkcddb.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Exec=kcmshell5 libkcddb +Exec=kcmshell4 libkcddb Icon=media-optical-audio Type=Service ServiceTypes=KCModule diff --git a/libkcddb/CMakeLists.txt b/libkcddb/CMakeLists.txt index 153e405..8927d1a 100644 --- a/libkcddb/CMakeLists.txt +++ b/libkcddb/CMakeLists.txt @@ -1,94 +1,62 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +########### next target ############### + +set(kcddb_LIB_SRCS ${libmusicbrainz_SRCS} + cache.cpp + cdinfo.cpp + kcddbconfig.cpp + client.cpp + kcddb.cpp + cddb.cpp + lookup.cpp + cddbplookup.cpp + synccddbplookup.cpp + asynccddbplookup.cpp + httplookup.cpp + synchttplookup.cpp + asynchttplookup.cpp + smtpsubmit.cpp + asyncsmtpsubmit.cpp + syncsmtpsubmit.cpp + submit.cpp + sites.cpp + httpsubmit.cpp + asynchttpsubmit.cpp + synchttpsubmit.cpp + categories.cpp + genres.cpp + cdinfodialog.cpp + cdinfoencodingwidget.cpp ) + + +kde4_add_ui_files(kcddb_LIB_SRCS cdinfodialog.ui cdinfoencodingwidget.ui ) + +kde4_add_kcfg_files(kcddb_LIB_SRCS configbase.kcfgc ) + +kde4_add_library(kcddb SHARED ${kcddb_LIB_SRCS}) + +target_link_libraries(kcddb ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) if(MUSICBRAINZ5_FOUND) - set(musicbrainz_sources - musicbrainz/musicbrainzlookup.cpp - musicbrainz/asyncmusicbrainzlookup.cpp) + target_link_libraries(kcddb ${MUSICBRAINZ5_LIBRARIES}) +endif(MUSICBRAINZ5_FOUND) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) - set(enable_exceptions -EHsc) - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(enable_exceptions "-fexceptions -UQT_NO_EXCEPTIONS") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - set(enable_exceptions -fexceptions) - endif() +set_target_properties(kcddb PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) +install(TARGETS kcddb EXPORT LibkcddbTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) - set_source_files_properties(${musicbrainz_sources} PROPERTIES COMPILE_FLAGS ${enable_exceptions}) -endif() -kconfig_add_kcfg_files(kcfg_sources configbase.kcfgc) - -add_library(kcddb SHARED - cache.cpp - cdinfo.cpp - kcddbconfig.cpp - client.cpp - kcddb.cpp - cddb.cpp - lookup.cpp - cddbplookup.cpp - synccddbplookup.cpp - asynccddbplookup.cpp - httplookup.cpp - synchttplookup.cpp - asynchttplookup.cpp - smtpsubmit.cpp - asyncsmtpsubmit.cpp - syncsmtpsubmit.cpp - submit.cpp - sites.cpp - httpsubmit.cpp - asynchttpsubmit.cpp - synchttpsubmit.cpp - categories.cpp - genres.cpp - logging.cpp - ${musicbrainz_sources} - ${kcfg_sources}) - -target_link_libraries(kcddb - PUBLIC - KF5::ConfigGui - PRIVATE - KF5::Codecs - KF5::I18n - KF5::KIOCore - Qt5::Network) - -if(MUSICBRAINZ5_FOUND) - target_link_libraries(kcddb PRIVATE musicbrainz) -endif() - -ki18n_wrap_ui(ui_sources cdinfodialog.ui cdinfoencodingwidget.ui) - -add_library(kcddbwidgets SHARED - cdinfodialog.cpp - cdinfoencodingwidget.cpp - ${ui_sources}) - -target_link_libraries(kcddbwidgets - PUBLIC - kcddb - Qt5::Widgets - PRIVATE - KF5::Codecs - KF5::I18n) - -generate_export_header(kcddb) - -set_target_properties(kcddb kcddbwidgets PROPERTIES VERSION ${KCDDB_VERSION} SOVERSION ${KCDDB_SOVERSION}) - -install(TARGETS kcddb kcddbwidgets EXPORT LibkcddbTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) +########### install files ############### install(FILES - categories.h cdinfo.h cdinfodialog.h client.h genres.h kcddbconfig.h kcddb.h - ${CMAKE_CURRENT_BINARY_DIR}/kcddb_export.h + kcddb_export.h ${CMAKE_CURRENT_BINARY_DIR}/configbase.h - DESTINATION ${INCLUDE_INSTALL_DIR}/libkcddb COMPONENT Devel) + DESTINATION ${INCLUDE_INSTALL_DIR}/libkcddb COMPONENT Devel ) +install( FILES libkcddb.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) -install( FILES libkcddb.kcfg DESTINATION ${KCFG_INSTALL_DIR}) diff --git a/libkcddb/asynccddbplookup.cpp b/libkcddb/asynccddbplookup.cpp index e763b19..8cc7d23 100644 --- a/libkcddb/asynccddbplookup.cpp +++ b/libkcddb/asynccddbplookup.cpp @@ -20,7 +20,9 @@ */ #include "asynccddbplookup.h" -#include "logging.h" + +#include <kdebug.h> +#include <ksocketfactory.h> namespace KCDDB { @@ -43,8 +45,7 @@ namespace KCDDB const TrackOffsetList & trackOffsetList ) { - socket_ = new QTcpSocket; - socket_->connectToHost(hostname, port); + socket_ = KSocketFactory::connectToHost(QLatin1String( "cddbp" ), hostname, port); connect (socket_, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotGotError(QAbstractSocket::SocketError))); @@ -76,14 +77,14 @@ namespace KCDDB void AsyncCDDBPLookup::slotConnectionSuccess() { - qCDebug(LIBKCDDB) << "Connection successful"; + kDebug(60010) << "Connection successful"; state_ = WaitingForGreeting; } void AsyncCDDBPLookup::slotReadyRead() { - qCDebug(LIBKCDDB) << "Ready to read. State: " << stateToString(); + kDebug(60010) << "Ready to read. State: " << stateToString(); while ( Idle != state_ && isConnected() && socket_->canReadLine() ) read(); @@ -336,4 +337,6 @@ namespace KCDDB } +#include "asynccddbplookup.moc" + // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 diff --git a/libkcddb/asynccddbplookup.h b/libkcddb/asynccddbplookup.h index 4079b25..0b2aa2a 100644 --- a/libkcddb/asynccddbplookup.h +++ b/libkcddb/asynccddbplookup.h @@ -21,6 +21,7 @@ #ifndef KCDDB_ASYNC_CDDBP_LOOKUP_H #define KCDDB_ASYNC_CDDBP_LOOKUP_H + #include "cddbplookup.h" namespace KCDDB diff --git a/libkcddb/asynchttplookup.cpp b/libkcddb/asynchttplookup.cpp index cbe9aaa..bba91df 100644 --- a/libkcddb/asynchttplookup.cpp +++ b/libkcddb/asynchttplookup.cpp @@ -19,9 +19,12 @@ */ #include "asynchttplookup.h" -#include "logging.h" -#include <KIO/Job> +#include <qstringlist.h> +#include <qapplication.h> + +#include <kdebug.h> +#include <kio/job.h> namespace KCDDB { @@ -71,7 +74,7 @@ namespace KCDDB void AsyncHTTPLookup::slotQueryReady() { - qCDebug(LIBKCDDB) << "Matches Found: " << matchList_.count(); + kDebug(60010) << "Matches Found: " << matchList_.count(); if ( Success != result_ ) { @@ -127,7 +130,7 @@ namespace KCDDB Result AsyncHTTPLookup::fetchURL() { - qCDebug(LIBKCDDB) << "About to fetch: " << cgiURL_.url(); + kDebug(60010) << "About to fetch: " << cgiURL_.url(); KIO::TransferJob* job = KIO::get( cgiURL_, KIO::NoReload, KIO::HideProgressInfo ); @@ -144,4 +147,6 @@ namespace KCDDB } +#include "asynchttplookup.moc" + // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 diff --git a/libkcddb/asynchttpsubmit.cpp b/libkcddb/asynchttpsubmit.cpp index 31ed186..acc6205 100644 --- a/libkcddb/asynchttpsubmit.cpp +++ b/libkcddb/asynchttpsubmit.cpp @@ -19,8 +19,8 @@ #include "asynchttpsubmit.h" -#include <KIO/Job> -#include <QtCore/QDebug> +#include <kio/job.h> +#include <kdebug.h> namespace KCDDB { @@ -44,7 +44,7 @@ namespace KCDDB void AsyncHTTPSubmit::slotFinished(KJob* job) { - qDebug() << "Finished"; + kDebug() << "Finished"; if ( job->error()==0 ) emit finished( Success ); @@ -53,3 +53,4 @@ namespace KCDDB } } +#include "asynchttpsubmit.moc" diff --git a/libkcddb/asyncsmtpsubmit.cpp b/libkcddb/asyncsmtpsubmit.cpp index e5b7505..3ea9702 100644 --- a/libkcddb/asyncsmtpsubmit.cpp +++ b/libkcddb/asyncsmtpsubmit.cpp @@ -18,11 +18,12 @@ */ #include "asyncsmtpsubmit.h" -#include "logging.h" #include "cdinfo.h" -#include <KIO/Job> + +#include <kdebug.h> +#include <kio/job.h> namespace KCDDB { @@ -48,7 +49,7 @@ namespace KCDDB void AsyncSMTPSubmit::slotDone( KJob* job ) { - qCDebug(LIBKCDDB) ; + kDebug(60010) ; if ( job->error()==0 ) emit finished( Success ); else @@ -56,3 +57,4 @@ namespace KCDDB } } +#include "asyncsmtpsubmit.moc" diff --git a/libkcddb/cache.cpp b/libkcddb/cache.cpp index 1c3846a..96c9560 100644 --- a/libkcddb/cache.cpp +++ b/libkcddb/cache.cpp @@ -24,16 +24,18 @@ #include "kcddbconfig.h" #include "cddb.h" -#include "logging.h" #include "config-musicbrainz.h" #ifdef HAVE_MUSICBRAINZ5 #include "musicbrainz/musicbrainzlookup.h" #endif -#include <QtCore/QFile> -#include <QtCore/QDir> -#include <QtCore/QTextStream> +#include <kdebug.h> +#include <kstandarddirs.h> + +#include <QFile> +#include <QDir> +#include <QTextStream> namespace KCDDB { @@ -42,7 +44,7 @@ namespace KCDDB { QString cddbId = CDDB::trackOffsetListToId(offsetList); - qCDebug(LIBKCDDB) << "Looking up " << cddbId << " in CDDB cache"; + kDebug(60010) << "Looking up " << cddbId << " in CDDB cache"; CDInfoList infoList; @@ -102,7 +104,7 @@ namespace KCDDB else { if (source != QLatin1String( "user" )) - qCWarning(LIBKCDDB) << "Unknown source " << source << " for CDInfo"; + kWarning(60010) << "Unknown source " << source << " for CDInfo"; cacheDir = QLatin1String( "/user/" ); QString id = CDDB::trackOffsetListToId(offsetList); @@ -121,12 +123,12 @@ namespace KCDDB { if (!dir.mkpath(cacheDir)) { - qCWarning(LIBKCDDB) << "Couldn't create cache directory " << cacheDir; + kWarning(60010) << "Couldn't create cache directory " << cacheDir; return; } } - qCDebug(LIBKCDDB) << "Storing " << cacheFile << " in CDDB cache"; + kDebug(60010) << "Storing " << cacheFile << " in CDDB cache"; QFile f(cacheDir + QLatin1Char( '/' ) + cacheFile); if ( f.open(QIODevice::WriteOnly) ) @@ -137,7 +139,7 @@ namespace KCDDB f.close(); } } else { - qDebug() << "There's no cache dir defined, not storing it"; + kDebug(60010) << "There's no cache dir defined, not storing it"; } } } diff --git a/libkcddb/cache.h b/libkcddb/cache.h index 3858ad4..0f67c10 100644 --- a/libkcddb/cache.h +++ b/libkcddb/cache.h @@ -22,10 +22,12 @@ #ifndef KCDDB_CACHE_H #define KCDDB_CACHE_H +#include <qpair.h> +#include <QString> + #include "kcddb.h" #include "cdinfo.h" - -#include <QtCore/QString> +#include <kdemacros.h> namespace KCDDB { diff --git a/libkcddb/categories.cpp b/libkcddb/categories.cpp index b21b661..222df47 100644 --- a/libkcddb/categories.cpp +++ b/libkcddb/categories.cpp @@ -8,63 +8,28 @@ #include "categories.h" -#include "kcddbi18n.h" - -class KCDDB::Categories::Private -{ -public: - QStringList cddb; - QStringList i18n; -}; +#include <klocale.h> KCDDB::Categories::Categories() - : d(new Private) { // These are only 11 Category values defined by CDDB. See // // http://www.freedb.org/modules.php?name=Sections&sop=viewarticle&artid=26 // - d->cddb << QLatin1String( "blues" ) << QLatin1String( "classical" ) << QLatin1String( "country" ) << + m_cddb << QLatin1String( "blues" ) << QLatin1String( "classical" ) << QLatin1String( "country" ) << QLatin1String( "data" ) << QLatin1String( "folk" ) << QLatin1String( "jazz" ) << QLatin1String( "misc" ) << QLatin1String( "newage" ) << QLatin1String( "reggae" ) << QLatin1String( "rock" ) << QLatin1String( "soundtrack" ); - d->i18n << i18n("Blues") << i18n("Classical") << i18nc("music genre", "Country") << + m_i18n << i18n("Blues") << i18n("Classical") << i18nc("music genre", "Country") << i18n("Data") << i18n("Folk") << i18n("Jazz") << i18n("Miscellaneous") << i18n("New Age") << i18n("Reggae") << i18n("Rock") << i18n("Soundtrack"); } -KCDDB::Categories::~Categories() -{ - delete d; -} - -KCDDB::Categories::Categories(const Categories& other) - :d(new Private) -{ - *d = *other.d; -} - -KCDDB::Categories& KCDDB::Categories::operator=(const Categories& other) -{ - *d = *other.d; - return *this; -} - -const QStringList &KCDDB::Categories::cddbList() const -{ - return d->cddb; -} - -const QStringList &KCDDB::Categories::i18nList() const -{ - return d->i18n; -} - const QString KCDDB::Categories::cddb2i18n(const QString &category) const { - int index = d->cddb.indexOf(category.trimmed()); + int index = m_cddb.indexOf(category.trimmed()); if (index != -1) { - return d->i18n[index]; + return m_i18n[index]; } else { @@ -74,10 +39,10 @@ const QString KCDDB::Categories::cddb2i18n(const QString &category) const const QString KCDDB::Categories::i18n2cddb(const QString &category) const { - int index = d->i18n.indexOf(category.trimmed()); + int index = m_i18n.indexOf(category.trimmed()); if (index != -1) { - return d->cddb[index]; + return m_cddb[index]; } else { diff --git a/libkcddb/categories.h b/libkcddb/categories.h index d96ae35..c2d28fa 100644 --- a/libkcddb/categories.h +++ b/libkcddb/categories.h @@ -8,26 +8,21 @@ #ifndef KCDDB_CATEGORIES_H #define KCDDB_CATEGORIES_H -#include <libkcddb/kcddb_export.h> -#include <QtCore/QString> -#include <QtCore/QStringList> +#include <QString> +#include <qstringlist.h> namespace KCDDB { /** * Category values defined by CDDB. */ - class KCDDB_EXPORT Categories + class Categories { public: Categories(); - Categories(const Categories&); - ~Categories(); - Categories& operator=(const Categories&); - - const QStringList &cddbList() const; - const QStringList &i18nList() const; + const QStringList &cddbList() const { return m_cddb; } + const QStringList &i18nList() const { return m_i18n; } /** * Lookup the CDDB category, and return the i18n'd version. @@ -39,8 +34,8 @@ namespace KCDDB */ const QString i18n2cddb(const QString &category) const; private: - class Private; - Private * const d; + QStringList m_cddb; + QStringList m_i18n; }; } diff --git a/libkcddb/cddb.cpp b/libkcddb/cddb.cpp index e86fe9f..9518f87 100644 --- a/libkcddb/cddb.cpp +++ b/libkcddb/cddb.cpp @@ -22,12 +22,12 @@ #include "cddb.h" #include "categories.h" -#include "kcddbi18n.h" -#include <KCoreAddons/KStringHandler> +#include <qstringlist.h> -#include <QtCore/QDebug> -#include <QtCore/QStringList> +#include <kdebug.h> +#include <kstringhandler.h> +#include <klocale.h> namespace KCDDB { diff --git a/libkcddb/cddb.h b/libkcddb/cddb.h index 8adc077..202f1d9 100644 --- a/libkcddb/cddb.h +++ b/libkcddb/cddb.h @@ -22,13 +22,12 @@ #ifndef KCDDB_CDDB_H #define KCDDB_CDDB_H +#include <QtCore/QString> +#include <QtCore/QList> #include <libkcddb/kcddb.h> #include <libkcddb/cdinfo.h> #include <libkcddb/kcddbconfig.h> -#include <QtCore/QList> -#include <QtCore/QString> - namespace KCDDB { class CDDB diff --git a/libkcddb/cddbplookup.cpp b/libkcddb/cddbplookup.cpp index 06a7f9f..2f3c772 100644 --- a/libkcddb/cddbplookup.cpp +++ b/libkcddb/cddbplookup.cpp @@ -20,9 +20,10 @@ */ #include "cddbplookup.h" -#include "logging.h" -#include <QtCore/QByteArray> +#include <kdebug.h> + +#include <qbytearray.h> namespace KCDDB { @@ -89,7 +90,7 @@ namespace KCDDB void CDDBPLookup::close() { - qCDebug(LIBKCDDB) << "Disconnect from server..."; + kDebug(60010) << "Disconnect from server..."; if ( isConnected() ) { socket_->close(); @@ -103,16 +104,16 @@ namespace KCDDB if ( 200 == serverStatus ) { - qCDebug(LIBKCDDB) << "Server response: read-only"; + kDebug(60010) << "Server response: read-only"; readOnly_ = true; } else if ( 201 == serverStatus ) { - qCDebug(LIBKCDDB) << "Server response: read-write"; + kDebug(60010) << "Server response: read-write"; } else { - qCDebug(LIBKCDDB) << "Server response: bugger off"; + kDebug(60010) << "Server response: bugger off"; return false; } @@ -126,11 +127,11 @@ namespace KCDDB if ( ( 200 != serverStatus ) && ( 402 != serverStatus ) ) { - qCDebug(LIBKCDDB) << "Handshake was too tight. Letting go."; + kDebug(60010) << "Handshake was too tight. Letting go."; return false; } - qCDebug(LIBKCDDB) << "Handshake was warm and firm"; + kDebug(60010) << "Handshake was warm and firm"; return true; } @@ -141,11 +142,11 @@ namespace KCDDB { if ( !isConnected() ) { - qCDebug(LIBKCDDB) << "socket status: " << socket_->state(); + kDebug(60010) << "socket status: " << socket_->state(); return -1; } - qCDebug(LIBKCDDB) << "WRITE: [" << line << "]"; + kDebug(60010) << "WRITE: [" << line << "]"; QByteArray buf(line.toUtf8()); buf.append( '\n' ); diff --git a/libkcddb/cddbplookup.h b/libkcddb/cddbplookup.h index ee5aaf6..6c4244c 100644 --- a/libkcddb/cddbplookup.h +++ b/libkcddb/cddbplookup.h @@ -22,9 +22,9 @@ #ifndef KCDDB_CDDBP_LOOKUP_H #define KCDDB_CDDBP_LOOKUP_H -#include "lookup.h" +#include <qtcpsocket.h> -#include <QtNetwork/QTcpSocket> +#include "lookup.h" namespace KCDDB { diff --git a/libkcddb/cdinfo.cpp b/libkcddb/cdinfo.cpp index 4c1d67e..ee1cd39 100644 --- a/libkcddb/cdinfo.cpp +++ b/libkcddb/cdinfo.cpp @@ -24,10 +24,9 @@ #include "client.h" #include "cddb.h" -#include "logging.h" -#include <KCoreAddons/KStringHandler> -#include <QtCore/QDebug> +#include <kdebug.h> +#include <kstringhandler.h> #include <QMap> @@ -120,13 +119,13 @@ namespace KCDDB void set(const QString& type, const QVariant &d) { - //qDebug() << "set: " << type << ", " << d.toString(); + //kDebug() << "set: " << type << ", " << d.toString(); if(type.contains(QRegExp( QLatin1String( "^T.*_.*$" )) )){ - qCDebug(LIBKCDDB) << "Error: custom cdinfo::set data can not start with T and contain a _"; + kDebug(60010) << "Error: custom cdinfo::set data can not start with T and contain a _"; return; } if(type.toUpper() == QLatin1String( "DTITLE" )){ - qCDebug(LIBKCDDB) << "Error: type: DTITLE is reserved and can not be set."; + kDebug(60010) << "Error: type: DTITLE is reserved and can not be set."; return; } @@ -228,7 +227,7 @@ namespace KCDDB bool ok; int track = get(QLatin1String( "tracknumber" )).toInt(&ok); if(!ok) - qCDebug(LIBKCDDB) << "Warning toString() on a track that doesn't have track number assigned."; + kDebug(60010) << "Warning toString() on a track that doesn't have track number assigned."; QMap<QString, QVariant>::const_iterator i = d->data.constBegin(); while (i != d->data.constEnd()) { if(i.key() != QLatin1String( "COMMENT" ) && i.key() != QLatin1String( "TITLE" ) && i.key() != QLatin1String( "ARTIST" ) && i.key() != QLatin1String( "TRACKNUMBER" )) { @@ -413,7 +412,7 @@ namespace KCDDB if ( get(Genre).toString().isEmpty() ) set(Genre, QLatin1String( "Unknown" )); - qCDebug(LIBKCDDB) << "Loaded CDInfo for " << get(QLatin1String( "discid" )).toString(); + kDebug(60010) << "Loaded CDInfo for " << get(QLatin1String( "discid" )).toString(); return true; } @@ -573,7 +572,7 @@ namespace KCDDB return d->trackInfoList[trackNumber]; else { - qWarning() << "Couldn't find track " << trackNumber; + kWarning() << "Couldn't find track " << trackNumber; return TrackInfo(); } } diff --git a/libkcddb/cdinfo.h b/libkcddb/cdinfo.h index a8702d8..6322f59 100644 --- a/libkcddb/cdinfo.h +++ b/libkcddb/cdinfo.h @@ -22,9 +22,9 @@ #ifndef KCDDB_CDINFO_H #define KCDDB_CDINFO_H -#include <libkcddb/kcddb_export.h> #include <QtCore/QStringList> #include <QtCore/QVariant> +#include <libkcddb/kcddb_export.h> namespace KCDDB { diff --git a/libkcddb/cdinfodialog.cpp b/libkcddb/cdinfodialog.cpp index b5d2e4e..e7f7839 100644 --- a/libkcddb/cdinfodialog.cpp +++ b/libkcddb/cdinfodialog.cpp @@ -21,17 +21,15 @@ #include "cdinfodialog.h" #include "cdinfoencodingwidget.h" -#include "kcddbi18n.h" #include "ui_cdinfodialog.h" -#include <KCodecs/KCharsets> +#include <QTextCodec> +#include <QStringList> +#include <QStandardItemModel> -#include <QtCore/QDebug> -#include <QtCore/QStringList> -#include <QtCore/QTextCodec> -#include <QtCore/QTime> -#include <QtGui/QStandardItemModel> -#include <QtWidgets/QVBoxLayout> +#include <kdebug.h> +#include <kglobal.h> +#include <kcharsets.h> using KCDDB::TrackInfo; @@ -61,14 +59,12 @@ class CDInfoDialog::Private QLatin1String CDInfoDialog::Private::SEPARATOR = QLatin1String( " / " ); CDInfoDialog::CDInfoDialog(QWidget* parent) - : QDialog(parent), + : KDialog(parent), d(new Private) { QWidget* w = new QWidget(this); d->ui->setupUi(w); - - QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(w); + setMainWidget(w); d->info.set(QLatin1String( "source" ), QLatin1String( "user" )); @@ -81,8 +77,10 @@ class CDInfoDialog::Private d->ui->m_trackList->setModel(m_trackModel); // We want control over the visibility of this column. See artistChanged(). - d->ui->m_trackList->header()->setSectionResizeMode(Private::TRACK_ARTIST, QHeaderView::Interactive); +// d->ui->m_trackList->setColumnWidthMode(Private::TRACK_ARTIST, Q3ListView::Manual); + // ensure we get our translations + KGlobal::locale()->insertCatalog( QLatin1String( "libkcddb" )); connect( d->ui->m_trackList, SIGNAL(activated(QModelIndex)), this, SLOT(slotTrackSelected(QModelIndex)) ); connect( d->ui->m_trackList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotTrackDoubleClicked(QModelIndex)) ); connect( d->ui->m_artist, SIGNAL(textChanged(QString)), this, SLOT(artistChanged(QString)) ); @@ -102,21 +100,23 @@ class CDInfoDialog::Private { delete d->ui; delete d; + } void CDInfoDialog::slotNextTrack() { - QModelIndex index = d->ui->m_trackList->indexBelow(d->ui->m_trackList->currentIndex()); - if (index.isValid()) +/* QTreeWidgetItem *item = d->ui->m_trackList->itemBelow(d->ui->m_trackList->currentItem()); + if (item) { - d->ui->m_trackList->setCurrentIndex(index); - d->ui->m_trackList->scrollTo(index, QTreeView::EnsureVisible); - } + + d->ui->m_trackList->setCurrentItem(item);*/ +// d->ui->m_trackList->ensureItemVisible(item); +// } } void CDInfoDialog::slotTrackDoubleClicked(const QModelIndex &index) { - d->ui->m_trackList->edit(index); +// d->ui->m_trackList->editItem(item); } void CDInfoDialog::setInfo( const KCDDB::CDInfo &info, const KCDDB::TrackOffsetList &trackStartFrames ) @@ -149,10 +149,10 @@ class CDInfoDialog::Private QList<QStandardItem *> trackItems = QList<QStandardItem *>(); TrackInfo ti(info.track(i)); QStandardItem *trackNumberItem = new QStandardItem(QString().sprintf("%02d", i + 1)); - trackNumberItem->setEditable(false); + trackNumberItem->setEditable(FALSE); trackItems << trackNumberItem; QStandardItem *trackLengthItem = new QStandardItem(framesTime(trackStartFrames[i + 1] - trackStartFrames[i])); - trackLengthItem->setEditable(false); + trackLengthItem->setEditable(FALSE); trackItems << trackLengthItem; QStandardItem *trackTitleItem = new QStandardItem(ti.get(Title).toString()); trackItems << trackTitleItem; @@ -263,8 +263,9 @@ class CDInfoDialog::Private void CDInfoDialog::slotChangeEncoding() { - QDialog* dialog = new QDialog(this); - dialog->setWindowTitle(i18n("Change Encoding")); + KDialog* dialog = new KDialog(this); + dialog->setCaption(i18n("Change Encoding")); + dialog->setButtons( KDialog::Ok | KDialog::Cancel); dialog->setModal( true ); @@ -280,12 +281,11 @@ class CDInfoDialog::Private KCDDB::CDInfoEncodingWidget* encWidget = new KCDDB::CDInfoEncodingWidget( dialog, d->ui->m_artist->text(),d->ui->m_title->text(), songTitles); - QVBoxLayout* layout = new QVBoxLayout(dialog); - layout->addWidget(encWidget); + dialog->setMainWidget(encWidget); if (dialog->exec()) { - KCharsets* charsets = KCharsets::charsets(); + KCharsets* charsets = KGlobal::charsets(); QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encWidget->selectedEncoding())); d->ui->m_artist->setText(codec->toUnicode(d->ui->m_artist->text().toLatin1())); @@ -307,3 +307,4 @@ class CDInfoDialog::Private } } +#include "cdinfodialog.moc" diff --git a/libkcddb/cdinfodialog.h b/libkcddb/cdinfodialog.h index cd049c5..b52773e 100644 --- a/libkcddb/cdinfodialog.h +++ b/libkcddb/cdinfodialog.h @@ -24,14 +24,14 @@ #include <libkcddb/cdinfo.h> #include <libkcddb/kcddb.h> -#include <QtWidgets/QDialog> +#include <KDE/KDialog> class QStandardItemModel; class QModelIndex; namespace KCDDB { - class KCDDB_EXPORT CDInfoDialog : public QDialog + class KCDDB_EXPORT CDInfoDialog : public KDialog { Q_OBJECT public: diff --git a/libkcddb/cdinfodialog.ui b/libkcddb/cdinfodialog.ui index 4d60d62..9ca3400 100644 --- a/libkcddb/cdinfodialog.ui +++ b/libkcddb/cdinfodialog.ui @@ -36,7 +36,7 @@ </widget> </item> <item row="1" column="1" colspan="3"> - <widget class="QLineEdit" name="m_title"> + <widget class="KLineEdit" name="m_title"> <property name="toolTip"> <string>Use the name of the artist if there is no title.</string> </property> @@ -60,7 +60,7 @@ </widget> </item> <item row="0" column="1" colspan="3"> - <widget class="QLineEdit" name="m_artist"> + <widget class="KLineEdit" name="m_artist"> <property name="toolTip"> <string>Write names as "first last", not "last, first". Omit any leading "The". Use "Various" for compilations.</string> </property> @@ -97,7 +97,7 @@ </widget> </item> <item row="4" column="1"> - <widget class="QComboBox" name="m_category"> + <widget class="KComboBox" name="m_category"> <property name="enabled"> <bool>false</bool> </property> @@ -107,7 +107,7 @@ </widget> </item> <item row="3" column="1"> - <widget class="QSpinBox" name="m_year"> + <widget class="KIntSpinBox" name="m_year"> <property name="maximum"> <number>2100</number> </property> @@ -121,7 +121,7 @@ </widget> </item> <item row="2" column="1" colspan="3"> - <widget class="QLineEdit" name="m_comment"/> + <widget class="KLineEdit" name="m_comment"/> </item> <item row="2" column="0"> <widget class="QLabel" name="lb_comment"> @@ -144,7 +144,7 @@ </widget> </item> <item row="4" column="3"> - <widget class="QComboBox" name="m_genre"> + <widget class="KComboBox" name="m_genre"> <property name="toolTip"> <string>Avoid custom values, as they will be written to CDDB as-is.</string> </property> @@ -239,10 +239,29 @@ </widget> </item> <item> - <widget class="QLineEdit" name="m_playOrder"/> + <widget class="KLineEdit" name="m_playOrder"/> </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>KComboBox</class> + <extends>QComboBox</extends> + <header>kcombobox.h</header> + </customwidget> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>KIntSpinBox</class> + <extends>QSpinBox</extends> + <header>knuminput.h</header> + <container>1</container> + </customwidget> + </customwidgets> <tabstops> <tabstop>m_artist</tabstop> <tabstop>m_title</tabstop> diff --git a/libkcddb/cdinfoencodingwidget.cpp b/libkcddb/cdinfoencodingwidget.cpp index 568cfe7..97f6071 100644 --- a/libkcddb/cdinfoencodingwidget.cpp +++ b/libkcddb/cdinfoencodingwidget.cpp @@ -19,10 +19,10 @@ #include "cdinfoencodingwidget.h" -#include "kcddbi18n.h" - -#include <KCodecs/KCharsets> -#include <QtCore/QTextCodec> +#include <qtextcodec.h> +#include <klocale.h> +#include <kglobal.h> +#include <kcharsets.h> namespace KCDDB { @@ -33,7 +33,7 @@ namespace KCDDB { setupUi(this); - encodingCombo->addItems(KCharsets::charsets()->descriptiveEncodingNames()); + encodingCombo->addItems(KGlobal::charsets()->descriptiveEncodingNames()); slotEncodingChanged(encodingCombo->currentText()); @@ -48,7 +48,7 @@ namespace KCDDB void CDInfoEncodingWidget::slotEncodingChanged(const QString& encoding) { - KCharsets* charsets = KCharsets::charsets(); + KCharsets* charsets = KGlobal::charsets(); QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encoding)); @@ -67,3 +67,4 @@ namespace KCDDB } } +#include "cdinfoencodingwidget.moc" diff --git a/libkcddb/cdinfoencodingwidget.ui b/libkcddb/cdinfoencodingwidget.ui index 53ca791..0f92cf7 100644 --- a/libkcddb/cdinfoencodingwidget.ui +++ b/libkcddb/cdinfoencodingwidget.ui @@ -11,21 +11,19 @@ </rect> </property> <layout class="QGridLayout"> - <property name="leftMargin"> - <number>10</number> - </property> - <property name="topMargin"> - <number>10</number> - </property> - <property name="rightMargin"> - <number>10</number> - </property> - <property name="bottomMargin"> + <property name="margin"> <number>10</number> </property> <property name="spacing"> <number>6</number> </property> + <item row="0" column="0"> + <widget class="QLabel" name="encodingLabel"> + <property name="text"> + <string>Encoding</string> + </property> + </widget> + </item> <item row="0" column="1"> <widget class="QComboBox" name="encodingCombo"/> </item> @@ -38,16 +36,7 @@ <property name="spacing"> <number>6</number> </property> - <property name="leftMargin"> - <number>10</number> - </property> - <property name="topMargin"> - <number>10</number> - </property> - <property name="rightMargin"> - <number>10</number> - </property> - <property name="bottomMargin"> + <property name="margin"> <number>10</number> </property> <item> @@ -58,7 +47,7 @@ </widget> </item> <item> - <widget class="QListWidget" name="songsBox"> + <widget class="KListWidget" name="songsBox"> <property name="minimumSize"> <size> <width>300</width> @@ -70,22 +59,15 @@ </layout> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="encodingLabel"> - <property name="text"> - <string>Encoding</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>KListWidget</class> + <extends>QListWidget</extends> + <header>klistwidget.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/libkcddb/client.cpp b/libkcddb/client.cpp index b122495..6ceb0f5 100644 --- a/libkcddb/client.cpp +++ b/libkcddb/client.cpp @@ -31,7 +31,6 @@ #include "asynchttpsubmit.h" #include "cache.h" #include "lookup.h" -#include "logging.h" #include "config-musicbrainz.h" #ifdef HAVE_MUSICBRAINZ5 @@ -39,6 +38,8 @@ #include "musicbrainz/asyncmusicbrainzlookup.h" #endif +#include <kdebug.h> + namespace KCDDB { class Client::Private @@ -70,7 +71,7 @@ namespace KCDDB Client::Client() : d(new Private) { - d->config.load(); + d->config.readConfig(); } Client::~Client() @@ -110,7 +111,7 @@ namespace KCDDB if ( trackOffsetList.count() <= 1 ) { - qCDebug(LIBKCDDB) << "Lookup called with empty offset list"; + kDebug(60010) << "Lookup called with empty offset list"; return NoRecordFound; } @@ -118,7 +119,7 @@ namespace KCDDB { d->cdInfoList = Cache::lookup( trackOffsetList, config() ); - qCDebug(LIBKCDDB) << "Found " << d->cdInfoList.count() << " hit(s)"; + kDebug(60010) << "Found " << d->cdInfoList.count() << " hit(s)"; if ( !d->cdInfoList.isEmpty() ) { @@ -320,7 +321,7 @@ namespace KCDDB break; } default: - qCDebug(LIBKCDDB) << "Unsupported transport: "; + kDebug(60010) << "Unsupported transport: "; // << CDDB::transportToString(d->config.submitTransport()) << endl; return UnknownError; break; @@ -369,4 +370,7 @@ namespace KCDDB } } +#include "client.moc" + + // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 diff --git a/libkcddb/client.h b/libkcddb/client.h index 30e39d2..136cab7 100644 --- a/libkcddb/client.h +++ b/libkcddb/client.h @@ -21,10 +21,11 @@ #ifndef KCDDB_CLIENT_H #define KCDDB_CLIENT_H -#include "cdinfo.h" -#include "kcddb.h" #include "kcddbconfig.h" +#include "cdinfo.h" #include <QtCore/QObject> +#include "kcddb.h" +#include <kdemacros.h> namespace KCDDB { diff --git a/libkcddb/genres.cpp b/libkcddb/genres.cpp index 281d349..3af2558 100644 --- a/libkcddb/genres.cpp +++ b/libkcddb/genres.cpp @@ -8,7 +8,7 @@ #include "genres.h" -#include "kcddbi18n.h" +#include <klocale.h> class KCDDB::Genres::Private { diff --git a/libkcddb/genres.h b/libkcddb/genres.h index de3dca3..d0fe2bb 100644 --- a/libkcddb/genres.h +++ b/libkcddb/genres.h @@ -8,8 +8,8 @@ #ifndef KCDDB_GENRES_H #define KCDDB_GENRES_H -#include <libkcddb/kcddb_export.h> #include <QtCore/QStringList> +#include <libkcddb/kcddb_export.h> namespace KCDDB { diff --git a/libkcddb/httplookup.cpp b/libkcddb/httplookup.cpp index 0a5044d..9a43712 100644 --- a/libkcddb/httplookup.cpp +++ b/libkcddb/httplookup.cpp @@ -21,9 +21,8 @@ #include "httplookup.h" -#include <KIO/Job> -#include <QtCore/QDebug> -#include <QtCore/QUrlQuery> +#include <kio/job.h> +#include <kdebug.h> namespace KCDDB { @@ -67,7 +66,7 @@ namespace KCDDB void HTTPLookup::initURL( const QString & hostName, uint port ) { - cgiURL_.setScheme( QLatin1String( "http" ) ); + cgiURL_.setProtocol( QLatin1String( "http" ) ); cgiURL_.setHost( hostName ); cgiURL_.setPort( port ); cgiURL_.setPath( QLatin1String( "/~cddb/cddb.cgi" ) ); @@ -78,16 +77,17 @@ namespace KCDDB void HTTPLookup::makeURL( const QString & cmd ) { + // The whole query has to constructed each time as the + // CDDB CGI script expects the parameters in strict order + + cgiURL_.setQuery( QString::null ); //krazy:exclude=nullstrassign for old broken gcc + QString hello = QString::fromLatin1("%1 %2 %3 %4") .arg(user_, localHostName_, clientName(), clientVersion()); - // The whole query has to constructed each time as the - // CDDB CGI script expects the parameters in strict order - QUrlQuery query; - query.addQueryItem( QLatin1String( "cmd" ), cmd ); - query.addQueryItem( QLatin1String( "hello" ), hello ); - query.addQueryItem( QLatin1String( "proto" ), QLatin1String( "6" ) ); - cgiURL_.setQuery( query ); + cgiURL_.addQueryItem( QLatin1String( "cmd" ), cmd ); + cgiURL_.addQueryItem( QLatin1String( "hello" ), hello ); + cgiURL_.addQueryItem( QLatin1String( "proto" ), QLatin1String( "6" ) ); } void @@ -183,4 +183,6 @@ namespace KCDDB } } +#include "httplookup.moc" + // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 diff --git a/libkcddb/httplookup.h b/libkcddb/httplookup.h index 83bcb17..c4861ac 100644 --- a/libkcddb/httplookup.h +++ b/libkcddb/httplookup.h @@ -22,8 +22,9 @@ #ifndef KCDDB_HTTP_LOOKUP_H #define KCDDB_HTTP_LOOKUP_H +#include <kurl.h> + #include "lookup.h" -#include <QtCore/QUrl> namespace KIO { @@ -68,7 +69,7 @@ namespace KCDDB protected: bool block_; - QUrl cgiURL_; + KUrl cgiURL_; QByteArray data_; State state_; Result result_; diff --git a/libkcddb/httpsubmit.cpp b/libkcddb/httpsubmit.cpp index 96386b9..402c98d 100644 --- a/libkcddb/httpsubmit.cpp +++ b/libkcddb/httpsubmit.cpp @@ -20,15 +20,15 @@ #include "httpsubmit.h" -#include <KIO/Job> -#include <QtCore/QDebug> +#include <kdebug.h> +#include <kio/job.h> namespace KCDDB { HTTPSubmit::HTTPSubmit(const QString& from, const QString& hostname, uint port) : Submit(), from_(from) { - url_.setScheme( QLatin1String( "http" )); + url_.setProtocol( QLatin1String( "http" )); url_.setHost(hostname); url_.setPort(port); url_.setPath(QLatin1String( "/~cddb/submit.cgi" )); diff --git a/libkcddb/httpsubmit.h b/libkcddb/httpsubmit.h index 93f06ba..a37f773 100644 --- a/libkcddb/httpsubmit.h +++ b/libkcddb/httpsubmit.h @@ -20,7 +20,7 @@ */ #include "submit.h" -#include <QtCore/QUrl> +#include <kurl.h> namespace KCDDB { @@ -33,7 +33,7 @@ namespace KCDDB protected: virtual KIO::Job* createJob(const CDInfo& cdInfo); - QUrl url_; + KUrl url_; QString from_; } ; } diff --git a/libkcddb/kcddb.cpp b/libkcddb/kcddb.cpp index ae6d8c0..b90873f 100644 --- a/libkcddb/kcddb.cpp +++ b/libkcddb/kcddb.cpp @@ -19,7 +19,7 @@ #include "kcddb.h" -#include "kcddbi18n.h" +#include <klocale.h> namespace KCDDB { diff --git a/libkcddb/kcddb_export.h b/libkcddb/kcddb_export.h new file mode 100644 index 0000000..6ac6d57 --- /dev/null +++ b/libkcddb/kcddb_export.h @@ -0,0 +1,40 @@ +/* This file is part of the KDE project + Copyright (C) 2007 David Faure <[email protected]> + + This library 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 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 + 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. +*/ + +#ifndef KCDDB_EXPORT_H +#define KCDDB_EXPORT_H + +/* needed for KDE_EXPORT and KDE_IMPORT macros */ +#include <kdemacros.h> + +#ifndef KCDDB_EXPORT +# if defined(MAKE_KCDDB_LIB) + /* We are building this library */ +# define KCDDB_EXPORT KDE_EXPORT +# else + /* We are using this library */ +# define KCDDB_EXPORT KDE_IMPORT +# endif +#endif + +# ifndef KCDDB_EXPORT_DEPRECATED +# define KCDDB_EXPORT_DEPRECATED KDE_DEPRECATED KCDDB_EXPORT +# endif + +#endif diff --git a/libkcddb/kcddbconfig.cpp b/libkcddb/kcddbconfig.cpp index 6cb99a6..27f2a34 100644 --- a/libkcddb/kcddbconfig.cpp +++ b/libkcddb/kcddbconfig.cpp @@ -22,7 +22,7 @@ #include <libkcddb/kcddbconfig.h> -#include <KConfigCore/KEMailSettings> +#include <kemailsettings.h> namespace KCDDB { @@ -49,7 +49,7 @@ namespace KCDDB { loadEmailSettings(); - load(); + readConfig(); } } diff --git a/libkcddb/kcddbi18n.h b/libkcddb/kcddbi18n.h deleted file mode 100644 index a1fb2ca..0000000 --- a/libkcddb/kcddbi18n.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef KCDDBI18N_H -#define KCDDBI18N_H - -#define TRANSLATION_DOMAIN "libkcddb" -#include <KI18n/KLocalizedString> - -#endif // KCDDBI18N_H diff --git a/libkcddb/logging.cpp b/libkcddb/logging.cpp deleted file mode 100644 index 03cab84..0000000 --- a/libkcddb/logging.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2003-2004 Richard Lärkäng <[email protected]> - - This library 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 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 - 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. -*/ - -#include "logging.h" - -Q_LOGGING_CATEGORY(LIBKCDDB, "libkcddb") diff --git a/libkcddb/logging.h b/libkcddb/logging.h deleted file mode 100644 index d3115a8..0000000 --- a/libkcddb/logging.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LOGGING_H -#define LOGGING_H -/* - Copyright (C) 2003 Richard Lärkäng <[email protected]> - - This library 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 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 - 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. -*/ - -#include <QtCore/QLoggingCategory> - -Q_DECLARE_LOGGING_CATEGORY(LIBKCDDB) - -#endif // LOGGING_H diff --git a/libkcddb/lookup.cpp b/libkcddb/lookup.cpp index b7efae0..d3ec89a 100644 --- a/libkcddb/lookup.cpp +++ b/libkcddb/lookup.cpp @@ -21,7 +21,7 @@ #include "lookup.h" -#include <QtCore/QDebug> +#include <kdebug.h> namespace KCDDB { diff --git a/libkcddb/lookup.h b/libkcddb/lookup.h index fec63ce..5b5556b 100644 --- a/libkcddb/lookup.h +++ b/libkcddb/lookup.h @@ -22,12 +22,11 @@ #ifndef KCDDB_LOOKUP_H #define KCDDB_LOOKUP_H -#include <libkcddb/cddb.h> -#include <libkcddb/cdinfo.h> - #include <QtCore/QList> #include <QtCore/QObject> #include <QtCore/QPair> +#include <libkcddb/cddb.h> +#include <libkcddb/cdinfo.h> namespace KCDDB { diff --git a/libkcddb/musicbrainz/asyncmusicbrainzlookup.cpp b/libkcddb/musicbrainz/asyncmusicbrainzlookup.cpp index a9f8afe..c13c94f 100644 --- a/libkcddb/musicbrainz/asyncmusicbrainzlookup.cpp +++ b/libkcddb/musicbrainz/asyncmusicbrainzlookup.cpp @@ -21,9 +21,10 @@ #include "musicbrainzlookup.h" -#include <QtCore/QDebug> #include <QtCore/QThread> +#include <kdebug.h> + namespace KCDDB { class LookupThread : public QThread @@ -67,7 +68,7 @@ namespace KCDDB void AsyncMusicBrainzLookup::lookupFinished() { - qDebug() ; + kDebug() ; cdInfoList_ = m_lookupThread->m_lookupResponse; @@ -76,3 +77,5 @@ namespace KCDDB } // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 + +#include "asyncmusicbrainzlookup.moc" diff --git a/libkcddb/musicbrainz/musicbrainzlookup.cpp b/libkcddb/musicbrainz/musicbrainzlookup.cpp index aa6e08f..3364897 100644 --- a/libkcddb/musicbrainz/musicbrainzlookup.cpp +++ b/libkcddb/musicbrainz/musicbrainzlookup.cpp @@ -17,10 +17,15 @@ Boston, MA 02110-1301, USA. */ -#include "musicbrainzlookup.h" -#include "kcddbi18n.h" +#include "musicbrainzlookup.h" +#include <kdebug.h> +#include <kcodecs.h> +#include <klocale.h> +#include <qcryptographichash.h> +#include <cstdio> +#include <cstring> #include <musicbrainz5/Query.h> #include <musicbrainz5/Medium.h> #include <musicbrainz5/Release.h> @@ -34,14 +39,6 @@ #include <musicbrainz5/NameCredit.h> #include <musicbrainz5/SecondaryType.h> -#include <KCodecs/KCodecs> - -#include <QtCore/QCryptographicHash> -#include <QtCore/QDebug> - -#include <cstdio> -#include <cstring> - namespace KCDDB { MusicBrainzLookup::MusicBrainzLookup() @@ -58,19 +55,19 @@ namespace KCDDB { QString discId = calculateDiscId(trackOffsetList); - qDebug() << "Should lookup " << discId; + kDebug() << "Should lookup " << discId; MusicBrainz5::CQuery Query("libkcddb-0.5"); // Code adapted from libmusicbrainz/examples/cdlookup.cc try { - MusicBrainz5::CMetadata Metadata=Query.Query("discid",discId.toLatin1().constData()); + MusicBrainz5::CMetadata Metadata=Query.Query("discid",discId.toAscii().constData()); if (Metadata.Disc() && Metadata.Disc()->ReleaseList()) { MusicBrainz5::CReleaseList *ReleaseList=Metadata.Disc()->ReleaseList(); - qDebug() << "Found " << ReleaseList->NumItems() << " release(s)"; + kDebug() << "Found " << ReleaseList->NumItems() << " release(s)"; int relnr=1; @@ -93,22 +90,22 @@ namespace KCDDB //However, these releases will include information for all media in the release //So we need to filter out the only the media we want. - MusicBrainz5::CMediumList MediaList=FullRelease->MediaMatchingDiscID(discId.toLatin1().constData()); + MusicBrainz5::CMediumList MediaList=FullRelease->MediaMatchingDiscID(discId.toAscii().constData()); if (MediaList.NumItems() > 0) { /*if (FullRelease->ReleaseGroup()) - qDebug() << "Release group title: " << FullRelease->ReleaseGroup()->Title(); + kDebug() << "Release group title: " << FullRelease->ReleaseGroup()->Title(); else - qDebug() << "No release group for this release";*/ + kDebug() << "No release group for this release";*/ - qDebug() << "Found " << MediaList.NumItems() << " media item(s)"; + kDebug() << "Found " << MediaList.NumItems() << " media item(s)"; for (int i=0; i < MediaList.NumItems(); i++) { MusicBrainz5::CMedium* Medium= MediaList.Item(i); - /*qDebug() << "Found media: '" << Medium.Title() << "', position " << Medium.Position();*/ + /*kDebug() << "Found media: '" << Medium.Title() << "', position " << Medium.Position();*/ CDInfo info; info.set(QLatin1String( "source" ), QLatin1String( "musicbrainz" )); @@ -179,71 +176,71 @@ namespace KCDDB catch (MusicBrainz5::CConnectionError& Error) { - qDebug() << "Connection Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "Connection Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } catch (MusicBrainz5::CTimeoutError& Error) { - qDebug() << "Timeout Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "Timeout Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } catch (MusicBrainz5::CAuthenticationError& Error) { - qDebug() << "Authentication Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "Authentication Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } catch (MusicBrainz5::CFetchError& Error) { - qDebug() << "Fetch Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "Fetch Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } catch (MusicBrainz5::CRequestError& Error) { - qDebug() << "Request Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "Request Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } catch (MusicBrainz5::CResourceNotFoundError& Error) { - qDebug() << "ResourceNotFound Exception: '" << Error.what() << "'"; - qDebug() << "LastResult: " << Query.LastResult(); - qDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); - qDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); + kDebug() << "ResourceNotFound Exception: '" << Error.what() << "'"; + kDebug() << "LastResult: " << Query.LastResult(); + kDebug() << "LastHTTPCode: " << Query.LastHTTPCode(); + kDebug() << "LastErrorMessage: " << QString::fromUtf8(Query.LastErrorMessage().c_str()); return ServerError; } if (cdInfoList_.isEmpty()) { - qDebug() << "No record found"; + kDebug() << "No record found"; return NoRecordFound; } - qDebug() << "Query succeeded :-)"; + kDebug() << "Query succeeded :-)"; return Success; } @@ -305,7 +302,7 @@ namespace KCDDB dir.setNameFilters(QStringList(discid+QLatin1String( "*" ))); QStringList files = dir.entryList(); - qDebug() << "Cache files found: " << files.count(); + kDebug() << "Cache files found: " << files.count(); for (QStringList::iterator it = files.begin(); it != files.end(); ++it) { QFile f( dir.filePath(*it) ); @@ -323,7 +320,7 @@ namespace KCDDB infoList.append( info ); } else - qDebug() << "Could not read file: " << f.fileName(); + kDebug() << "Could not read file: " << f.fileName(); } } @@ -332,7 +329,7 @@ namespace KCDDB QString MusicBrainzLookup::artistFromCreditList(MusicBrainz5::CArtistCredit * artistCredit ) { - qDebug()/* << k_funcinfo*/; + kDebug() << k_funcinfo; QString artistName; MusicBrainz5::CNameCreditList *ArtistList=artistCredit->NameCreditList(); @@ -352,7 +349,7 @@ namespace KCDDB artistName += QString::fromUtf8(Name->JoinPhrase().c_str()); } - qDebug() << "Artist:" << artistName; + kDebug() << "Artist:" << artistName; } @@ -361,3 +358,5 @@ namespace KCDDB } // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1 + +#include "musicbrainzlookup.moc" diff --git a/libkcddb/sites.cpp b/libkcddb/sites.cpp index 7b042ff..65a2e48 100644 --- a/libkcddb/sites.cpp +++ b/libkcddb/sites.cpp @@ -19,12 +19,12 @@ #include "sites.h" -#include <KIO/Job> -#include <QtCore/QDebug> -#include <QtCore/QRegExp> -#include <QtCore/QTextStream> -#include <QtCore/QUrl> -#include <QtCore/QUrlQuery> +#include <kurl.h> +#include <kio/netaccess.h> +#include <kio/job.h> +#include <QTextStream> +#include <kdebug.h> +#include <QRegExp> namespace KCDDB { @@ -36,27 +36,26 @@ namespace KCDDB QList<Mirror> Sites::siteList() { - QUrl url; - url.setScheme( QLatin1String( "http" ) ); + KUrl url; + url.setProtocol( QLatin1String( "http" ) ); url.setHost( QLatin1String( "freedb.freedb.org" ) ); url.setPort( 80 ); url.setPath( QLatin1String( "/~cddb/cddb.cgi" ) ); + url.setQuery( QString::null ); //krazy:exclude=nullstrassign for old broken gcc + QString hello = QString::fromLatin1("%1 %2 %3 %4") .arg(QLatin1String( "libkcddb-user" ), QLatin1String( "localHost" ), CDDB::clientName(), CDDB::clientVersion()); - QUrlQuery query; - query.addQueryItem( QLatin1String( "cmd" ), QLatin1String( "sites" ) ); - query.addQueryItem( QLatin1String( "hello" ), hello ); - query.addQueryItem( QLatin1String( "proto" ), QLatin1String( "5" ) ); - url.setQuery( query ); + url.addQueryItem( QLatin1String( "cmd" ), QLatin1String( "sites" ) ); + url.addQueryItem( QLatin1String( "hello" ), hello ); + url.addQueryItem( QLatin1String( "proto" ), QLatin1String( "5" ) ); QList<Mirror> result; - KIO::TransferJob* job = KIO::get( url, KIO::NoReload, KIO::HideProgressInfo ); + KIO::Job* job = KIO::get( url, KIO::NoReload, KIO::HideProgressInfo ); QByteArray data; - QObject::connect( job, &KIO::TransferJob::data, [&data](KIO::Job *, const QByteArray &d){ data += d; } ); - if( job->exec() ) + if( KIO::NetAccess::synchronousRun( job, 0, &data ) ) { result = readData( data ); } @@ -104,7 +103,7 @@ namespace KCDDB m.port = rexp.cap(3).toUInt(); if (m.transport == Lookup::HTTP && rexp.cap(4) != QLatin1String( "/~cddb/cddb.cgi" )) - qWarning() << "Non default urls are not supported for http"; + kWarning() << "Non default urls are not supported for http"; m.description = rexp.cap(5); } diff --git a/libkcddb/sites.h b/libkcddb/sites.h index 97a157f..3a4121b 100644 --- a/libkcddb/sites.h +++ b/libkcddb/sites.h @@ -20,10 +20,10 @@ #ifndef KCDDB_SITES_H #define KCDDB_SITES_H +#include <QtCore/QList> #include <libkcddb/cddb.h> #include <libkcddb/lookup.h> #include <libkcddb/kcddb_export.h> -#include <QtCore/QList> namespace KCDDB { diff --git a/libkcddb/smtpsubmit.cpp b/libkcddb/smtpsubmit.cpp index 2608e50..3e74ce9 100644 --- a/libkcddb/smtpsubmit.cpp +++ b/libkcddb/smtpsubmit.cpp @@ -18,9 +18,9 @@ */ #include "smtpsubmit.h" -#include "logging.h" -#include <KIO/Job> +#include <kdebug.h> +#include <kio/job.h> namespace KCDDB { @@ -28,11 +28,11 @@ namespace KCDDB const QString& from, const QString& to) : Submit(), from_(from), to_(to) { - url_.setScheme(QLatin1String( "smtp" )); + url_.setProtocol(QLatin1String( "smtp" )); url_.setHost(hostname); url_.setPort(port); if (!username.isEmpty()) - url_.setUserName(username); + url_.setUser(username); url_.setPath(QLatin1String( "/send" )); } @@ -46,7 +46,7 @@ namespace KCDDB url_.setQuery(QString::fromLatin1("to=%1&subject=cddb %2 %3&from=%4") .arg(to_, cdInfo.get(Category).toString(), cdInfo.get(QLatin1String( "discid" )).toString(), from_)); - qCDebug(LIBKCDDB) << "Url is: " << url_.toDisplayString(); + kDebug(60010) << "Url is: " << url_.prettyUrl(); return KIO::storedPut(diskData_.toUtf8().data(), url_, -1, KIO::HideProgressInfo); } diff --git a/libkcddb/smtpsubmit.h b/libkcddb/smtpsubmit.h index 01da5b3..6a082b0 100644 --- a/libkcddb/smtpsubmit.h +++ b/libkcddb/smtpsubmit.h @@ -20,7 +20,7 @@ */ #include "submit.h" -#include <QtCore/QUrl> +#include <kurl.h> namespace KCDDB { @@ -35,7 +35,7 @@ namespace KCDDB virtual KIO::Job* createJob(const CDInfo& cdInfo); - QUrl url_; + KUrl url_; QString from_, to_; } ; } diff --git a/libkcddb/submit.cpp b/libkcddb/submit.cpp index ef806e9..99661cc 100644 --- a/libkcddb/submit.cpp +++ b/libkcddb/submit.cpp @@ -20,7 +20,8 @@ */ #include "submit.h" -#include "logging.h" + +#include <kdebug.h> namespace KCDDB { @@ -81,7 +82,7 @@ namespace KCDDB diskData_ += cdInfo.toString(true); - qCDebug(LIBKCDDB) << "diskData_ == " << diskData_; + kDebug(60010) << "diskData_ == " << diskData_; } bool Submit::validCategory( const QString& c ) diff --git a/libkcddb/submit.h b/libkcddb/submit.h index ae83222..e46fedb 100644 --- a/libkcddb/submit.h +++ b/libkcddb/submit.h @@ -25,7 +25,7 @@ #include "cddb.h" #include "cdinfo.h" -#include <QtCore/QObject> +#include <QObject> namespace KIO { diff --git a/libkcddb/synccddbplookup.cpp b/libkcddb/synccddbplookup.cpp index 8de04e2..a4d9625 100644 --- a/libkcddb/synccddbplookup.cpp +++ b/libkcddb/synccddbplookup.cpp @@ -20,9 +20,10 @@ */ #include "synccddbplookup.h" -#include "logging.h" -#include <QtCore/QStringList> +#include <qstringlist.h> +#include <kdebug.h> +#include <ksocketfactory.h> namespace KCDDB { @@ -46,13 +47,12 @@ namespace KCDDB { trackOffsetList_ = trackOffsetList; - socket_ = new QTcpSocket; - socket_->connectToHost(hostName, port); + socket_ = KSocketFactory::synchronousConnectToHost(QLatin1String( "cddbp" ), hostName, port); - if ( !socket_->waitForConnected(30000) ) + if ( !socket_->isValid() ) { - qCDebug(LIBKCDDB) << "Couldn't connect to " << socket_->peerName() << ":" << socket_->peerPort(); - qCDebug(LIBKCDDB) << "Socket error: " << socket_->errorString(); + kDebug(60010) << "Couldn't connect to " << socket_->peerName() << ":" << socket_->peerPort(); + kDebug(60010) << "Socket error: " << socket_->errorString(); if ( socket_->error() == QAbstractSocket::HostNotFoundError ) return HostNotFound; @@ -77,7 +77,7 @@ namespace KCDDB if (matchList_.isEmpty()) return NoRecordFound; - qCDebug(LIBKCDDB) << matchList_.count() << " matches found."; + kDebug(60010) << matchList_.count() << " matches found."; // For each match, read the cd info from the server and save it to // cdInfoList. @@ -186,7 +186,7 @@ namespace KCDDB { if ( !isConnected() ) { - qCDebug(LIBKCDDB) << "socket status: " << socket_->state(); + kDebug(60010) << "socket status: " << socket_->state(); return QString(); } diff --git a/libkcddb/synchttplookup.cpp b/libkcddb/synchttplookup.cpp index bc13303..bfe79d2 100644 --- a/libkcddb/synchttplookup.cpp +++ b/libkcddb/synchttplookup.cpp @@ -19,9 +19,13 @@ */ #include "synchttplookup.h" -#include "logging.h" -#include <KIO/Job> +#include <qstringlist.h> +#include <qapplication.h> + +#include <kdebug.h> +#include <kio/job.h> +#include <kio/netaccess.h> namespace KCDDB { @@ -53,7 +57,7 @@ namespace KCDDB if ( Success != result_ ) return result_; - qCDebug(LIBKCDDB) << matchList_.count() << " matches found."; + kDebug(60010) << matchList_.count() << " matches found."; if (matchList_.isEmpty()) return NoRecordFound; @@ -83,7 +87,7 @@ namespace KCDDB if ( Success != result_ ) return result_; - qCDebug(LIBKCDDB) << "runQuery() Result: " << resultToString(result_); + kDebug(60010) << "runQuery() Result: " << resultToString(result_); return result_; } @@ -105,16 +109,14 @@ namespace KCDDB Result SyncHTTPLookup::fetchURL() { - qCDebug(LIBKCDDB) << "About to fetch: " << cgiURL_.url(); + kDebug(60010) << "About to fetch: " << cgiURL_.url(); KIO::TransferJob* job = KIO::get( cgiURL_, KIO::NoReload, KIO::HideProgressInfo ); if ( 0 == job ) return ServerError; - QObject::connect( job, &KIO::TransferJob::data, [&](KIO::Job *, const QByteArray &data){ data_ += data; } ); - - if (!job->exec()) + if (!KIO::NetAccess::synchronousRun(job, 0, &data_)) return ServerError; jobFinished(); diff --git a/libkcddb/synchttpsubmit.cpp b/libkcddb/synchttpsubmit.cpp index 7bf47ad..7e13aa7 100644 --- a/libkcddb/synchttpsubmit.cpp +++ b/libkcddb/synchttpsubmit.cpp @@ -19,7 +19,8 @@ #include "synchttpsubmit.h" -#include <KIO/Job> +#include <kio/netaccess.h> +#include <kio/job.h> namespace KCDDB { @@ -36,7 +37,9 @@ namespace KCDDB Result SyncHTTPSubmit::runJob(KIO::Job* job) { - if (job->exec()) + bool success = KIO::NetAccess::synchronousRun(job, 0); + + if (success) return Success; else return UnknownError; diff --git a/libkcddb/syncsmtpsubmit.cpp b/libkcddb/syncsmtpsubmit.cpp index 8d327c3..19cc941 100644 --- a/libkcddb/syncsmtpsubmit.cpp +++ b/libkcddb/syncsmtpsubmit.cpp @@ -21,7 +21,8 @@ #include "cdinfo.h" -#include <KIO/Job> +#include <kio/netaccess.h> +#include <kio/job.h> namespace KCDDB { @@ -39,7 +40,7 @@ namespace KCDDB Result SyncSMTPSubmit::runJob(KIO::Job* job) { - if ( job->exec() ) + if ( KIO::NetAccess::synchronousRun(job, 0) ) return Success; return UnknownError; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2cb0633..e2e2aab 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,13 +1,24 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) -function(add_unit_tests) - foreach(test ${ARGN}) - add_executable(${test} ${test}.cpp) - add_test( ${test} ${test} ) - target_link_libraries(${test} Qt5::Test kcddb) - endforeach() -endfunction() +include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/../libkcddb ) -add_unit_tests( + +MACRO(KCDDB_EXECUTABLE_TESTS) + FOREACH(_testname ${ARGN}) + kde4_add_executable(${_testname} TEST ${_testname}.cpp) + target_link_libraries(${_testname} ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} kcddb) + ENDFOREACH(_testname) +ENDMACRO(KCDDB_EXECUTABLE_TESTS) +MACRO(KCDDB_UNIT_TESTS) + FOREACH(_testname ${ARGN}) + kde4_add_unit_test(${_testname} TESTNAME kcddb-${_testname} ${_testname}.cpp) + target_link_libraries(${_testname} ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} kcddb) + ENDFOREACH(_testname) +ENDMACRO(KCDDB_UNIT_TESTS) + +KCDDB_UNIT_TESTS( asynchttplookuptest asynccddblookuptest synccddblookuptest @@ -19,8 +30,13 @@ add_unit_tests( cachetest musicbrainztest-severaldiscs musicbrainztest-fulldate +) + +KCDDB_EXECUTABLE_TESTS( syncsmtpsubmittest asyncsmtpsubmittest asynchttpsubmittest synchttpsubmittest - sitestest) + sitestest +) + diff --git a/test/asynccddblookuptest.cpp b/test/asynccddblookuptest.cpp index 9558c56..03f79fe 100644 --- a/test/asynccddblookuptest.cpp +++ b/test/asynccddblookuptest.cpp @@ -17,10 +17,10 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "asynccddblookuptest.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" -#include <QtTest/QTest> void AsyncCDDBLookupTest::testLookup() { @@ -95,17 +95,17 @@ void AsyncCDDBLookupTest::testLookup() AsyncCDDBLookupTest::slotFinished(Result r) { m_result = r; - qDebug() << "AsyncCDDBLookupTest::slotResult: Got " << KCDDB::resultToString(r); + kDebug() << "AsyncCDDBLookupTest::slotResult: Got " << KCDDB::resultToString(r); CDInfoList l = client_->lookupResponse(); - qDebug() << "AsyncCDDBLookupTest::slotResult: Item count: " << l.count(); + kDebug() << "AsyncCDDBLookupTest::slotResult: Item count: " << l.count(); foreach(const CDInfo &i, l) { if (i.get("discid") == "a1107d0a" && i.get(Category) == "jazz") { - qDebug() << "Found the CD"; + kDebug() << "Found the CD"; m_info = i; break; } @@ -114,4 +114,6 @@ AsyncCDDBLookupTest::slotFinished(Result r) m_eventLoop.quit(); } -QTEST_GUILESS_MAIN(AsyncCDDBLookupTest) +QTEST_KDEMAIN(AsyncCDDBLookupTest, NoGUI) + +#include "asynccddblookuptest.moc" diff --git a/test/asynccddblookuptest.h b/test/asynccddblookuptest.h index efa6fce..5ce40fb 100644 --- a/test/asynccddblookuptest.h +++ b/test/asynccddblookuptest.h @@ -21,7 +21,7 @@ #define TEST_H #include <QEventLoop> -#include <QtCore/QObject> +#include <QObject> #include <libkcddb/client.h> #include <libkcddb/kcddb.h> diff --git a/test/asynchttplookuptest.cpp b/test/asynchttplookuptest.cpp index 56a3f74..3377987 100644 --- a/test/asynchttplookuptest.cpp +++ b/test/asynchttplookuptest.cpp @@ -18,10 +18,10 @@ */ +#include <qtest_kde.h> #include "asynchttplookuptest.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" -#include <QtTest/QTest> void AsyncHTTPLookupTest::testLookup() { @@ -96,17 +96,17 @@ void AsyncHTTPLookupTest::testLookup() AsyncHTTPLookupTest::slotFinished(Result r) { m_result = r; - qDebug() << "AsyncHTTPLookupTest::slotFinished: Got " << KCDDB::resultToString(r); + kDebug() << "AsyncHTTPLookupTest::slotFinished: Got " << KCDDB::resultToString(r); CDInfoList l = client_->lookupResponse(); - qDebug() << "AsyncHTTPLookupTest::slotFinished: Item count: " << l.count(); + kDebug() << "AsyncHTTPLookupTest::slotFinished: Item count: " << l.count(); foreach(const CDInfo &i, l) { if (i.get("discid") == "a1107d0a" && i.get(Category) == "jazz") { - qDebug() << "Found the CD"; + kDebug() << "Found the CD"; m_info = i; break; } @@ -115,4 +115,6 @@ AsyncHTTPLookupTest::slotFinished(Result r) m_eventLoop.quit(); } -QTEST_GUILESS_MAIN(AsyncHTTPLookupTest) +QTEST_KDEMAIN(AsyncHTTPLookupTest, NoGUI) + +#include "asynchttplookuptest.moc" diff --git a/test/asynchttplookuptest.h b/test/asynchttplookuptest.h index 1c92b42..bcddc58 100644 --- a/test/asynchttplookuptest.h +++ b/test/asynchttplookuptest.h @@ -21,7 +21,7 @@ #define TEST_H #include <QEventLoop> -#include <QtCore/QObject> +#include <QObject> #include <libkcddb/client.h> #include <libkcddb/kcddb.h> diff --git a/test/asynchttpsubmittest.cpp b/test/asynchttpsubmittest.cpp index 4574872..155ad98 100644 --- a/test/asynchttpsubmittest.cpp +++ b/test/asynchttpsubmittest.cpp @@ -17,14 +17,15 @@ Boston, MA 02110-1301, USA. */ -#include <QtCore/QDebug> -#include <QtCore/QCoreApplication> +#include <kdebug.h> +#include <kapplication.h> +#include <kcmdlineargs.h> #include "asynchttpsubmittest.h" #include "libkcddb/submit.h" -AsyncHTTPSubmitTest::AsyncHTTPSubmitTest(QCoreApplication& app) - : app_(app) +AsyncHTTPSubmitTest::AsyncHTTPSubmitTest() + : QObject() { using namespace KCDDB; @@ -67,17 +68,20 @@ AsyncHTTPSubmitTest::AsyncHTTPSubmitTest(QCoreApplication& app) void AsyncHTTPSubmitTest::slotFinished(Result r) { - qDebug() << "AsyncHTTPSubmitTest::slotFinished: Got " << KCDDB::resultToString(r); + kDebug() << "AsyncHTTPSubmitTest::slotFinished: Got " << KCDDB::resultToString(r); - app_.quit(); + kapp->quit(); } int main(int argc, char ** argv) { - QCoreApplication app(argc, argv); - app.setApplicationName("libkcddb_test"); + KCmdLineArgs::init(argc, argv, "libkcddb_test", 0, KLocalizedString(), ""); - new AsyncHTTPSubmitTest(app); + KApplication app(false); + + new AsyncHTTPSubmitTest; return app.exec(); } + +#include "asynchttpsubmittest.moc" diff --git a/test/asynchttpsubmittest.h b/test/asynchttpsubmittest.h index 5f061b9..0f31f10 100644 --- a/test/asynchttpsubmittest.h +++ b/test/asynchttpsubmittest.h @@ -20,19 +20,17 @@ #ifndef TEST_H #define TEST_H -#include <QtCore/QObject> +#include <QObject> #include <libkcddb/client.h> using namespace KCDDB; -class QCoreApplication; - class AsyncHTTPSubmitTest : public QObject { Q_OBJECT public: - AsyncHTTPSubmitTest(QCoreApplication& app); + AsyncHTTPSubmitTest(); public slots: @@ -40,7 +38,6 @@ class AsyncHTTPSubmitTest : public QObject private: - QCoreApplication& app_; KCDDB::Client * client_; }; diff --git a/test/asyncmusicbrainztest.cpp b/test/asyncmusicbrainztest.cpp index a9accba..4aea67e 100644 --- a/test/asyncmusicbrainztest.cpp +++ b/test/asyncmusicbrainztest.cpp @@ -18,11 +18,11 @@ */ +#include <qtest_kde.h> #include "asyncmusicbrainztest.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "config-musicbrainz.h" -#include <QtTest/QTest> void AsyncMusicBrainzTest::testLookup() { @@ -141,11 +141,11 @@ void AsyncMusicBrainzTest::testLookup() AsyncMusicBrainzTest::slotFinished(Result r) { m_result = r; - qDebug() << ": Got " << KCDDB::resultToString(r); + kDebug() << ": Got " << KCDDB::resultToString(r); CDInfoList l = client_->lookupResponse(); - qDebug() << ": Item count: " << l.count(); + kDebug() << ": Item count: " << l.count(); QVERIFY(l.count() > 0); m_info = l.first(); @@ -153,4 +153,6 @@ AsyncMusicBrainzTest::slotFinished(Result r) m_eventLoop.quit(); } -QTEST_GUILESS_MAIN(AsyncMusicBrainzTest) +QTEST_KDEMAIN(AsyncMusicBrainzTest, NoGUI) + +#include "asyncmusicbrainztest.moc" diff --git a/test/asyncmusicbrainztest.h b/test/asyncmusicbrainztest.h index 6187a95..b56fdc2 100644 --- a/test/asyncmusicbrainztest.h +++ b/test/asyncmusicbrainztest.h @@ -21,7 +21,7 @@ #define TEST_H #include <QEventLoop> -#include <QtCore/QObject> +#include <QObject> #include <libkcddb/client.h> #include <libkcddb/kcddb.h> diff --git a/test/asyncsmtpsubmittest.cpp b/test/asyncsmtpsubmittest.cpp index e99d879..5ade7c9 100644 --- a/test/asyncsmtpsubmittest.cpp +++ b/test/asyncsmtpsubmittest.cpp @@ -17,14 +17,15 @@ Boston, MA 02110-1301, USA. */ -#include <QtCore/QDebug> -#include <QtCore/QCoreApplication> +#include <kdebug.h> +#include <kapplication.h> +#include <kcmdlineargs.h> #include "asyncsmtpsubmittest.h" #include "libkcddb/submit.h" -AsyncSMTPSubmitTest::AsyncSMTPSubmitTest(QCoreApplication& app) - : app_(app) +AsyncSMTPSubmitTest::AsyncSMTPSubmitTest() + : QObject() { using namespace KCDDB; @@ -68,17 +69,20 @@ AsyncSMTPSubmitTest::AsyncSMTPSubmitTest(QCoreApplication& app) void AsyncSMTPSubmitTest::slotFinished(Result r) { - qDebug() << "AsyncSMTPSubmitTest::slotFinished: Got " << KCDDB::resultToString(r); + kDebug() << "AsyncSMTPSubmitTest::slotFinished: Got " << KCDDB::resultToString(r); - app_.quit(); + kapp->quit(); } int main(int argc, char ** argv) { - QCoreApplication app(argc, argv); - app.setApplicationName("libkcddb_test"); + KCmdLineArgs::init(argc, argv, "libkcddb_test", 0, KLocalizedString(), ""); - new AsyncSMTPSubmitTest(app); + KApplication app(false); + + new AsyncSMTPSubmitTest; return app.exec(); } + +#include "asyncsmtpsubmittest.moc" diff --git a/test/asyncsmtpsubmittest.h b/test/asyncsmtpsubmittest.h index 06b8801..d053267 100644 --- a/test/asyncsmtpsubmittest.h +++ b/test/asyncsmtpsubmittest.h @@ -20,19 +20,17 @@ #ifndef TEST_H #define TEST_H -#include <QtCore/QObject> +#include <QObject> #include <libkcddb/client.h> using namespace KCDDB; -class QCoreApplication; - class AsyncSMTPSubmitTest : public QObject { Q_OBJECT public: - AsyncSMTPSubmitTest(QCoreApplication& app); + AsyncSMTPSubmitTest(); public slots: @@ -40,7 +38,6 @@ class AsyncSMTPSubmitTest : public QObject private: - QCoreApplication& app_; KCDDB::Client * client_; }; diff --git a/test/cachetest.cpp b/test/cachetest.cpp index 5ba43ca..fd5bcb7 100644 --- a/test/cachetest.cpp +++ b/test/cachetest.cpp @@ -20,10 +20,10 @@ #include "cachetest.h" #include "libkcddb/cache.h" +#include <qtest_kde.h> #include "libkcddb/cdinfo.h" #include "libkcddb/client.h" #include "config-musicbrainz.h" -#include <QtTest/QTest> using namespace KCDDB; @@ -129,4 +129,6 @@ void CacheTest::testMusicbrainz() #endif } -QTEST_GUILESS_MAIN(CacheTest) +QTEST_KDEMAIN(CacheTest, NoGUI) + +#include "cachetest.moc" diff --git a/test/cachetest.h b/test/cachetest.h index 1a67813..6f8820d 100644 --- a/test/cachetest.h +++ b/test/cachetest.h @@ -28,7 +28,7 @@ namespace KCDDB class Client; } -#include <QtCore/QObject> +#include <QObject> class CacheTest : public QObject { diff --git a/test/cdinfotest.cpp b/test/cdinfotest.cpp index b5e510a..69f98a8 100644 --- a/test/cdinfotest.cpp +++ b/test/cdinfotest.cpp @@ -88,4 +88,6 @@ void CDInfoTest::testLongLines() } } -QTEST_GUILESS_MAIN(CDInfoTest) +QTEST_MAIN(CDInfoTest) + +#include "cdinfotest.moc" diff --git a/test/cdinfotest.h b/test/cdinfotest.h index 70db442..12d4749 100644 --- a/test/cdinfotest.h +++ b/test/cdinfotest.h @@ -20,7 +20,7 @@ #ifndef CDINFOTEST_H #define CDINFOTEST_H -#include <QtCore/QObject> +#include <QObject> class CDInfoTest : public QObject { diff --git a/test/musicbrainztest-fulldate.cpp b/test/musicbrainztest-fulldate.cpp index d5f7677..d1c4ad4 100644 --- a/test/musicbrainztest-fulldate.cpp +++ b/test/musicbrainztest-fulldate.cpp @@ -17,12 +17,13 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "musicbrainztest-fulldate.h" #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "config-musicbrainz.h" -#include <QtTest/QTest> + void MusicBrainzTestFullDate::testLookup() { @@ -76,11 +77,11 @@ void MusicBrainzTestFullDate::testLookup() QVERIFY(r == Success); - qDebug() << "Client::lookup gave : " << resultToString(r); + kDebug() << "Client::lookup gave : " << resultToString(r); CDInfoList response = c.lookupResponse(); - qDebug() << "Client::lookup returned : " << response.count() << " entries" + kDebug() << "Client::lookup returned : " << response.count() << " entries" << endl; QVERIFY(response.count() > 0); @@ -151,4 +152,6 @@ void MusicBrainzTestFullDate::testLookup() } } -QTEST_GUILESS_MAIN(MusicBrainzTestFullDate) +QTEST_KDEMAIN(MusicBrainzTestFullDate, NoGUI) + +#include "musicbrainztest-fulldate.moc" diff --git a/test/musicbrainztest-fulldate.h b/test/musicbrainztest-fulldate.h index 9f9cf01..8ab56c1 100644 --- a/test/musicbrainztest-fulldate.h +++ b/test/musicbrainztest-fulldate.h @@ -20,7 +20,7 @@ #ifndef MUSICBRAINZTESTFULLDATE_H #define MUSICBRAINZTESTFULLDATE_H -#include <QtCore/QObject> +#include <QObject> class MusicBrainzTestFullDate : public QObject { diff --git a/test/musicbrainztest-severaldiscs.cpp b/test/musicbrainztest-severaldiscs.cpp index 5964c6a..e476a8b 100644 --- a/test/musicbrainztest-severaldiscs.cpp +++ b/test/musicbrainztest-severaldiscs.cpp @@ -17,12 +17,13 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "musicbrainztest-severaldiscs.h" #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "config-musicbrainz.h" -#include <QtTest/QTest> + void MusicBrainzTestSeveralDiscs::testLookup() { @@ -66,11 +67,11 @@ void MusicBrainzTestSeveralDiscs::testLookup() QVERIFY(r == Success); - qDebug() << "Client::lookup gave : " << resultToString(r); + kDebug() << "Client::lookup gave : " << resultToString(r); CDInfoList response = c.lookupResponse(); - qDebug() << "Client::lookup returned : " << response.count() << " entries" + kDebug() << "Client::lookup returned : " << response.count() << " entries" << endl; QVERIFY(response.count() > 0); @@ -135,4 +136,6 @@ void MusicBrainzTestSeveralDiscs::testLookup() } } -QTEST_GUILESS_MAIN(MusicBrainzTestSeveralDiscs) +QTEST_KDEMAIN(MusicBrainzTestSeveralDiscs, NoGUI) + +#include "musicbrainztest-severaldiscs.moc" diff --git a/test/musicbrainztest-severaldiscs.h b/test/musicbrainztest-severaldiscs.h index f792f5d..87655f6 100644 --- a/test/musicbrainztest-severaldiscs.h +++ b/test/musicbrainztest-severaldiscs.h @@ -20,7 +20,7 @@ #ifndef MUSICBRAINZTESTSEVERALDISCS_H #define MUSICBRAINZTESTSEVERALDISCS_H -#include <QtCore/QObject> +#include <QObject> class MusicBrainzTestSeveralDiscs : public QObject { diff --git a/test/musicbrainztest.cpp b/test/musicbrainztest.cpp index 540de5d..95bef0b 100644 --- a/test/musicbrainztest.cpp +++ b/test/musicbrainztest.cpp @@ -17,12 +17,13 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "musicbrainztest.h" #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "config-musicbrainz.h" -#include <QtTest/QTest> + void MusicBrainzTest::testLookup() { @@ -61,11 +62,11 @@ void MusicBrainzTest::testLookup() QVERIFY(r == Success); - qDebug() << "Client::lookup gave : " << resultToString(r); + kDebug() << "Client::lookup gave : " << resultToString(r); CDInfoList response = c.lookupResponse(); - qDebug() << "Client::lookup returned : " << response.count() << " entries" + kDebug() << "Client::lookup returned : " << response.count() << " entries" << endl; QVERIFY(response.count() > 0); @@ -118,4 +119,6 @@ void MusicBrainzTest::testLookup() } } -QTEST_GUILESS_MAIN(MusicBrainzTest) +QTEST_KDEMAIN(MusicBrainzTest, NoGUI) + +#include "musicbrainztest.moc" diff --git a/test/musicbrainztest.h b/test/musicbrainztest.h index 0a8ec21..df9d2b3 100644 --- a/test/musicbrainztest.h +++ b/test/musicbrainztest.h @@ -20,7 +20,7 @@ #ifndef MUSICBRAINZTEST_H #define MUSICBRAINZTEST_H -#include <QtCore/QObject> +#include <QObject> class MusicBrainzTest : public QObject { diff --git a/test/sitestest.cpp b/test/sitestest.cpp index e5aeeed..dd028fa 100644 --- a/test/sitestest.cpp +++ b/test/sitestest.cpp @@ -17,30 +17,32 @@ Boston, MA 02110-1301, USA. */ -#include <QtCore/QDebug> -#include <QtCore/QCoreApplication> -#include <QtCore/QList> +#include <kdebug.h> +#include <kapplication.h> +#include <kcmdlineargs.h> #include "libkcddb/sites.h" +#include <qlist.h> int main(int argc, char ** argv) { - QCoreApplication app(argc, argv); - app.setApplicationName("libkcddb_test"); + KCmdLineArgs::init(argc, argv, "libkcddb_test", 0, KLocalizedString(), ""); + + KApplication app(true); using namespace KCDDB; Sites s; - qDebug() << "Sites: "; + kDebug() << "Sites: "; QList<Mirror> sites = s.siteList(); for (QList<Mirror>::Iterator it = sites.begin(); it != sites.end(); ++it) if ((*it).transport == Lookup::CDDBP) - qDebug() << (*it).address << " CDDBP " << (*it).port << " " << (*it).description; + kDebug() << (*it).address << " CDDBP " << (*it).port << " " << (*it).description; else - qDebug() << (*it).address << " HTTP " << (*it).port << " " << (*it).description; + kDebug() << (*it).address << " HTTP " << (*it).port << " " << (*it).description; return 0; } diff --git a/test/synccddblookuptest.cpp b/test/synccddblookuptest.cpp index 2a73929..6b6b28b 100644 --- a/test/synccddblookuptest.cpp +++ b/test/synccddblookuptest.cpp @@ -17,11 +17,11 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "synccddblookuptest.h" -#include <QtTest/QTest> void SyncCDDBLookupTest::testLookup() { @@ -91,4 +91,6 @@ void SyncCDDBLookupTest::testLookup() QVERIFY(hasRunTest); } -QTEST_GUILESS_MAIN(SyncCDDBLookupTest) +QTEST_KDEMAIN(SyncCDDBLookupTest, NoGUI) + +#include "synccddblookuptest.moc" diff --git a/test/synccddblookuptest.h b/test/synccddblookuptest.h index 7687464..01a750f 100644 --- a/test/synccddblookuptest.h +++ b/test/synccddblookuptest.h @@ -20,7 +20,7 @@ #ifndef SYNCCDDBLOOKUPTEST_H #define SYNCCDDBLOOKUPTEST_H -#include <QtCore/QObject> +#include <QObject> class SyncCDDBLookupTest : public QObject { diff --git a/test/synchttplookuptest.cpp b/test/synchttplookuptest.cpp index f93120c..c09f324 100644 --- a/test/synchttplookuptest.cpp +++ b/test/synchttplookuptest.cpp @@ -17,11 +17,11 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "synchttplookuptest.h" -#include <QtTest/QTest> void SyncHTTPLookupTest::testLookup() { @@ -91,4 +91,6 @@ void SyncHTTPLookupTest::testLookup() QVERIFY(hasRunTest); } -QTEST_GUILESS_MAIN(SyncHTTPLookupTest) +QTEST_KDEMAIN(SyncHTTPLookupTest, NoGUI) + +#include "synchttplookuptest.moc" diff --git a/test/synchttplookuptest.h b/test/synchttplookuptest.h index 8a12b31..72e3ddc 100644 --- a/test/synchttplookuptest.h +++ b/test/synchttplookuptest.h @@ -20,7 +20,7 @@ #ifndef SYNCHTTPLOOKUPTEST_H #define SYNCHTTPLOOKUPTEST_H -#include <QtCore/QObject> +#include <QObject> class SyncHTTPLookupTest : public QObject { diff --git a/test/synchttpsubmittest.cpp b/test/synchttpsubmittest.cpp index d247b1e..a107b9d 100644 --- a/test/synchttpsubmittest.cpp +++ b/test/synchttpsubmittest.cpp @@ -17,8 +17,9 @@ Boston, MA 02110-1301, USA. */ -#include <QtCore/QDebug> -#include <QtCore/QCoreApplication> +#include <kdebug.h> +#include <kapplication.h> +#include <kcmdlineargs.h> #include "libkcddb/client.h" #include "libkcddb/kcddbconfig.h" @@ -27,8 +28,9 @@ int main(int argc, char ** argv) { - QCoreApplication app(argc, argv); - app.setApplicationName("libkcddb_test"); + KCmdLineArgs::init(argc, argv, "libkcddb_test", 0, KLocalizedString(), ""); + + KApplication app(false /* No styles */); using namespace KCDDB; @@ -65,6 +67,6 @@ main(int argc, char ** argv) Result r = c.submit(cdInfo, list); - qDebug() << "Result: " << resultToString(r); + kDebug() << "Result: " << resultToString(r); } diff --git a/test/syncsmtpsubmittest.cpp b/test/syncsmtpsubmittest.cpp index 2aca5ae..c957c6d 100644 --- a/test/syncsmtpsubmittest.cpp +++ b/test/syncsmtpsubmittest.cpp @@ -17,8 +17,9 @@ Boston, MA 02110-1301, USA. */ -#include <QtCore/QDebug> -#include <QtCore/QCoreApplication> +#include <kdebug.h> +#include <kapplication.h> +#include <kcmdlineargs.h> #include "libkcddb/client.h" #include "libkcddb/kcddbconfig.h" @@ -27,8 +28,9 @@ int main(int argc, char ** argv) { - QCoreApplication app(argc, argv); - app.setApplicationName("libkcddb_test"); + KCmdLineArgs::init(argc, argv, "libkcddb_test", 0, KLocalizedString(), ""); + + KApplication app(false /* No styles */); using namespace KCDDB; @@ -67,6 +69,6 @@ main(int argc, char ** argv) Result r = c.submit(cdInfo, list); - qDebug() << "Result: " << resultToString(r); + kDebug() << "Result: " << resultToString(r); } diff --git a/test/utf8test.cpp b/test/utf8test.cpp index 2f27146..83f7b3a 100644 --- a/test/utf8test.cpp +++ b/test/utf8test.cpp @@ -17,11 +17,11 @@ Boston, MA 02110-1301, USA. */ +#include <qtest_kde.h> #include "libkcddb/client.h" #include "libkcddb/cache.h" #include "libkcddb/lookup.h" #include "utf8test.h" -#include <QtTest/QTest> void Utf8Test::testLookup() { @@ -82,4 +82,6 @@ void Utf8Test::testLookup() QVERIFY(hasRunTest); } -QTEST_GUILESS_MAIN(Utf8Test) +QTEST_KDEMAIN(Utf8Test, NoGUI) + +#include "utf8test.moc" diff --git a/test/utf8test.h b/test/utf8test.h index 2298b0e..631dafd 100644 --- a/test/utf8test.h +++ b/test/utf8test.h @@ -20,7 +20,7 @@ #ifndef UTF8TEST_H #define UTF8TEST_H -#include <QtCore/QObject> +#include <QObject> class Utf8Test : public QObject { _______________________________________________ kde-doc-english mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-doc-english
