From eb7215b4f05d3a3c76b08a14cbbce74ab962544b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Tue, 2 Jul 2013 13:33:17 -0400 Subject: [PATCH] [ #26649 ] Add Qt5 support for library CMakeLists (it doesn't compile on Qt5 yet) --- src/CMakeLists.txt | 107 ++++++++++++++++++++++++-------- src/callmodel.cpp | 2 +- src/dbus/callmanager.h | 2 +- src/dbus/configurationmanager.h | 2 +- src/dbus/instancemanager.h | 2 +- src/dbus/videomanager.h | 4 +- src/historymodel.cpp | 2 +- src/historymodel.h | 3 + 8 files changed, 91 insertions(+), 33 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8876c331..8d59e117 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) ADD_DEFINITIONS("-std=c++0x") # ADD_DEFINITIONS("-std=c++0x") @@ -15,10 +15,14 @@ PROJECT(qtsflphone) SET(LOCAL_CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") SET(CMAKE_MODULE_PATH "${LOCAL_CMAKE_MODULE_PATH}") -FIND_PACKAGE ( KDE4 REQUIRED ) -FIND_PACKAGE ( Qt4 REQUIRED ) +IF(${ENABLE_QT5} MATCHES true) + FIND_PACKAGE(Qt5Core) + FIND_PACKAGE(Qt5DBus) +ELSE() + FIND_PACKAGE ( Qt4 REQUIRED ) +ENDIF(${ENABLE_QT5} MATCHES true) + -INCLUDE ( KDE4Defaults ) set(GENERIC_LIB_VERSION "1.2.3") @@ -60,12 +64,22 @@ SET_SOURCE_FILES_PROPERTIES( ${configurationmanager_xml} PROPERTIES CLASSNAME ConfigurationManagerInterface - INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbus/metatypes.h") + INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbus/metatypes.h") -QT4_ADD_DBUS_INTERFACE( - qtsflphone_LIB_SRCS - ${configurationmanager_xml} - configurationmanager_dbus_interface) +IF(${ENABLE_QT5} MATCHES true) + QT5_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${configurationmanager_xml} + configurationmanager_dbus_interface + ) +ELSE() + QT4_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${configurationmanager_xml} + configurationmanager_dbus_interface + ) + +ENDIF(${ENABLE_QT5} MATCHES true) # call manager interface SET ( callmanager_xml ${dbus_xml_introspecs_path}/callmanager-introspec.xml ) @@ -76,10 +90,20 @@ SET_SOURCE_FILES_PROPERTIES( CLASSNAME CallManagerInterface INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbus/metatypes.h") -QT4_ADD_DBUS_INTERFACE( - qtsflphone_LIB_SRCS - ${callmanager_xml} - callmanager_dbus_interface) +IF(${ENABLE_QT5} MATCHES true) + QT5_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${callmanager_xml} + callmanager_dbus_interface + ) +ELSE() + QT4_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${callmanager_xml} + callmanager_dbus_interface + ) +ENDIF(${ENABLE_QT5} MATCHES true) + # video manager interface SET ( video_xml ${dbus_xml_introspecs_path}/video_controls-introspec.xml ) @@ -90,10 +114,20 @@ SET_SOURCE_FILES_PROPERTIES( CLASSNAME VideoInterface INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbus/metatypes.h") -QT4_ADD_DBUS_INTERFACE( - qtsflphone_LIB_SRCS - ${video_xml} - video_dbus_interface) +IF(${ENABLE_QT5} MATCHES true) + QT5_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${video_xml} + video_dbus_interface + ) +ELSE() + QT4_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${video_xml} + video_dbus_interface + ) +ENDIF(${ENABLE_QT5} MATCHES true) + # instance interface SET ( instance_xml ${dbus_xml_introspecs_path}/instance-introspec.xml ) @@ -103,14 +137,28 @@ SET_SOURCE_FILES_PROPERTIES( PROPERTIES CLASSNAME InstanceInterface INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dbus/metatypes.h") - -QT4_ADD_DBUS_INTERFACE( - qtsflphone_LIB_SRCS - ${instance_xml} - instance_dbus_interface) - -kde4_add_library( qtsflphone SHARED ${qtsflphone_LIB_SRCS} ) + +IF(${ENABLE_QT5} MATCHES true) + QT5_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${instance_xml} + instance_dbus_interface + ) +ELSE() + QT4_ADD_DBUS_INTERFACE( + qtsflphone_LIB_SRCS + ${instance_xml} + instance_dbus_interface + ) +ENDIF(${ENABLE_QT5} MATCHES true) + +add_library( qtsflphone SHARED ${qtsflphone_LIB_SRCS} ) + +IF(${ENABLE_QT5} MATCHES true) + QT5_USE_MODULES(qtsflphone Core DBus) +ENDIF(${ENABLE_QT5} MATCHES true) + target_link_libraries( qtsflphone -lrt -lpthread @@ -119,7 +167,7 @@ target_link_libraries( qtsflphone ) set_target_properties( qtsflphone - PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} + PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_VERSION} ) set( qtsflphone_LIB_HDRS @@ -144,9 +192,16 @@ set( qtsflphone_LIB_HDRS visitors/phonenumberselector.h ) +SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include) +SET(INSTALL_TARGETS_DEFAULT_ARGS ${CMAKE_INSTALL_PREFIX}/lib) + install( FILES ${qtsflphone_LIB_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/qtsflphone COMPONENT Devel ) -install( TARGETS qtsflphone ${INSTALL_TARGETS_DEFAULT_ARGS} ) +install( TARGETS qtsflphone + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS} +) diff --git a/src/callmodel.cpp b/src/callmodel.cpp index 730208ea..0d1b6aa3 100644 --- a/src/callmodel.cpp +++ b/src/callmodel.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#include <callmodel.h> +#include "callmodel.h" //Qt #include <QtCore/QDebug> diff --git a/src/dbus/callmanager.h b/src/dbus/callmanager.h index 619926e9..0f8e3b4c 100644 --- a/src/dbus/callmanager.h +++ b/src/dbus/callmanager.h @@ -20,7 +20,7 @@ #ifndef CALL_MANAGER_INTERFACE_SINGLETON_H #define CALL_MANAGER_INTERFACE_SINGLETON_H -#include "src/lib/callmanager_dbus_interface.h" +#include "callmanager_dbus_interface.h" #include "../typedefs.h" namespace DBus { diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 9f55bef5..ac90cf44 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -19,7 +19,7 @@ #ifndef CONFIGURATION_MANAGER_INTERFACE_SINGLETON_H #define CONFIGURATION_MANAGER_INTERFACE_SINGLETON_H -#include "src/lib/configurationmanager_dbus_interface.h" +#include "configurationmanager_dbus_interface.h" #include "../typedefs.h" namespace DBus { diff --git a/src/dbus/instancemanager.h b/src/dbus/instancemanager.h index 07c0bcfe..d17170c9 100644 --- a/src/dbus/instancemanager.h +++ b/src/dbus/instancemanager.h @@ -20,7 +20,7 @@ #ifndef INSTANCE_INTERFACE_SINGLETON_H #define INSTANCE_INTERFACE_SINGLETON_H -#include "src/lib/instance_dbus_interface.h" +#include "instance_dbus_interface.h" #include "../typedefs.h" namespace DBus { diff --git a/src/dbus/videomanager.h b/src/dbus/videomanager.h index 1d02f164..3beae23b 100644 --- a/src/dbus/videomanager.h +++ b/src/dbus/videomanager.h @@ -18,8 +18,8 @@ #ifndef VIDEO_INTERFACE_SINGLETON_H #define VIDEO_INTERFACE_SINGLETON_H -#include "src/lib/video_dbus_interface.h" -#include "typedefs.h" +#include "video_dbus_interface.h" +#include "../typedefs.h" namespace DBus { diff --git a/src/historymodel.cpp b/src/historymodel.cpp index b5b9fd16..ace7da1a 100644 --- a/src/historymodel.cpp +++ b/src/historymodel.cpp @@ -308,7 +308,7 @@ QVariant HistoryModel::data( const QModelIndex& idx, int role) const case HistoryTreeBackend::Type::CALL: if (role == Call::Role::DropState) return QVariant(modelItem->dropState()); - else if (m_lCategoryCounter.size() >= idx.parent().row() + else if (m_lCategoryCounter.size() >= idx.parent().row() && idx.parent().row() >= 0 && m_lCategoryCounter[idx.parent().row()] && m_lCategoryCounter[idx.parent().row()]->m_lChilds.size() >= idx.row()) return m_lCategoryCounter[idx.parent().row()]->m_lChilds[idx.row()]->roleData((Call::Role)role); diff --git a/src/historymodel.h b/src/historymodel.h index 2e912d4f..45ebb89d 100644 --- a/src/historymodel.h +++ b/src/historymodel.h @@ -118,6 +118,9 @@ private: friend class HistoryModel; public: virtual QObject* getSelf() {return this;} + virtual ~TopLevelItem() { + m_spInstance->m_lCategoryCounter.removeAll(this); + } private: TopLevelItem(int name); CallList m_lChilds; -- GitLab