diff -Nru gammaray-2.1.0/3rdparty/qt/private/qobject_p.h gammaray-2.2.0-0ubuntu0/3rdparty/qt/private/qobject_p.h --- gammaray-2.1.0/3rdparty/qt/private/qobject_p.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/3rdparty/qt/private/qobject_p.h 2014-10-15 20:32:47.000000000 +0000 @@ -56,4 +56,6 @@ }; void Q_CORE_EXPORT qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet &callback_set); +extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; + #endif diff -Nru gammaray-2.1.0/3rdparty/qt/resourcemodel.cpp gammaray-2.2.0-0ubuntu0/3rdparty/qt/resourcemodel.cpp --- gammaray-2.1.0/3rdparty/qt/resourcemodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/3rdparty/qt/resourcemodel.cpp 2014-10-15 20:32:47.000000000 +0000 @@ -437,6 +437,14 @@ return QAbstractItemModel::headerData(section, orientation, role); } +QMap ResourceModel::itemData(const QModelIndex &index) const +{ + QMap map = QAbstractItemModel::itemData(index); + map.insert(ResourceModel::FilePathRole, data(index, ResourceModel::FilePathRole)); + map.insert(ResourceModel::FileNameRole, data(index, ResourceModel::FileNameRole)); + return map; +} + /*! Returns true if the \a parent model item has children; otherwise returns false. diff -Nru gammaray-2.1.0/3rdparty/qt/resourcemodel.h gammaray-2.2.0-0ubuntu0/3rdparty/qt/resourcemodel.h --- gammaray-2.1.0/3rdparty/qt/resourcemodel.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/3rdparty/qt/resourcemodel.h 2014-10-15 20:32:47.000000000 +0000 @@ -80,6 +80,7 @@ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QMap itemData(const QModelIndex &index) const; bool hasChildren(const QModelIndex &index = QModelIndex()) const; Qt::ItemFlags flags(const QModelIndex &index) const; diff -Nru gammaray-2.1.0/CHANGES gammaray-2.2.0-0ubuntu0/CHANGES --- gammaray-2.1.0/CHANGES 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/CHANGES 2014-10-15 20:32:47.000000000 +0000 @@ -1,6 +1,17 @@ Release Highlights ================== +Version 2.1.1: +------------- + * Fix invoking non-slot methods with arguments. + * Fix QtQuick2 preview not showing any content with Qt 5.2 or older. + * Fix crash when encountering tooltips in Qt5 targets. + * Fix deadlock in object list model. + * Fix QGraphicsView scene selection in in-process mode. + * Fix debug message handler for Qt5. + * A missing relocatable startup hook is no longer fatal with Qt 5.4. + * Fix Qt 5.4 compatibility of the QtQuick2 preview. + Version 2.1.0: ------------- * Aggregated property view combining static, dynamic and non-QObject property views. diff -Nru gammaray-2.1.0/cmake/GammaRayProbeABI.cmake gammaray-2.2.0-0ubuntu0/cmake/GammaRayProbeABI.cmake --- gammaray-2.1.0/cmake/GammaRayProbeABI.cmake 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/cmake/GammaRayProbeABI.cmake 2014-10-15 20:32:47.000000000 +0000 @@ -16,13 +16,11 @@ set(GAMMARAY_PROBE_ABI "qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}") endif() - # on Windows, the compiler also matters if(WIN32) set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_CXX_COMPILER_ID}") endif() - # debug vs. release (MSVC only) if(MSVC) if(CMAKE_BUILD_TYPE MATCHES "^[Rr]el") @@ -32,7 +30,6 @@ endif() endif() - # processor architecture # this is a bit messy since CMAKE_SYSTEM_PROCESSOR seems to contain the host CPU rather than the target architecture sometimes # and is empty on cross-builds by default @@ -65,5 +62,4 @@ endif() endif() - message(STATUS "Building probe for ABI: ${GAMMARAY_PROBE_ABI}") diff -Nru gammaray-2.1.0/cmake/Toolchain-iMX6.cmake gammaray-2.2.0-0ubuntu0/cmake/Toolchain-iMX6.cmake --- gammaray-2.1.0/cmake/Toolchain-iMX6.cmake 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/cmake/Toolchain-iMX6.cmake 2014-10-15 20:32:47.000000000 +0000 @@ -0,0 +1,25 @@ +# Basic cmake toolchain file for Freescale iMX6 +# Assumptions: toolchain is in path, $SYSROOT points to the sysroot +# + +# Copyright (c) 2013-2014 Klarälvdalens Datakonsult AB, a KDAB Group company + +# Author: Volker Krause +# +# Redistribution and use is allowed according to the terms of the BSD license. + +set(CMAKE_SYSTEM_NAME "Linux") +set(CMAKE_SYSTEM_PROCESSOR "armv7-a") +set(CMAKE_C_COMPILER "arm-linux-gcc") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=$ENV{SYSROOT} -march=armv7-a -mfpu=neon") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=$ENV{SYSROOT} -march=armv7-a -mfpu=neon") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=$ENV{SYSROOT}") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=$ENV{SYSROOT}") +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=$ENV{SYSROOT}") + +set(CMAKE_FIND_ROOT_PATH "$ENV{SYSROOT}") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + diff -Nru gammaray-2.1.0/CMakeLists.txt gammaray-2.2.0-0ubuntu0/CMakeLists.txt --- gammaray-2.1.0/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/CMakeLists.txt 2014-10-15 20:32:47.000000000 +0000 @@ -24,13 +24,8 @@ project(GammaRay) -if(WIN32) - # needed for automoc and QtMain to work correctly - cmake_minimum_required(VERSION 2.8.11) - cmake_policy(SET CMP0020 NEW) -else() - cmake_minimum_required(VERSION 2.8.9) -endif() +cmake_minimum_required(VERSION 2.8.11) +cmake_policy(SET CMP0020 NEW) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH}) set(CMAKE_AUTOMOC ON) @@ -48,16 +43,35 @@ include(GammaRayMacrosInternal) include(FeatureSummary) +# Exit for blacklisted compilers (those that don't support C++11 very well) +# MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) +# Clang 3.0 +set(BAD_CXX_MESSAGE "") +if(MSVC) + if(MSVC_VERSION LESS 1500) + set(BAD_CXX_MESSAGE "MSVC 2008 or higher") + endif() +endif() +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1.0) + set(BAD_CXX_MESSAGE "Clang v3.1.0 or higher") + endif() +endif() +if(BAD_CXX_MESSAGE) + message(FATAL_ERROR "\nSorry, ${BAD_CXX_MESSAGE} is required to build this software. Please retry using a modern compiler that supports C++11 lambdas.") +endif() + +# Enable the test harness enable_testing() # Version setup set(GAMMARAY_VERSION_MAJOR "2") set(GAMMARAY_VERSION_MINOR "1") -set(GAMMARAY_VERSION_PATCH "0") +set(GAMMARAY_VERSION_PATCH "50") set(GAMMARAY_VERSION "${GAMMARAY_VERSION_MAJOR}.${GAMMARAY_VERSION_MINOR}.${GAMMARAY_VERSION_PATCH}") set(GAMMARAY_VERSION_STRING "${GAMMARAY_VERSION}") -set(GAMMARAY_SOVERSION "2.1.0") -set(GAMMARAY_PLUGIN_VERSION "2.1") +set(GAMMARAY_SOVERSION "2.2.0") +set(GAMMARAY_PLUGIN_VERSION "2.2") if(EXISTS "${CMAKE_SOURCE_DIR}/.git") find_package(Git) @@ -85,7 +99,7 @@ # option( GAMMARAY_ENFORCE_QT4_BUILD - "Enable if you want to enfore a build with Qt4" + "Enable if you want to enforce a build with Qt4" OFF ) @@ -107,21 +121,28 @@ # Compiler & linker settings # if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - check_cxx_compiler_flag(-Wunused-but-set-variable HAVE_GCC_UNUSED_BUT_SET) - check_cxx_compiler_flag(-Wlogical-op HAVE_GCC_LOGICAL_OP) - check_cxx_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GCC_POINTER_MEMACCESS) - check_cxx_compiler_flag(-Wreorder HAVE_GCC_REORDER) + check_cxx_compiler_flag(-Wunused-but-set-variable HAVE_GXX_UNUSED_BUT_SET) + check_cxx_compiler_flag(-Wlogical-op HAVE_GXX_LOGICAL_OP) + check_cxx_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GXX_POINTER_MEMACCESS) + check_cxx_compiler_flag(-Wreorder HAVE_GXX_REORDER) + check_cxx_compiler_flag(-std=c++0x HAVE_GXX_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wextra -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wcast-qual -Wmissing-noreturn -Werror=return-type") - if(HAVE_GCC_UNUSED_BUT_SET) + if(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # required in C++11 mode + endif() + if(HAVE_GXX_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + endif() + if(HAVE_GXX_UNUSED_BUT_SET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable") endif() - if(HAVE_GCC_LOGICAL_OP) + if(HAVE_GXX_LOGICAL_OP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op") endif() - if(HAVE_GCC_POINTER_MEMACCESS) + if(HAVE_GXX_POINTER_MEMACCESS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsizeof-pointer-memaccess") endif() - if(HAVE_GCC_REORDER) + if(HAVE_GXX_REORDER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreorder") endif() if(MINGW) diff -Nru gammaray-2.1.0/common/metatypedeclarations.h gammaray-2.2.0-0ubuntu0/common/metatypedeclarations.h --- gammaray-2.1.0/common/metatypedeclarations.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/common/metatypedeclarations.h 2014-10-15 20:32:47.000000000 +0000 @@ -36,8 +36,10 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include #include #include #endif @@ -53,8 +55,10 @@ Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(Qt::WindowType) Q_DECLARE_METATYPE(Qt::WindowState) +Q_DECLARE_METATYPE(const QMatrix4x4*) #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +Q_DECLARE_METATYPE(QOpenGLShader::ShaderType) Q_DECLARE_METATYPE(QSurfaceFormat) Q_DECLARE_METATYPE(QSurface::SurfaceClass) Q_DECLARE_METATYPE(QSurface::SurfaceType) diff -Nru gammaray-2.1.0/common/modelroles.h gammaray-2.2.0-0ubuntu0/common/modelroles.h --- gammaray-2.1.0/common/modelroles.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/common/modelroles.h 2014-10-15 20:32:47.000000000 +0000 @@ -54,7 +54,8 @@ namespace ObjectMethodModelRole { enum Role { MetaMethod = UserRole + 1, - MetaMethodType + MetaMethodType, + MethodSignature }; } diff -Nru gammaray-2.1.0/common/protocol.cpp gammaray-2.2.0-0ubuntu0/common/protocol.cpp --- gammaray-2.1.0/common/protocol.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/common/protocol.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -52,7 +52,7 @@ qint32 version() { - return 8; + return 10; } qint32 broadcastFormatVersion() diff -Nru gammaray-2.1.0/common/resourcebrowserinterface.h gammaray-2.2.0-0ubuntu0/common/resourcebrowserinterface.h --- gammaray-2.1.0/common/resourcebrowserinterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/common/resourcebrowserinterface.h 2014-10-15 20:32:48.000000000 +0000 @@ -37,10 +37,16 @@ explicit ResourceBrowserInterface(QObject *parent = 0); virtual ~ResourceBrowserInterface(); + public slots: + virtual void downloadResource(const QString &sourceFilePath, const QString &targetFilePath) = 0; + signals: void resourceDeselected(); void resourceSelected(const QPixmap &pixmap); void resourceSelected(const QByteArray &contents); + + void resourceDownloaded(const QString &targetFilePath, const QPixmap &pixmap); + void resourceDownloaded(const QString &targetFilePath, const QByteArray &contents); }; } diff -Nru gammaray-2.1.0/common/tools/objectinspector/methodsextensioninterface.h gammaray-2.2.0-0ubuntu0/common/tools/objectinspector/methodsextensioninterface.h --- gammaray-2.1.0/common/tools/objectinspector/methodsextensioninterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/common/tools/objectinspector/methodsextensioninterface.h 2014-10-15 20:32:48.000000000 +0000 @@ -41,6 +41,7 @@ public slots: virtual void activateMethod() = 0; virtual void invokeMethod(Qt::ConnectionType type) = 0; + virtual void connectToSignal() = 0; private: QString m_name; diff -Nru gammaray-2.1.0/config-gammaray.h.cmake gammaray-2.2.0-0ubuntu0/config-gammaray.h.cmake --- gammaray-2.1.0/config-gammaray.h.cmake 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/config-gammaray.h.cmake 2014-10-15 20:32:48.000000000 +0000 @@ -11,7 +11,6 @@ #define GAMMARAY_INVERSE_PROBE_DIR "${GAMMARAY_INVERSE_PROBE_DIR}" #define GAMMARAY_INVERSE_LIBEXEC_DIR "${GAMMARAY_INVERSE_LIBEXEC_DIR}" - // build options #cmakedefine BUILD_TIMER_PLUGIN diff -Nru gammaray-2.1.0/core/metaobjectrepository.cpp gammaray-2.2.0-0ubuntu0/core/metaobjectrepository.cpp --- gammaray-2.1.0/core/metaobjectrepository.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/metaobjectrepository.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -34,6 +34,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include @@ -82,12 +83,27 @@ initOpenGLTypes(); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_DECLARE_METATYPE(QThread*) +#endif +Q_DECLARE_METATYPE(QThread::Priority) + void MetaObjectRepository::initQObjectTypes() { MetaObject *mo = 0; MO_ADD_METAOBJECT0(QObject); MO_ADD_PROPERTY_RO(QObject, QObject*, parent); MO_ADD_PROPERTY_RO(QObject, bool, signalsBlocked); // TODO setter has non-void return type + MO_ADD_PROPERTY_RO(QObject, QThread*, thread); + + MO_ADD_METAOBJECT1(QThread, QObject) + MO_ADD_PROPERTY_RO(QThread, bool, isFinished); +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + MO_ADD_PROPERTY_RO(QThread, bool, isInterruptionRequested); +#endif + MO_ADD_PROPERTY_RO(QThread, bool, isRunning); + MO_ADD_PROPERTY (QThread, QThread::Priority, priority, setPriority); + MO_ADD_PROPERTY (QThread, uint, stackSize, setStackSize); MO_ADD_METAOBJECT0(QPaintDevice); MO_ADD_PROPERTY_RO(QPaintDevice, int, colorCount); @@ -248,10 +264,6 @@ #endif } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -Q_DECLARE_METATYPE(QOpenGLShader::ShaderType) -#endif - void MetaObjectRepository::initOpenGLTypes() { #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) @@ -267,7 +279,8 @@ MO_ADD_PROPERTY_RO(QOpenGLShaderProgram, bool, isLinked); MO_ADD_PROPERTY_RO(QOpenGLShaderProgram, QString, log); #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) - MO_ADD_PROPERTY_RO(QOpenGLShaderProgram, int, maxGeometryOutputVertices); +// FIXME calling this asserts in debug builds of some newer Qt versions +// MO_ADD_PROPERTY_RO(QOpenGLShaderProgram, int, maxGeometryOutputVertices); MO_ADD_PROPERTY (QOpenGLShaderProgram, int, patchVertexCount, setPatchVertexCount); #endif MO_ADD_PROPERTY_RO(QOpenGLShaderProgram, uint, programId); diff -Nru gammaray-2.1.0/core/metaproperty.h gammaray-2.2.0-0ubuntu0/core/metaproperty.h --- gammaray-2.1.0/core/metaproperty.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/metaproperty.h 2014-10-15 20:32:48.000000000 +0000 @@ -65,14 +65,29 @@ MetaObject *m_class; }; +///@cond internal +namespace detail { + +template +struct strip_const_ref { typedef T type; }; + +template +struct strip_const_ref { typedef T type; }; + +} +///@endcond + /** @brief Template-ed implementation of MetaProperty. */ -template +template class MetaPropertyImpl : public MetaProperty { + private: + typedef typename detail::strip_const_ref::type ValueType; + public: inline MetaPropertyImpl( const QString &name, - ValueType (Class::*getter)() const, void (Class::*setter)(SetterArgType) = 0) + GetterReturnType (Class::*getter)() const, void (Class::*setter)(SetterArgType) = 0) : m_name(name), m_getter(getter), m_setter(setter) { } @@ -121,7 +136,7 @@ private: QString m_name; - ValueType (Class::*m_getter)() const; + GetterReturnType (Class::*m_getter)() const; void (Class::*m_setter)(SetterArgType); }; diff -Nru gammaray-2.1.0/core/metapropertymodel.cpp gammaray-2.2.0-0ubuntu0/core/metapropertymodel.cpp --- gammaray-2.1.0/core/metapropertymodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/metapropertymodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -143,7 +143,7 @@ case Qt::DecorationRole: return VariantHandler::decoration(value); case Qt::EditRole: - return value; + return property->isReadOnly() ? QVariant() : value; } } diff -Nru gammaray-2.1.0/core/metapropertymodel.h gammaray-2.2.0-0ubuntu0/core/metapropertymodel.h --- gammaray-2.1.0/core/metapropertymodel.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/metapropertymodel.h 2014-10-15 20:32:48.000000000 +0000 @@ -24,6 +24,8 @@ #ifndef GAMMARAY_METAPROPERTYMODEL_H #define GAMMARAY_METAPROPERTYMODEL_H +#include "gammaray_core_export.h" + #include namespace GammaRay { @@ -34,7 +36,7 @@ * @todo needs better name, but ObjectPropertyModel is already in use... * @todo maybe it's a good to merge those to anyway? */ -class MetaPropertyModel : public QAbstractTableModel +class GAMMARAY_CORE_EXPORT MetaPropertyModel : public QAbstractTableModel { Q_OBJECT public: diff -Nru gammaray-2.1.0/core/objectmethodmodel.cpp gammaray-2.2.0-0ubuntu0/core/objectmethodmodel.cpp --- gammaray-2.1.0/core/objectmethodmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/objectmethodmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -22,6 +22,7 @@ */ #include "objectmethodmodel.h" +#include "util.h" using namespace GammaRay; @@ -46,11 +47,7 @@ { if (role == Qt::DisplayRole) { if (index.column() == 0) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - return method.signature(); -#else - return method.methodSignature(); -#endif + return Util::prettyMethodSignature(method); } if (index.column() == 1) { switch (method.methodType()) { @@ -90,6 +87,12 @@ return QVariant::fromValue(method); } else if (role == ObjectMethodModelRole::MetaMethodType) { return QVariant::fromValue(method.methodType()); + } else if (role == ObjectMethodModelRole::MethodSignature) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return method.signature(); +#else + return method.methodSignature(); +#endif } return QVariant(); } @@ -115,5 +118,6 @@ { QMap m = super::itemData(index); m.insert(ObjectMethodModelRole::MetaMethodType, data(index, ObjectMethodModelRole::MetaMethodType)); + m.insert(ObjectMethodModelRole::MethodSignature, data(index, ObjectMethodModelRole::MethodSignature)); return m; } diff -Nru gammaray-2.1.0/core/objectmodelbase.h gammaray-2.2.0-0ubuntu0/core/objectmodelbase.h --- gammaray-2.1.0/core/objectmodelbase.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/objectmodelbase.h 2014-10-15 20:32:48.000000000 +0000 @@ -81,23 +81,14 @@ { if (role == Qt::DisplayRole) { if (index.column() == 0) { - return - object->objectName().isEmpty() ? - Util::addressToString(object) : - object->objectName(); + return Util::shortDisplayString(object); } else if (index.column() == 1) { return object->metaObject()->className(); } } else if (role == ObjectModel::ObjectRole) { return QVariant::fromValue(object); } else if (role == Qt::ToolTipRole) { - return - QObject::tr("

Object name: %1\nType: %2\nParent: %3 (Address: %4)\nNumber of children: %5

"). - arg(object->objectName().isEmpty() ? "<Not set>" : object->objectName()). - arg(object->metaObject()->className()). - arg(object->parent() ? object->parent()->metaObject()->className() : ""). - arg(Util::addressToString(object->parent())). - arg(object->children().size()); + return Util::tooltipForObject(object); } else if (role == Qt::DecorationRole && index.column() == 0) { return Util::iconForObject(object); } diff -Nru gammaray-2.1.0/core/objectstaticpropertymodel.cpp gammaray-2.2.0-0ubuntu0/core/objectstaticpropertymodel.cpp --- gammaray-2.1.0/core/objectstaticpropertymodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/objectstaticpropertymodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -80,7 +80,7 @@ return VariantHandler::decoration(value); } } else if (role == Qt::EditRole) { - if (index.column() == 1) { + if (index.column() == 1 && prop.isWritable()) { return value; } } else if (role == Qt::ToolTipRole) { @@ -187,11 +187,7 @@ s << tr("Designable: %1").arg(translateBool(prop.isDesignable(m_obj.data()))); s << tr("Final: %1").arg(translateBool(prop.isFinal())); if (prop.hasNotifySignal()) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - s << tr("Notification: %1").arg(prop.notifySignal().signature()); -#else - s << tr("Notification: %1").arg(QString::fromUtf8(prop.notifySignal().methodSignature())); -#endif + s << tr("Notification: %1").arg(Util::prettyMethodSignature(prop.notifySignal())); } else { s << tr("Notification: no"); } diff -Nru gammaray-2.1.0/core/probe.cpp gammaray-2.2.0-0ubuntu0/core/probe.cpp --- gammaray-2.1.0/core/probe.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/probe.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -33,6 +33,7 @@ #include "probesettings.h" #include "probecontroller.h" #include "toolpluginmodel.h" +#include "util.h" #include "tools/modelinspector/modeltest.h" @@ -56,6 +57,7 @@ #include #include +#include #include #include @@ -93,7 +95,49 @@ #endif // QT_VERSION -static QItemSelectionModel* selectionModelFactory(QAbstractItemModel* model) +static void signal_begin_callback(QObject *caller, int method_index, void **argv) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + method_index = Util::signalIndexToMethodIndex(caller->metaObject(), method_index); +#endif + Probe::executeSignalCallback([=](const QSignalSpyCallbackSet &qt_signal_spy_callback_set) { + if (qt_signal_spy_callback_set.signal_begin_callback) { + qt_signal_spy_callback_set.signal_begin_callback(caller, method_index, argv); + } + }); +} + +static void signal_end_callback(QObject *caller, int method_index) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + method_index = Util::signalIndexToMethodIndex(caller->metaObject(), method_index); +#endif + Probe::executeSignalCallback([=](const QSignalSpyCallbackSet &qt_signal_spy_callback_set) { + if (qt_signal_spy_callback_set.signal_end_callback) { + qt_signal_spy_callback_set.signal_end_callback(caller, method_index); + } + }); +} + +static void slot_begin_callback(QObject *caller, int method_index, void **argv) +{ + Probe::executeSignalCallback([=](const QSignalSpyCallbackSet &qt_signal_spy_callback_set) { + if (qt_signal_spy_callback_set.slot_begin_callback) { + qt_signal_spy_callback_set.slot_begin_callback(caller, method_index, argv); + } + }); +} + +static void slot_end_callback(QObject *caller, int method_index) +{ + Probe::executeSignalCallback([=](const QSignalSpyCallbackSet &qt_signal_spy_callback_set) { + if (qt_signal_spy_callback_set.slot_end_callback) { + qt_signal_spy_callback_set.slot_end_callback(caller, method_index); + } + }); +} + +static QItemSelectionModel *selectionModelFactory(QAbstractItemModel *model) { return new SelectionModelServer(model->objectName() + ".selection", model, Probe::instance()); } @@ -148,7 +192,6 @@ }; Q_GLOBAL_STATIC(ObjectLock, s_lock) - Probe::Probe(QObject *parent): QObject(parent), m_objectListModel(new ObjectListModel(this)), @@ -182,7 +225,8 @@ ToolPluginModel *toolPluginModel = new ToolPluginModel(m_toolModel->plugins(), this); registerModel(QLatin1String("com.kdab.GammaRay.ToolPluginModel"), toolPluginModel); - ToolPluginErrorModel *toolPluginErrorModel = new ToolPluginErrorModel(m_toolModel->pluginErrors(), this); + ToolPluginErrorModel *toolPluginErrorModel = + new ToolPluginErrorModel(m_toolModel->pluginErrors(), this); registerModel(QLatin1String("com.kdab.GammaRay.ToolPluginErrorModel"), toolPluginErrorModel); if (qgetenv("GAMMARAY_MODELTEST") == "1") { @@ -201,12 +245,28 @@ m_queueTimer->setInterval(0); connect(m_queueTimer, SIGNAL(timeout()), this, SLOT(queuedObjectsFullyConstructed())); + + QSignalSpyCallbackSet callbacks; + callbacks.signal_begin_callback = signal_begin_callback; + callbacks.signal_end_callback = signal_end_callback; + callbacks.slot_begin_callback = slot_begin_callback; + callbacks.slot_end_callback = slot_end_callback; + m_previousSignalSpyCallbackSet = qt_signal_spy_callback_set; + if (qt_signal_spy_callback_set.signal_begin_callback || + qt_signal_spy_callback_set.signal_end_callback || + qt_signal_spy_callback_set.slot_begin_callback || + qt_signal_spy_callback_set.slot_end_callback) { + m_signalSpyCallbacks.push_back(qt_signal_spy_callback_set); // daisy-chain existing callbacks + } + qt_register_signal_spy_callbacks(callbacks); } Probe::~Probe() { IF_DEBUG(cerr << "detaching GammaRay probe" << endl;) + qt_register_signal_spy_callbacks(m_previousSignalSpyCallbackSet); + #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) QInternal::unregisterCallback(QInternal::ConnectCallback, &GammaRay::probeConnectCallback); QInternal::unregisterCallback(QInternal::DisconnectCallback, &GammaRay::probeDisconnectCallback); @@ -217,7 +277,7 @@ s_instance = QAtomicPointer(0); } -QThread* Probe::filteredThread() +QThread *Probe::filteredThread() { return s_listener()->filterThread; } @@ -227,7 +287,7 @@ m_window = window; } -QObject* Probe::window() const +QObject *Probe::window() const { return m_window; } @@ -328,8 +388,9 @@ } Server::instance()->setLabel(appName); - if (ProbeSettings::value("InProcessUi", false).toBool()) + if (ProbeSettings::value("InProcessUi", false).toBool()) { showInProcessUi(); + } } void Probe::showInProcessUi() @@ -343,19 +404,24 @@ s_listener()->filterThread = QThread::currentThread(); QString path = Paths::currentProbePath(); - if (!path.isEmpty()) + if (!path.isEmpty()) { path += QDir::separator(); + } path += "gammaray_inprocessui"; QLibrary lib; lib.setFileName(path); if (!lib.load()) { - std::cerr << "Failed to load in-process UI module: " << qPrintable(lib.errorString()) << std::endl; + std::cerr << "Failed to load in-process UI module: " + << qPrintable(lib.errorString()) + << std::endl; } else { - void(*factory)() = reinterpret_cast(lib.resolve("gammaray_create_inprocess_mainwindow")); - if (!factory) + void(*factory)() = + reinterpret_cast(lib.resolve("gammaray_create_inprocess_mainwindow")); + if (!factory) { std::cerr << Q_FUNC_INFO << ' ' << qPrintable(lib.errorString()) << endl; - else + } else { factory(); + } } s_listener()->filterThread = 0; @@ -373,7 +439,7 @@ Util::descendantOf(window(), obj); } -void Probe::registerModel(const QString& objectName, QAbstractItemModel* model) +void Probe::registerModel(const QString &objectName, QAbstractItemModel *model) { RemoteModelServer *ms = new RemoteModelServer(objectName, model); ms->setModel(model); @@ -577,8 +643,9 @@ << hex << obj << " have statics: " << s_listener() << endl;) - if (!s_listener()) + if (!s_listener()) { return; + } QVector &addedBefore = s_listener()->addedBeforeProbeInstance; for (QVector::iterator it = addedBefore.begin(); it != addedBefore.end();) { @@ -693,7 +760,8 @@ // we have no preloading hooks, so recover all objects we see if (!hasReliableObjectTracking() && event->type() != QEvent::ChildAdded && event->type() != QEvent::ChildRemoved && // already handled above - event->type() != QEvent::Destroy && event->type() != QEvent::WinIdChange && // unsafe since emitted from dtors + event->type() != QEvent::Destroy && + event->type() != QEvent::WinIdChange && // unsafe since emitted from dtors !filterObject(receiver)) { QWriteLocker lock(s_lock()); const bool tracked = m_validObjects.contains(receiver); @@ -704,8 +772,9 @@ // filters provided by plugins if (!filterObject(receiver)) { - foreach (QObject *filter, m_globalEventFilters) + foreach (QObject *filter, m_globalEventFilters) { filter->eventFilter(receiver, event); + } } return QObject::eventFilter(receiver, event); @@ -716,15 +785,16 @@ discoverObject(QCoreApplication::instance()); } -void Probe::discoverObject(QObject* obj) +void Probe::discoverObject(QObject *obj) { if (!obj) { return; } QWriteLocker lock(s_lock()); - if (m_validObjects.contains(obj)) + if (m_validObjects.contains(obj)) { return; + } objectAdded(obj); foreach (QObject *child, obj->children()) { @@ -732,7 +802,7 @@ } } -void Probe::installGlobalEventFilter(QObject* filter) +void Probe::installGlobalEventFilter(QObject *filter) { Q_ASSERT(!m_globalEventFilters.contains(filter)); m_globalEventFilters.push_back(filter); @@ -743,20 +813,39 @@ return !s_listener()->trackDestroyed; } -void Probe::selectObject(QObject* object, const QPoint& pos) +void Probe::selectObject(QObject *object, const QPoint &pos) { emit objectSelected(object, pos); - m_toolSelectionModel->select( m_toolModel->toolForObject(object), QItemSelectionModel::Select | QItemSelectionModel::Clear | - QItemSelectionModel::Rows | QItemSelectionModel::Current); + m_toolSelectionModel->select(m_toolModel->toolForObject(object), + QItemSelectionModel::Select | + QItemSelectionModel::Clear | + QItemSelectionModel::Rows | + QItemSelectionModel::Current); } -void Probe::selectObject(void* object, const QString& typeName) +void Probe::selectObject(void *object, const QString &typeName) { emit nonQObjectSelected(object, typeName); - m_toolSelectionModel->select( m_toolModel->toolForObject(object, typeName), QItemSelectionModel::Select | QItemSelectionModel::Clear | - QItemSelectionModel::Rows | QItemSelectionModel::Current); + m_toolSelectionModel->select(m_toolModel->toolForObject(object, typeName), + QItemSelectionModel::Select | + QItemSelectionModel::Clear | + QItemSelectionModel::Rows | + QItemSelectionModel::Current); +} + +void Probe::registerSignalSpyCallbackSet(const QSignalSpyCallbackSet &callbacks) +{ + m_signalSpyCallbacks.push_back(callbacks); +} + +template +void Probe::executeSignalCallback(const Func &func) +{ + std::for_each(instance()->m_signalSpyCallbacks.constBegin(), + instance()->m_signalSpyCallbacks.constEnd(), + func); } //BEGIN: SignalSlotsLocationStore diff -Nru gammaray-2.1.0/core/probe.h gammaray-2.2.0-0ubuntu0/core/probe.h --- gammaray-2.1.0/core/probe.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/probe.h 2014-10-15 20:32:48.000000000 +0000 @@ -33,6 +33,8 @@ #include #include +#include //krazy:exclude=camelcase + class QItemSelectionModel; class QThread; class QPoint; @@ -84,6 +86,7 @@ /*override*/ void discoverObject(QObject* object); /*override*/ void selectObject(QObject* object, const QPoint& pos = QPoint()); /*override*/ void selectObject(void* object, const QString& typeName); + /*override*/ void registerSignalSpyCallbackSet(const QSignalSpyCallbackSet& callbacks); QObject *window() const; void setWindow(QObject *window); @@ -110,6 +113,7 @@ /// internal static void startupHookReceived(); + template static void executeSignalCallback(const Func &func); signals: /** @@ -186,6 +190,8 @@ QQueue m_queuedObjects; QTimer *m_queueTimer; QVector m_globalEventFilters; + QVector m_signalSpyCallbacks; + QSignalSpyCallbackSet m_previousSignalSpyCallbackSet; }; class GAMMARAY_CORE_EXPORT SignalSlotsLocationStore diff -Nru gammaray-2.1.0/core/probeinterface.h gammaray-2.2.0-0ubuntu0/core/probeinterface.h --- gammaray-2.1.0/core/probeinterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/probeinterface.h 2014-10-15 20:32:48.000000000 +0000 @@ -38,6 +38,7 @@ class QObject; class QAbstractItemModel; class QString; +struct QSignalSpyCallbackSet; namespace GammaRay { @@ -142,6 +143,15 @@ * @since 2.1 */ virtual void selectObject(void* object, const QString& typeName) = 0; + + /** + * Register a signal spy callback set. + * Signal indexes provided as arguments are mapped to method indexes, ie. argument semantics + * are the same with Qt4 and Qt5. + * + * @since 2.2 + */ + virtual void registerSignalSpyCallbackSet(const QSignalSpyCallbackSet &callbacks) = 0; }; } diff -Nru gammaray-2.1.0/core/remote/remotemodelserver.cpp gammaray-2.2.0-0ubuntu0/core/remote/remotemodelserver.cpp --- gammaray-2.1.0/core/remote/remotemodelserver.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/remote/remotemodelserver.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -176,7 +177,9 @@ { QMap itemData(data); for (QMap::iterator it = itemData.begin(); it != itemData.end();) { - if (it.value().userType() == qMetaTypeId()) { + if (!it.value().isValid()) { + it = itemData.erase(it); + } else if (it.value().userType() == qMetaTypeId()) { // see also: https://bugreports.qt-project.org/browse/QTBUG-33321 const QIcon icon = it.value().value(); ///TODO: what size to use? icon.availableSizes is empty... @@ -186,6 +189,7 @@ } else if (canSerialize(it.value())) { ++it; } else { + qWarning() << "Cannot serialize QVariant of type" << it.value().typeName(); it = itemData.erase(it); } } diff -Nru gammaray-2.1.0/core/tools/messagehandler/backtrace_unix.cpp gammaray-2.2.0-0ubuntu0/core/tools/messagehandler/backtrace_unix.cpp --- gammaray-2.1.0/core/tools/messagehandler/backtrace_unix.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/messagehandler/backtrace_unix.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -53,7 +53,7 @@ #endif //NOTE: we don't have check_function_exists, so lets just hardcode some OS'es -#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && !defined(__UCLIBC__) #define HAVE_BACKTRACE (1) #endif ///TODO: what else is supported? what about mac? diff -Nru gammaray-2.1.0/core/tools/messagehandler/messagehandler.cpp gammaray-2.2.0-0ubuntu0/core/tools/messagehandler/messagehandler.cpp --- gammaray-2.1.0/core/tools/messagehandler/messagehandler.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/messagehandler/messagehandler.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -40,10 +40,10 @@ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) typedef QtMsgHandler MessageHandlerCallback; -static MessageHandlerCallback (*installMessageHandler)(MessageHandlerCallback) = qInstallMsgHandler; +static MessageHandlerCallback (*const installMessageHandler)(MessageHandlerCallback) = qInstallMsgHandler; #else typedef QtMessageHandler MessageHandlerCallback; -static MessageHandlerCallback (*installMessageHandler)(MessageHandlerCallback) = qInstallMessageHandler; +static MessageHandlerCallback (*const installMessageHandler)(MessageHandlerCallback) = qInstallMessageHandler; #endif static MessageModel *s_model = 0; diff -Nru gammaray-2.1.0/core/tools/objectinspector/abstractconnectionsmodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/abstractconnectionsmodel.cpp --- gammaray-2.1.0/core/tools/objectinspector/abstractconnectionsmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/abstractconnectionsmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -30,11 +30,6 @@ #include #include -#ifdef HAVE_PRIVATE_QT_HEADERS -#include -#include -#endif - using namespace GammaRay; AbstractConnectionsModel::AbstractConnectionsModel(QObject *parent): QAbstractTableModel(parent) @@ -122,11 +117,7 @@ return QObject::tr(""); const QMetaMethod method = object->metaObject()->method(methodIndex); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - return method.methodSignature(); -#else - return method.signature(); -#endif + return Util::prettyMethodSignature(method); } QString AbstractConnectionsModel::displayString(QObject* object) @@ -136,47 +127,13 @@ return Util::displayString(object); } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) && defined(HAVE_PRIVATE_QT_HEADERS) -// from Qt4's qobject.cpp -static void computeOffsets(const QMetaObject *mo, int *signalOffset, int *methodOffset) -{ - *signalOffset = *methodOffset = 0; - const QMetaObject *m = mo->superClass(); - while (m) { - const QMetaObjectPrivate *d = QMetaObjectPrivate::get(m); - *methodOffset += d->methodCount; - *signalOffset += d->signalCount; - m = m->superClass(); - } -} -#endif - int AbstractConnectionsModel::signalIndexToMethodIndex(QObject* object, int signalIndex) { -#ifdef HAVE_PRIVATE_QT_HEADERS -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - return QMetaObjectPrivate::signal(object->metaObject(), signalIndex).methodIndex(); -#else - if (signalIndex < 0) return signalIndex; Q_ASSERT(object); - const QMetaObject *mo = object->metaObject(); - int signalOffset, methodOffset; - computeOffsets(mo, &signalOffset, &methodOffset); - while (signalOffset > signalIndex) { - mo = mo->superClass(); - computeOffsets(mo, &signalOffset, &methodOffset); - } - const int offset = methodOffset - signalOffset; - return object->metaObject()->method(signalIndex + offset).methodIndex(); -#endif -#else - Q_UNUSED(object); - Q_UNUSED(signalIndex); - return -1; -#endif + return Util::signalIndexToMethodIndex(object->metaObject(), signalIndex); } QMap< int, QVariant > AbstractConnectionsModel::itemData(const QModelIndex& index) const diff -Nru gammaray-2.1.0/core/tools/objectinspector/inboundconnectionsmodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/inboundconnectionsmodel.cpp --- gammaray-2.1.0/core/tools/objectinspector/inboundconnectionsmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/inboundconnectionsmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -83,12 +83,15 @@ Connection conn; conn.endpoint = s->sender; - conn.slotIndex = s->method(); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) conn.signalIndex = signalIndexToMethodIndex(s->sender, s->signal_index); - if (s->isSlotObject) + if (s->isSlotObject) { conn.slotIndex = -1; + } else { + conn.slotIndex = s->method(); + } #else + conn.slotIndex = s->method(); conn.signalIndex = signalIndexToMethodIndex(s->sender, signalIndexForConnection(s, s->sender)); #endif conn.type = s->connectionType; diff -Nru gammaray-2.1.0/core/tools/objectinspector/methodsextension.cpp gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/methodsextension.cpp --- gammaray-2.1.0/core/tools/objectinspector/methodsextension.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/methodsextension.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -105,9 +105,19 @@ const QModelIndex index = selectionModel->selectedRows().first(); const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value(); - if (method.methodType() == QMetaMethod::Slot || method.methodType() == QMetaMethod::Method) { - m_methodArgumentModel->setMethod(method); - } else if (method.methodType() == QMetaMethod::Signal) { + m_methodArgumentModel->setMethod(method); +} + +void MethodsExtension::connectToSignal() +{ + QItemSelectionModel *selectionModel = ObjectBroker::selectionModel(m_model); + if (selectionModel->selectedRows().size() != 1) { + return; + } + const QModelIndex index = selectionModel->selectedRows().first(); + + const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value(); + if (method.methodType() == QMetaMethod::Signal) { m_signalMapper->connectToSignal(m_object, method); } } diff -Nru gammaray-2.1.0/core/tools/objectinspector/methodsextension.h gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/methodsextension.h --- gammaray-2.1.0/core/tools/objectinspector/methodsextension.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/methodsextension.h 2014-10-15 20:32:48.000000000 +0000 @@ -53,6 +53,7 @@ public slots: void activateMethod(); void invokeMethod(Qt::ConnectionType type); + void connectToSignal(); private slots: void signalEmitted(QObject *sender, int signalIndex, const QVector &args); diff -Nru gammaray-2.1.0/core/tools/objectinspector/outboundconnectionsmodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/outboundconnectionsmodel.cpp --- gammaray-2.1.0/core/tools/objectinspector/outboundconnectionsmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/objectinspector/outboundconnectionsmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -67,11 +67,12 @@ Connection conn; conn.endpoint = c->receiver; conn.signalIndex = signalIndexToMethodIndex(m_object, signalIndex); - conn.slotIndex = c->method(); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (c->isSlotObject) conn.slotIndex = -1; + else #endif + conn.slotIndex = c->method(); conn.type = c->connectionType; c = c->nextConnectionList; m_connections.push_back(conn); diff -Nru gammaray-2.1.0/core/tools/resourcebrowser/resourcebrowser.cpp gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcebrowser.cpp --- gammaray-2.1.0/core/tools/resourcebrowser/resourcebrowser.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcebrowser.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -45,6 +45,25 @@ this, SLOT(currentChanged(QModelIndex))); } +void ResourceBrowser::downloadResource(const QString &sourceFilePath, const QString &targetFilePath) +{ + const QFileInfo fi(sourceFilePath); + + if (fi.isFile()) { + static const QStringList l = QStringList() << "jpg" << "png" << "jpeg"; + if (l.contains(fi.suffix())) { + emit resourceDownloaded(targetFilePath, QPixmap(fi.absoluteFilePath())); + } else { + QFile f(fi.absoluteFilePath()); + if (f.open(QFile::ReadOnly | QFile::Text)) { + emit resourceDownloaded(targetFilePath, f.readAll()); + } else { + qWarning() << "Failed to open" << fi.absoluteFilePath(); + } + } + } +} + void ResourceBrowser::currentChanged(const QModelIndex ¤t) { const QFileInfo fi(current.data(ResourceModel::FilePathRole).toString()); diff -Nru gammaray-2.1.0/core/tools/resourcebrowser/resourcebrowser.h gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcebrowser.h --- gammaray-2.1.0/core/tools/resourcebrowser/resourcebrowser.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcebrowser.h 2014-10-15 20:32:48.000000000 +0000 @@ -38,6 +38,9 @@ public: explicit ResourceBrowser(ProbeInterface *probe, QObject *parent = 0); + public slots: + void downloadResource(const QString &sourceFilePath, const QString &targetFilePath); + private slots: void currentChanged(const QModelIndex ¤t); }; diff -Nru gammaray-2.1.0/core/tools/resourcebrowser/resourcefiltermodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcefiltermodel.cpp --- gammaray-2.1.0/core/tools/resourcebrowser/resourcefiltermodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcefiltermodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -44,3 +44,7 @@ return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); } +QMap ResourceFilterModel::itemData(const QModelIndex &index) const +{ + return sourceModel()->itemData(mapToSource(index)); +} diff -Nru gammaray-2.1.0/core/tools/resourcebrowser/resourcefiltermodel.h gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcefiltermodel.h --- gammaray-2.1.0/core/tools/resourcebrowser/resourcefiltermodel.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/resourcebrowser/resourcefiltermodel.h 2014-10-15 20:32:48.000000000 +0000 @@ -34,6 +34,7 @@ public: explicit ResourceFilterModel(QObject *parent = 0); virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; + virtual QMap itemData(const QModelIndex &index) const; }; } diff -Nru gammaray-2.1.0/core/tools/standardpaths/standardpathsmodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/standardpaths/standardpathsmodel.cpp --- gammaray-2.1.0/core/tools/standardpaths/standardpathsmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/standardpaths/standardpathsmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -34,7 +34,7 @@ #define P(x) { QStandardPaths:: x, #x } -static standard_path_t standard_paths[] = { +static const standard_path_t standard_paths[] = { P(DesktopLocation), P(DocumentsLocation), P(FontsLocation), @@ -55,7 +55,7 @@ #undef P -static int standard_path_count = sizeof(standard_paths) / sizeof(standard_path_t); +static const int standard_path_count = sizeof(standard_paths) / sizeof(standard_path_t); StandardPathsModel::StandardPathsModel(QObject *parent) : QAbstractTableModel(parent) diff -Nru gammaray-2.1.0/core/tools/textdocumentinspector/textdocumentinspector.cpp gammaray-2.2.0-0ubuntu0/core/tools/textdocumentinspector/textdocumentinspector.cpp --- gammaray-2.1.0/core/tools/textdocumentinspector/textdocumentinspector.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/textdocumentinspector/textdocumentinspector.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -63,6 +63,11 @@ const QItemSelection &deselected) { Q_UNUSED(deselected); + if (selected.isEmpty()) { + m_textDocumentModel->setDocument(0); + return; + } + const QModelIndex selectedRow = selected.first().topLeft(); QObject *selectedObj = selectedRow.data(ObjectModel::ObjectRole).value(); QTextDocument *doc = qobject_cast(selectedObj); diff -Nru gammaray-2.1.0/core/tools/textdocumentinspector/textdocumentmodel.cpp gammaray-2.2.0-0ubuntu0/core/tools/textdocumentinspector/textdocumentmodel.cpp --- gammaray-2.1.0/core/tools/textdocumentinspector/textdocumentmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/tools/textdocumentinspector/textdocumentmodel.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -31,6 +31,19 @@ using namespace GammaRay; +static QString formatTypeToString(int type) +{ + switch (type) { + case QTextFormat::InvalidFormat: return "Invalid"; + case QTextFormat::BlockFormat: return "Block"; + case QTextFormat::CharFormat: return "Char"; + case QTextFormat::ListFormat: return "List"; + case QTextFormat::FrameFormat: return "Frame"; + case QTextFormat::UserFormat: return "User"; + } + return QString("Unknown format: %1").arg(type); +} + TextDocumentModel::TextDocumentModel(QObject *parent) : QStandardItemModel(parent), m_document(0) { @@ -43,8 +56,10 @@ } m_document = doc; - connect(m_document, SIGNAL(contentsChanged()), SLOT(documentChanged())); fillModel(); + + if (m_document) + connect(m_document, SIGNAL(contentsChanged()), SLOT(documentChanged())); } void TextDocumentModel::documentChanged() @@ -63,6 +78,7 @@ QStandardItem *item = new QStandardItem(tr("Root Frame")); const QTextFormat f = m_document->rootFrame()->frameFormat(); item->setData(QVariant::fromValue(f), FormatRole); + item->setEditable(false); QStandardItemModel::appendRow(QList() << item << formatItem(m_document->rootFrame()->frameFormat())); @@ -135,8 +151,9 @@ const QTextImageFormat imgformat = format.toImageFormat(); item->setText(tr("Image: %1").arg(imgformat.name())); } else { - item->setText(tr("Format type: %1").arg(format.type())); + item->setText(formatTypeToString(format.type())); } + item->setEditable(false); return item; } @@ -145,6 +162,7 @@ { item->setData(QVariant::fromValue(format), FormatRole); item->setData(boundingBox, BoundingBoxRole); + item->setEditable(false); parent->appendRow(QList() << item << formatItem(format)); } diff -Nru gammaray-2.1.0/core/util.cpp gammaray-2.2.0-0ubuntu0/core/util.cpp --- gammaray-2.1.0/core/util.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/util.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -21,6 +21,8 @@ along with this program. If not, see . */ +#include "config-gammaray.h" + #include "util.h" #include #include "varianthandler.h" @@ -33,6 +35,11 @@ #include #include +#ifdef HAVE_PRIVATE_QT_HEADERS +#include +#include +#endif + #include using namespace GammaRay; @@ -54,19 +61,28 @@ return "QObject(0x0)"; } if (object->objectName().isEmpty()) { - return QString::fromLatin1("%1 (%2)"). - arg(addressToString(object)). - arg(object->metaObject()->className()); + return QString::fromLatin1("%1[this=%2]"). + arg(object->metaObject()->className()). + arg(addressToString(object)); } return object->objectName(); } +QString Util::shortDisplayString(const QObject* object) +{ + if (!object) + return "0x0"; + if (object->objectName().isEmpty()) + return addressToString(object); + return object->objectName(); +} + QString Util::addressToString(const void *p) { return (QLatin1String("0x") + QString::number(reinterpret_cast(p), 16)); } -QString Util::enumToString(const QVariant &value, const char *typeName, QObject *object) +QString Util::enumToString(const QVariant &value, const char *typeName, const QObject *object) { QByteArray enumTypeName(typeName); if (enumTypeName.isEmpty()) { @@ -96,6 +112,28 @@ return me.valueToKeys(value.toInt()); } +QString Util::prettyMethodSignature(const QMetaMethod& method) +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return method.signature(); +#else + QString signature = method.typeName(); + signature += ' ' + method.name() + '('; + QStringList args; + args.reserve(method.parameterCount()); + const QList paramTypes = method.parameterTypes(); + const QList paramNames = method.parameterNames(); + for (int i = 0; i < method.parameterCount(); ++i) { + QString arg = paramTypes.at(i); + if (!paramNames.at(i).isEmpty()) + arg += ' ' + paramNames.at(i); + args.push_back(arg); + } + signature += args.join(", ") + ')'; + return signature; +#endif +} + bool Util::descendantOf(const QObject *ascendant, const QObject *obj) { QObject *parent = obj->parent(); @@ -109,7 +147,7 @@ } namespace GammaRay { -static QString stringifyProperty(QObject *obj, const QString &propName) +static QString stringifyProperty(const QObject *obj, const QString &propName) { const QVariant value = obj->property(propName.toLatin1()); const QMetaProperty mp = @@ -184,7 +222,7 @@ return data; } -static QVariant iconForObject(const QMetaObject *mo, QObject *obj) +static QVariant iconForObject(const QMetaObject *mo, const QObject *obj) { static const IconDatabase iconDataBase = readIconData(); // stupid Qt convention to use int for sizes... the static cast shuts down warnings about conversion from size_t to int. @@ -216,7 +254,7 @@ } -QVariant Util::iconForObject(QObject *obj) +QVariant Util::iconForObject(const QObject *obj) { if (obj) { return GammaRay::iconForObject(obj->metaObject(), obj); @@ -224,6 +262,16 @@ return QVariant(); } +QString Util::tooltipForObject(const QObject* object) +{ + return QObject::tr("

Object name: %1\nType: %2\nParent: %3 (Address: %4)\nNumber of children: %5

"). + arg(object->objectName().isEmpty() ? "<Not set>" : object->objectName()). + arg(object->metaObject()->className()). + arg(object->parent() ? object->parent()->metaObject()->className() : ""). + arg(Util::addressToString(object->parent())). + arg(object->children().size()); +} + void Util::drawTransparencyPattern(QPainter *painter, const QRect &rect, int squareSize) { QPixmap bgPattern(2 * squareSize, 2 * squareSize); @@ -236,3 +284,45 @@ bgBrush.setTexture(bgPattern); painter->fillRect(rect, bgBrush); } + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) && defined(HAVE_PRIVATE_QT_HEADERS) +// from Qt4's qobject.cpp +static void computeOffsets(const QMetaObject *mo, int *signalOffset, int *methodOffset) +{ + *signalOffset = *methodOffset = 0; + const QMetaObject *m = mo->superClass(); + while (m) { + const QMetaObjectPrivate *d = QMetaObjectPrivate::get(m); + *methodOffset += d->methodCount; + *signalOffset += d->signalCount; + m = m->superClass(); + } +} +#endif + +int Util::signalIndexToMethodIndex(const QMetaObject* metaObject, int signalIndex) +{ +#ifdef HAVE_PRIVATE_QT_HEADERS +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + return QMetaObjectPrivate::signal(metaObject, signalIndex).methodIndex(); +#else + + if (signalIndex < 0) + return signalIndex; + Q_ASSERT(metaObject); + + int signalOffset, methodOffset; + computeOffsets(metaObject, &signalOffset, &methodOffset); + while (signalOffset > signalIndex) { + metaObject = metaObject->superClass(); + computeOffsets(metaObject, &signalOffset, &methodOffset); + } + const int offset = methodOffset - signalOffset; + return metaObject->method(signalIndex + offset).methodIndex(); +#endif +#else + Q_UNUSED(metaObject); + Q_UNUSED(signalIndex); + return -1; +#endif +} diff -Nru gammaray-2.1.0/core/util.h gammaray-2.2.0-0ubuntu0/core/util.h --- gammaray-2.1.0/core/util.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/util.h 2014-10-15 20:32:48.000000000 +0000 @@ -52,13 +52,21 @@ /** * Returns a human readable string name of the specified QObject. - * @param object is a pointer to a valid QObject. + * This does include the type name. + * @param object is a pointer to a valid or null QObject. * * @return a QString containing the human readable display string. */ GAMMARAY_CORE_EXPORT QString displayString(const QObject *object); /** + * Short display string for a QObject, either the object name or the address. + * This does not include the type name. + * @param object valid or 0 QObject + */ + GAMMARAY_CORE_EXPORT QString shortDisplayString(const QObject *object); + + /** * Returns a string version (as a hex number starting with "0x") of the * memory address @p p. * @param p is a pointer to an address in memory. @@ -79,7 +87,23 @@ */ GAMMARAY_CORE_EXPORT QString enumToString(const QVariant &value, const char *typeName = 0, - QObject *object = 0); + const QObject *object = 0); + + /** + * Convenience wrapper for the above, in case the enum value is not available + * in a QVariant already. + */ + template + inline QString enumToString(T value, const char *typeName = 0, const QObject *object = 0) + { + return enumToString(QVariant::fromValue(value), typeName, object); + } + + /** + * Returns a display string for @p method. + * This includes return types and argument names, if available. + */ + GAMMARAY_CORE_EXPORT QString prettyMethodSignature(const QMetaMethod &method); /** * Determines if the QObject @p obj is a descendant of the QObject @p ascendant. @@ -116,7 +140,13 @@ * * @return on failure QVariant() is returned; else a QIcon */ - GAMMARAY_CORE_EXPORT QVariant iconForObject(QObject *object); + GAMMARAY_CORE_EXPORT QVariant iconForObject(const QObject *object); + + /** + * Returns a suitable rich text tooltip string for @p object. + * @param object a pointer to a valid or null QObject. + */ + GAMMARAY_CORE_EXPORT QString tooltipForObject(const QObject *object); /** * Draws a transparency pattern, i.e. the common checkerboard pattern into @p rect. @@ -124,6 +154,18 @@ * @p size The size of the individual checkerboard squares. */ GAMMARAY_CORE_EXPORT void drawTransparencyPattern(QPainter *painter, const QRect &rect, int squareSize = 8); + + /** + * Turns a signal index into a method index. + * Signals indexes are used internally by QObject as an optimization and are + * usually not exposed in public API. If you get them nevertheless, by using + * internals of QObject this method turns them into method indexes that work + * with public QMetaObject API. + * + * @param metaObject The meta object the signal belongs so + * @since 2.2 + */ + GAMMARAY_CORE_EXPORT int signalIndexToMethodIndex(const QMetaObject* metaObject, int signalIndex); } } diff -Nru gammaray-2.1.0/core/varianthandler.cpp gammaray-2.2.0-0ubuntu0/core/varianthandler.cpp --- gammaray-2.1.0/core/varianthandler.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/varianthandler.cpp 2014-10-15 20:32:48.000000000 +0000 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -54,8 +55,51 @@ struct VariantHandlerRepository { QHash*> stringConverters; + QVector genericStringConverters; }; +static QString displayMatrix4x4(const QMatrix4x4 &matrix) +{ + QStringList rows; + for (int i = 0; i < 4; ++i) { + QStringList cols; + for (int j = 0; j < 4; ++j) { + cols.push_back(QString::number(matrix(i, j))); + } + rows.push_back(cols.join(" ")); + } + return '[' + rows.join(", ") + ']'; +} + +static QString displayMatrix4x4(const QMatrix4x4 *matrix) +{ + if (matrix) { + return displayMatrix4x4(*matrix); + } + return ""; +} + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +static QString displayShaderType(const QOpenGLShader::ShaderType type) +{ + QStringList types; +#define ST(t) if (type & QOpenGLShader::t) types.push_back(#t); + ST(Vertex) + ST(Fragment) +#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) + ST(Geometry) + ST(TessellationControl) + ST(TessellationEvaluation) + ST(Compute) +#endif +#undef ST + + if (types.isEmpty()) + return ""; + return types.join(" | "); +} +#endif + } Q_GLOBAL_STATIC(VariantHandlerRepository, s_variantHandlerRepository) @@ -84,13 +128,13 @@ } case QVariant::Line: return - QString::fromUtf8("%1 x %2 → %3 x %4"). + QString::fromUtf8("%1, %2 → %3, %4"). arg(value.toLine().x1()).arg(value.toLine().y1()). arg(value.toLine().x2()).arg(value.toLine().y2()); case QVariant::LineF: return - QString::fromUtf8("%1 x %2 → %3 x %4"). + QString::fromUtf8("%1, %2 → %3, %4"). arg(value.toLineF().x1()).arg(value.toLineF().y1()). arg(value.toLineF().x2()).arg(value.toLineF().y2()); @@ -99,19 +143,19 @@ case QVariant::Point: return - QString::fromLatin1("%1x%2"). + QString::fromLatin1("%1, %2"). arg(value.toPoint().x()). arg(value.toPoint().y()); case QVariant::PointF: return - QString::fromLatin1("%1x%2"). + QString::fromLatin1("%1, %2"). arg(value.toPointF().x()). arg(value.toPointF().y()); case QVariant::Rect: return - QString::fromLatin1("%1x%2 %3x%4"). + QString::fromLatin1("%1, %2 %3 x %4"). arg(value.toRect().x()). arg(value.toRect().y()). arg(value.toRect().width()). @@ -119,7 +163,7 @@ case QVariant::RectF: return - QString::fromLatin1("%1x%2 %3x%4"). + QString::fromLatin1("%1, %2 %3 x %4"). arg(value.toRectF().x()). arg(value.toRectF().y()). arg(value.toRectF().width()). @@ -149,13 +193,13 @@ case QVariant::Size: return - QString::fromLatin1("%1x%2"). + QString::fromLatin1("%1 x %2"). arg(value.toSize().width()). arg(value.toSize().height()); case QVariant::SizeF: return - QString::fromLatin1("%1x%2"). + QString::fromLatin1("%1 x %2"). arg(value.toSizeF().width()). arg(value.toSizeF().height()); @@ -212,6 +256,14 @@ return Util::displayString(value.value()); } + if (value.userType() == qMetaTypeId()) { + return displayMatrix4x4(value.value()); + } + + if (value.userType() == qMetaTypeId()) { + return displayMatrix4x4(value.value()); + } + #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (value.userType() == qMetaTypeId >()) { const QSet set = value.value >(); @@ -303,7 +355,10 @@ } } -#endif + if (value.userType() == qMetaTypeId()) + return displayShaderType(value.value()); + +#endif // Qt5 // enums const QString enumStr = Util::enumToString(value); @@ -326,18 +381,31 @@ int emptyStrings = 0; foreach (const QVariant &v, it) { s.push_back(displayString(v)); - if (s.last().isEmpty()) + if (s.last().isEmpty()) { ++emptyStrings; + } } - if (it.size() == 0) + if (it.size() == 0) { return QObject::tr(""); - else if (it.size() == emptyStrings) // we don't know the content either + } else if (it.size() == emptyStrings) { // we don't know the content either return QObject::tr("%1 entries").arg(emptyStrings); - else + } else { return s.join(", "); + } } #endif + // generic converters + QVector genStrConverters = + s_variantHandlerRepository()->genericStringConverters; + foreach (const GenericStringConverter &converter, genStrConverters) { + bool ok = false; + const QString s = converter(value, &ok); + if (ok) { + return s; + } + } + return value.toString(); } @@ -415,3 +483,9 @@ { s_variantHandlerRepository()->stringConverters.insert(type, converter); } + +void VariantHandler::registerGenericStringConverter( + VariantHandler::GenericStringConverter converter) +{ + s_variantHandlerRepository()->genericStringConverters.push_back(converter); +} diff -Nru gammaray-2.1.0/core/varianthandler.h gammaray-2.2.0-0ubuntu0/core/varianthandler.h --- gammaray-2.1.0/core/varianthandler.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/core/varianthandler.h 2014-10-15 20:32:48.000000000 +0000 @@ -39,10 +39,18 @@ virtual RetT operator() (const QVariant &v) = 0; }; - template struct ConverterImpl : public Converter + template struct ConverterImpl + : public Converter { - explicit inline ConverterImpl(FuncT converter) : f(converter) {} - /*override*/ inline RetT operator() (const QVariant &v) { return f(v.value()); } + explicit inline ConverterImpl(FuncT converter) : f(converter) + { + } + + /*override*/ + inline RetT operator() (const QVariant &v) + { + return f(v.value()); + } FuncT f; }; ///@endcond @@ -57,6 +65,15 @@ GAMMARAY_CORE_EXPORT QString displayString(const QVariant &value); /** + * Returns a human readable string version of the given value. + * Thihs is a convenience overload of the QVariant-based version above. + * + * @return a QString containing the human readable string. + */ + template + inline QString displayString(T value) { return displayString(QVariant::fromValue(value)); } + + /** * Returns a value representing @p value in a itemview decoration role. * @param value is a QVariant. * @@ -80,6 +97,17 @@ Converter *converter = new ConverterImpl(f); registerStringConverter(qMetaTypeId(), converter); } + + typedef QString(*GenericStringConverter)(const QVariant &value, bool *ok); + /** + * Register a generic string conversion function for various variant types. + * This can be used when you have a converter that can dynamically check if + * it can handle a given variant, and the types it can handle aren't known + * at compile time (example: QQmlListProperty). + * @param converter The converter function. It's second parameter is used to + * indicate if the value could be handled. + */ + GAMMARAY_CORE_EXPORT void registerGenericStringConverter(GenericStringConverter converter); } } diff -Nru gammaray-2.1.0/debian/changelog gammaray-2.2.0-0ubuntu0/debian/changelog --- gammaray-2.1.0/debian/changelog 2014-07-11 09:33:08.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/changelog 2014-10-15 20:33:32.000000000 +0000 @@ -1,27 +1,52 @@ -gammaray (2.1.0-1ubuntu3) utopic; urgency=medium +gammaray (2.2.0-0ubuntu0-gerboland) utopic; urgency=medium - * Disable tests as they fail in the PPA for armhf arch + * Update to 2.2.0 prerelease - -- Gerry Boland Fri, 11 Jul 2014 10:32:47 +0100 + -- Gerry Boland Wed, 15 Oct 2014 21:12:52 +0100 -gammaray (2.1.0-1ubuntu2) utopic; urgency=medium +gammaray (2.1.0-3ubuntu1) utopic; urgency=medium - * Added missing qtdeclarative5-private-dev dependency + * Fix FTBFS on ppc64el. - -- Gerry Boland Thu, 10 Jul 2014 23:24:13 +0100 + -- Felix Geyer Mon, 28 Jul 2014 19:29:20 +0200 -gammaray (2.1.0-1ubuntu1) utopic; urgency=medium +gammaray (2.1.0-3) unstable; urgency=medium - * New upstream release - * Refreshed d/patches/use-empty-rpath.patch. + * Team upload. - -- Gerry Boland Thu, 10 Jul 2014 20:32:04 +0100 + [ Jakub Adam ] + * Force 24-bit color depth to Xvfb + - attempts to fix "Unsupported screen depth: 8" failures during + the test runs on some architectures. -gammaray (2.0.2-1ubuntu1) utopic; urgency=medium + [ Felix Geyer ] + * Fix FTBFS on mips64 kernel, ppc64 and arm64. + * Make testsuite non-fatal on kfreebsd due to bug #570805: + Wrong path in /proc/pid/maps when bind mounted. + * Run tests sequentially in the hope that it helps running them on + architectures with low resources. - * Rebuild against Qt 5.3 + -- Felix Geyer Sun, 27 Jul 2014 17:22:50 +0200 - -- Timo Jyrinki Tue, 10 Jun 2014 16:35:56 +0200 +gammaray (2.1.0-2) unstable; urgency=medium + + * Fix FTBFS on kFreeBSD, Hurd, mips, ppc, and s390x (Closes: #754986). + + -- Jakub Adam Fri, 18 Jul 2014 18:26:51 +0200 + +gammaray (2.1.0-1) unstable; urgency=medium + + [ Felix Geyer ] + * Call dh_auto_clean for both build directories. + + [ Jakub Adam ] + * New upstream release. + * Removed no longer needed use-empty-rpath.patch. + * Build-depend on qtdeclarative5-private-dev. + * Create gammaray-plugin-quickinspector binary package. + * Removed unused license paragraph from d/copyright. + + -- Jakub Adam Mon, 07 Jul 2014 21:38:05 +0200 gammaray (2.0.2-1) unstable; urgency=medium diff -Nru gammaray-2.1.0/debian/control gammaray-2.2.0-0ubuntu0/debian/control --- gammaray-2.1.0/debian/control 2014-07-10 21:47:45.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/control 2014-10-15 20:32:48.000000000 +0000 @@ -12,7 +12,6 @@ qttools5-dev, libqt5svg5-dev, libqt5webkit5-dev, - qtdeclarative5-dev, qtdeclarative5-private-dev, libqt4-dev, libqt4-private-dev, @@ -67,6 +66,25 @@ # Also, for use with 3D glasses, various types of stereoscopic rendering # are supported. +Package: gammaray-plugin-quickinspector +Architecture: any +Depends: gammaray (= ${binary:Version}), + qml-module-qtquick2, + qml-module-qtquick-controls, + ${shlibs:Depends}, + ${misc:Depends} +Description: GammaRay plugin for inspecting QtQuick2 applications + This plugin provides the user with the following inspection and debugging + facilities: + . + * Tree view of all QQuickItems in the scene, marking invisible items + and items having focus. + * Object inspector allowing to see all the properties, inspect + signal-slot connections, and directly invoke slots and Q_INVOKABLE + methods. + * Live-preview of the QtQuick scene inside the GammaRay window. + * Qt Quick scene graph inspector. + Package: gammaray-plugin-kjobtracker Architecture: any Depends: gammaray (= ${binary:Version}), diff -Nru gammaray-2.1.0/debian/copyright gammaray-2.2.0-0ubuntu0/debian/copyright --- gammaray-2.1.0/debian/copyright 2014-07-10 19:30:54.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/copyright 2014-10-15 20:32:48.000000000 +0000 @@ -89,10 +89,6 @@ For full text of GPL-3 see /usr/share/common-licenses/GPL-3. For the latest version of the GPL see /usr/share/common-licenses/GPL. -License: LGPL-2 - For full text of GNU Library General Public License v2 see - /usr/share/common-licenses/LGPL-2. - License: LGPL-2+ You may use the software under the terms of GNU Library General Public License v2 or, at your option, any later version. diff -Nru gammaray-2.1.0/debian/gammaray.lintian-overrides gammaray-2.2.0-0ubuntu0/debian/gammaray.lintian-overrides --- gammaray-2.1.0/debian/gammaray.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/gammaray.lintian-overrides 2014-10-15 20:32:48.000000000 +0000 @@ -0,0 +1 @@ +gammaray: package-name-doesnt-match-sonames diff -Nru gammaray-2.1.0/debian/gammaray-plugin-quickinspector.install gammaray-2.2.0-0ubuntu0/debian/gammaray-plugin-quickinspector.install --- gammaray-2.1.0/debian/gammaray-plugin-quickinspector.install 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/gammaray-plugin-quickinspector.install 2014-10-15 20:32:48.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/gammaray/*/qt5*/gammaray_qmlsupport* +usr/lib/gammaray/*/qt5*/gammaray_quickinspector* diff -Nru gammaray-2.1.0/debian/gammaray-probe-qt4.lintian-overrides gammaray-2.2.0-0ubuntu0/debian/gammaray-probe-qt4.lintian-overrides --- gammaray-2.1.0/debian/gammaray-probe-qt4.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/gammaray-probe-qt4.lintian-overrides 2014-10-15 20:32:48.000000000 +0000 @@ -0,0 +1 @@ +gammaray-probe-qt4: package-name-doesnt-match-sonames diff -Nru gammaray-2.1.0/debian/patches/debian-archs-fix-build.patch gammaray-2.2.0-0ubuntu0/debian/patches/debian-archs-fix-build.patch --- gammaray-2.1.0/debian/patches/debian-archs-fix-build.patch 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/patches/debian-archs-fix-build.patch 2014-10-15 20:32:48.000000000 +0000 @@ -0,0 +1,62 @@ +From: Jakub Adam +Date: Wed, 16 Jul 2014 15:27:00 +0200 +Subject: debian-archs-fix-build + +--- + cmake/GammaRayProbeABI.cmake | 18 ++++++++++++++++++ + common/probeabidetector_elf.cpp | 3 +++ + 2 files changed, 21 insertions(+) + +diff --git a/cmake/GammaRayProbeABI.cmake b/cmake/GammaRayProbeABI.cmake +index e8519e9..5da6dee 100644 +--- a/cmake/GammaRayProbeABI.cmake ++++ b/cmake/GammaRayProbeABI.cmake +@@ -56,10 +56,32 @@ elseif(APPLE) + set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_SYSTEM_PROCESSOR}") + endif() + ++# kFreeBSD reports i686 as i386 and x86_64 as amd64 ++elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD") ++ if (CMAKE_SYSTEM_PROCESSOR MATCHES "i386") ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-i686") ++ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64") ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-x86_64") ++ else() ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_SYSTEM_PROCESSOR}") ++ endif() ++ ++# Debian GNU/Hurd reports unknown CPU; assume i686 ++elseif(CMAKE_SYSTEM_NAME MATCHES "GNU") ++ if (CMAKE_SYSTEM_PROCESSOR MATCHES "unknown") ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-i686") ++ else() ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_SYSTEM_PROCESSOR}") ++ endif() ++ + else() + # uname reports different ARM versions, unlike ELF, so map all this to "arm" + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-arm") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "mips64" AND CMAKE_SIZEOF_VOID_P EQUAL 4) ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-mips") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") ++ set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-ppc64") + else() + set(GAMMARAY_PROBE_ABI "${GAMMARAY_PROBE_ABI}-${CMAKE_SYSTEM_PROCESSOR}") + endif() +diff --git a/common/probeabidetector_elf.cpp b/common/probeabidetector_elf.cpp +index b35954c..af43eaf 100644 +--- a/common/probeabidetector_elf.cpp ++++ b/common/probeabidetector_elf.cpp +@@ -151,6 +151,11 @@ static QString archFromELFHeader(const uchar *data, quint64 size) + case EM_386: return "i686"; + case EM_X86_64: return "x86_64"; + case EM_ARM: return "arm"; ++ case EM_MIPS: return "mips"; ++ case EM_PPC: return "ppc"; ++ case EM_S390: return "s390x"; ++ case EM_PPC64: return "ppc64"; ++ case EM_AARCH64: return "aarch64"; + } + + qWarning() << "Unsupported ELF machine type:" << hdr->e_machine; diff -Nru gammaray-2.1.0/debian/patches/series gammaray-2.2.0-0ubuntu0/debian/patches/series --- gammaray-2.1.0/debian/patches/series 2014-07-10 19:30:54.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/patches/series 2014-10-15 20:32:48.000000000 +0000 @@ -1 +1 @@ -use-empty-rpath.patch +debian-archs-fix-build.patch diff -Nru gammaray-2.1.0/debian/patches/use-empty-rpath.patch gammaray-2.2.0-0ubuntu0/debian/patches/use-empty-rpath.patch --- gammaray-2.1.0/debian/patches/use-empty-rpath.patch 2014-07-10 19:39:46.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/patches/use-empty-rpath.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -From: Gerry Boland -Date: Thu, 10 Jul 2013 20:39:03 +0100 -Subject: use-empty-rpath - ---- - CMakeLists.txt | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 92e1955..6cbe7de 100644 ---- a/CMakeLists.txt 2014-07-06 17:08:59.000000000 +0100 -+++ b/CMakeLists.txt 2014-07-10 20:37:34.618948845 +0100 -@@ -35,7 +35,6 @@ - set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH}) - set(CMAKE_AUTOMOC ON) - set(CMAKE_INCLUDE_CURRENT_DIR ON) --set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) diff -Nru gammaray-2.1.0/debian/rules gammaray-2.2.0-0ubuntu0/debian/rules --- gammaray-2.1.0/debian/rules 2014-07-11 09:32:42.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian/rules 2014-10-15 20:32:48.000000000 +0000 @@ -4,6 +4,8 @@ export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) + %: dh $@ --parallel @@ -21,13 +23,22 @@ dh_auto_build -B obj-qt4 -O--parallel override_dh_auto_test: - # xvfb-run dh_auto_test -B obj-qt5 - fails to run for armhf build in PPA +# tests fail on kfreebsd because of bug #570805: Wrong path in /proc/pid/maps when bind mounted +ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-amd64 kfreebsd-i386)) + xvfb-run -s "-screen 0 640x480x24" dh_auto_test --max-parallel=1 -B obj-qt5 || true +else + xvfb-run -s "-screen 0 640x480x24" dh_auto_test --max-parallel=1 -B obj-qt5 +endif override_dh_auto_install: dh_auto_install -B obj-qt5 dh_auto_install -B obj-qt4 rm -f debian/tmp/usr/share/doc/gammaray/License.txt +override_dh_auto_clean: + dh_auto_clean -B obj-qt5 + dh_auto_clean -B obj-qt4 + override_dh_installdocs: dh_installdocs --link-doc=gammaray diff -Nru gammaray-2.1.0/debian.changelog gammaray-2.2.0-0ubuntu0/debian.changelog --- gammaray-2.1.0/debian.changelog 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/debian.changelog 2014-10-15 20:32:48.000000000 +0000 @@ -1,80 +1,86 @@ +gammaray (2.1.1) final; urgency=low + + * 2.1.1 first 2.1 bugfix release + + -- Allen Winter Sat, 30 Aug 2014 12:00:00 -0500 + gammaray (2.1.0) final; urgency=low * 2.1.0 final release - -- Allen Winter Fri, 27 Jun 2014 09:30:00 -0500 + -- Allen Winter Fri, 27 Jun 2014 09:30:00 -0500 gammaray (2.0.98) final; urgency=low * 2.1.0 rc1 release - -- Allen Winter Thu, 26 Jun 2014 15:30:00 -0500 + -- Allen Winter Thu, 26 Jun 2014 15:30:00 -0500 gammaray (2.0.2) final; urgency=low * 2.0.2 final release - -- Allen Winter Fri, 18 Apr 2014 11:30:00 -0500 + -- Allen Winter Fri, 18 Apr 2014 11:30:00 -0500 gammaray (2.0.1) final; urgency=low * 2.0.1 final release - -- Allen Winter Fri, 28 Feb 2014 11:30:00 -0500 + -- Allen Winter Fri, 28 Feb 2014 11:30:00 -0500 gammaray (2.0.0) final; urgency=low * 2.0.0 final release - -- Allen Winter Fri, 17 Jan 2014 11:00:00 -0500 + -- Allen Winter Fri, 17 Jan 2014 11:00:00 -0500 gammaray (1.9.96) final; urgency=low * 2.0.0 beta2 release - -- Allen Winter Sat, 11 Jan 2014 11:00:00 -0500 + -- Allen Winter Sat, 11 Jan 2014 11:00:00 -0500 gammaray (1.9.95) final; urgency=low * 2.0.0 beta1 release - -- Allen Winter Fri, 20 Dec 2013 11:00:00 -0500 + -- Allen Winter Fri, 20 Dec 2013 11:00:00 -0500 gammaray (1.3.2) final; urgency=low * 1.3.2 patch release - -- Allen Winter Thu, 03 Oct 2013 11:00:00 -0500 + -- Allen Winter Thu, 03 Oct 2013 11:00:00 -0500 gammaray (1.3.1) final; urgency=low * 1.3.1 patch release - -- Allen Winter Tues, 30 Apr 2013 16:30:00 -0500 + -- Allen Winter Tues, 30 Apr 2013 16:30:00 -0500 gammaray (1.3.0) final; urgency=low * 1.3.0 final release - -- Allen Winter Sun, 27 Jan 2013 18:00:00 -0500 + -- Allen Winter Sun, 27 Jan 2013 18:00:00 -0500 gammaray (1.2.2) patch; urgency=low * 1.2.2 patch release - -- Allen Winter Fri, 21 Dec 2012 14:33:00 -0500 + -- Allen Winter Fri, 21 Dec 2012 14:33:00 -0500 gammaray (1.2.1) patch; urgency=low * 1.2.1 patch release - -- Allen Winter Thu, 16 Aug 2012 10:17:14 -0500 + -- Allen Winter Thu, 16 Aug 2012 10:17:14 -0500 gammaray (1.2.0) final; urgency=low * 1.2.0 final release - -- Allen Winter Thu, 05 Jul 2012 10:19:14 -0500 + -- Allen Winter Thu, 05 Jul 2012 10:19:14 -0500 gammaray (1.1.99) beta2; urgency=low diff -Nru gammaray-2.1.0/docs/CMakeLists.txt gammaray-2.2.0-0ubuntu0/docs/CMakeLists.txt --- gammaray-2.1.0/docs/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/docs/CMakeLists.txt 2014-10-15 20:32:48.000000000 +0000 @@ -1,7 +1,7 @@ # # man page # -if (UNIX) +if(UNIX) find_program(POD2MAN_EXECUTABLE pod2man) gammaray_add_dummy_package(pod2man POD2MAN_EXECUTABLE) set_package_properties(pod2man PROPERTIES diff -Nru gammaray-2.1.0/docs/Doxyfile.cmake gammaray-2.2.0-0ubuntu0/docs/Doxyfile.cmake --- gammaray-2.1.0/docs/Doxyfile.cmake 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/docs/Doxyfile.cmake 2014-10-15 20:32:48.000000000 +0000 @@ -63,7 +63,6 @@ ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -SHOW_DIRECTORIES = NO FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages @@ -136,7 +135,6 @@ HTML_HEADER = HTML_FOOTER = @CMAKE_SOURCE_DIR@/docs/footer.html HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = diff -Nru gammaray-2.1.0/docs/gammaray.pod gammaray-2.2.0-0ubuntu0/docs/gammaray.pod --- gammaray-2.1.0/docs/gammaray.pod 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/docs/gammaray.pod 2014-10-15 20:32:48.000000000 +0000 @@ -132,15 +132,24 @@ =head1 AUTHORS - Volker Krause (Head Engineer) Allen Winter Andreas Holzammer + Anton Kreuzkamp David Faure + Frank Osterfeld + James Turner + Jan Dalheimer Kevin Funk + Laurent Montel + Mathias Hasselmann Milian Wolff Patrick Spendrin + Peter Kuemmel + Rafael Roquetto Stephen Kelly + Thomas McGuire Till Adam Tobias Koenig + Volker Krause =cut diff -Nru gammaray-2.1.0/.emacs-dirvars gammaray-2.2.0-0ubuntu0/.emacs-dirvars --- gammaray-2.1.0/.emacs-dirvars 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/.emacs-dirvars 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -;; -*- emacs-lisp -*- -;; -;; This file is processed by the dirvars emacs package. Each variable -;; setting below is performed when this dirvars file is loaded. -;; -indent-tabs-mode: nil -tab-width: 8 -c-basic-offset: 2 -evaluate: (c-set-offset 'innamespace '0) -evaluate: (c-set-offset 'inline-open '0) -kdab-qt-version: 4 -magic-parens-mode: nil diff -Nru gammaray-2.1.0/GammaRay.appdata.xml gammaray-2.2.0-0ubuntu0/GammaRay.appdata.xml --- gammaray-2.1.0/GammaRay.appdata.xml 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/GammaRay.appdata.xml 2014-10-15 20:32:48.000000000 +0000 @@ -1,6 +1,6 @@ - GammayRay.desktop + GammaRay.desktop GFDL-1.3 GPL-2.0+ GammaRay diff -Nru gammaray-2.1.0/gammaray.dsc gammaray-2.2.0-0ubuntu0/gammaray.dsc --- gammaray-2.1.0/gammaray.dsc 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/gammaray.dsc 2014-10-15 20:32:48.000000000 +0000 @@ -1,10 +1,10 @@ Format: 1.0 Source: gammaray -Version: 2.1.0 +Version: 2.1.1 Binary: gammaray Maintainer: Allen Winter Architecture: any Build-Depends: debhelper (>= 4.1.16), cdbs, cmake, libqt4-dev, libqtwebkit-dev, graphviz-dev Files: - 00000000000000000000000000000000 00000 gammaray-2.1.0.tar.gz + 00000000000000000000000000000000 00000 gammaray-2.1.1.tar.gz diff -Nru gammaray-2.1.0/gammaray.spec gammaray-2.2.0-0ubuntu0/gammaray.spec --- gammaray-2.1.0/gammaray.spec 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/gammaray.spec 2014-10-15 20:32:48.000000000 +0000 @@ -1,5 +1,5 @@ Name: gammaray -Version: 2.1.0 +Version: 2.1.1 Release: 2 Summary: An introspection tool for Qt applications Source: %{name}-%{version}.tar.gz @@ -28,6 +28,11 @@ %if 0%{?suse_version} > 1230 BuildRequires: python-devel %endif +%if 0%{?suse_version} > 1310 +# dependency ambiguity for vtk-java needed by vtk-devel in openSUSE > 13.1 +#!BuildIgnore: java-1_7_0-openjdk-bootstrap-headless +#!BuildIgnore: java-1_7_0-openjdk-headless +%endif Requires: graphviz %endif @@ -199,6 +204,8 @@ %{_libdir}/cmake/GammaRay/ %changelog +* Sat Aug 30 2014 Allen Winter 2.1.1 + 2.1.1 final * Fri Jun 27 2014 Allen Winter 2.1.0 2.1.0 final * Thu Jun 26 2014 Allen Winter 2.0.98 diff -Nru gammaray-2.1.0/.gitignore gammaray-2.2.0-0ubuntu0/.gitignore --- gammaray-2.1.0/.gitignore 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -# general -*.kdev4 -*~ -*.rej -*.orig -*.out -.* -CMakeLists.txt.user - -# from kdiff3 -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* diff -Nru gammaray-2.1.0/Install.txt gammaray-2.2.0-0ubuntu0/Install.txt --- gammaray-2.1.0/Install.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/Install.txt 2014-10-15 20:32:48.000000000 +0000 @@ -11,8 +11,9 @@ To build a debug version pass -DCMAKE_BUILD_TYPE=Debug to cmake. To build GammaRay you will need: - - CMake 2.8.9 (or 2.8.11 on Windows) - - Qt 4.7 or higher + - CMake 2.8.11 + - a C++ compiler with C++11 lambda support + - Qt 4.8 or higher Optional FOSS packages (eg. VTK, Graphviz, etc) provide extra functionality. See the "Optional Dependencies" section below for more details. diff -Nru gammaray-2.1.0/.kateconfig gammaray-2.2.0-0ubuntu0/.kateconfig --- gammaray-2.1.0/.kateconfig 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/.kateconfig 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -// kate: space-indent on; indent-width 2; remove-trailing-space on; remove-trailing-space-save on; diff -Nru gammaray-2.1.0/.krazy gammaray-2.2.0-0ubuntu0/.krazy --- gammaray-2.1.0/.krazy 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/.krazy 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -CHECKSETS qt4,c++,foss - -#KDAB-specific checks -EXTRA kdabcopyright - -#additional checks -EXTRA defines,null,style - -#coding style settings -STYLE_CPPSTYLE kde -STYLE_OFFSET 2 -STYLE_LINEMAX 100 - -#no need to check 3rdparty stuff -SKIP /3rdparty/ -#nor Nokia's stuff -SKIP /qmldebugcontrol/ -SKIP /modeltest.cpp|/modeltest.h -SKIP /processlist_unix.cpp|/processlist_win.cpp|/processlist.h -SKIP /launcher/processlist.h|/launcher/injector/interactiveprocess.cpp|/launcher/injector/interactiveprocess.h -SKIP StackWalker -#if you have a build subdir, skip it -SKIP /build -SKIP Doxyfile.cmake - -#skip the borrowed code in the cmake subdir -SKIP /cmake/MacroLogFeature.cmake|/cmake/ECMQt4To5Porting.cmake|/cmake/FindGraphviz.cmake|/cmake/Toolchain-QNX65.cmake diff -Nru gammaray-2.1.0/launcher/injector/preloadinjector.cpp gammaray-2.2.0-0ubuntu0/launcher/injector/preloadinjector.cpp --- gammaray-2.1.0/launcher/injector/preloadinjector.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/launcher/injector/preloadinjector.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -55,12 +55,17 @@ env.insert("GAMMARAY_UNSET_PRELOAD", "1"); PreloadCheck check; - bool success = check.test("qt_startup_hook"); + const bool success = check.test("qt_startup_hook"); +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) // before 5.4 this is fatal, after that we have the built-in hooks and DLL initialization as an even better way if (!success) { mExitCode = 1; mErrorString = check.errorString(); return false; } +#else + Q_UNUSED(success); +#endif + #endif return launchProcess(programAndArgs, env); diff -Nru gammaray-2.1.0/launcher/injector/processinjector.cpp gammaray-2.2.0-0ubuntu0/launcher/injector/processinjector.cpp --- gammaray-2.1.0/launcher/injector/processinjector.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/launcher/injector/processinjector.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -55,6 +55,12 @@ newArgs << "--args"; newArgs += args; args = newArgs; + } else if (env.contains("GAMMARAY_GDBSERVER")) { + QStringList newArgs; + newArgs << "gdbserver" + << env.value("GAMMARAY_GDBSERVER"); + newArgs += args; + args = newArgs; } else if (env.value("GAMMARAY_MEMCHECK").toInt()) { QStringList newArgs; newArgs << "valgrind" diff -Nru gammaray-2.1.0/launcher/injector/windllinjector.cpp gammaray-2.2.0-0ubuntu0/launcher/injector/windllinjector.cpp --- gammaray-2.1.0/launcher/injector/windllinjector.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/launcher/injector/windllinjector.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -33,11 +33,11 @@ using namespace GammaRay; WinDllInjector::WinDllInjector() : - m_destProcess(NULL), - m_destThread(NULL), mExitCode(-1), mProcessError(QProcess::UnknownError), - mExitStatus(QProcess::NormalExit) + mExitStatus(QProcess::NormalExit), + m_destProcess(NULL), + m_destThread(NULL) { } diff -Nru gammaray-2.1.0/launcher/ui/launcherwindow.cpp gammaray-2.2.0-0ubuntu0/launcher/ui/launcherwindow.cpp --- gammaray-2.1.0/launcher/ui/launcherwindow.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/launcher/ui/launcherwindow.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -23,9 +23,10 @@ #include "launcherwindow.h" #include "ui_launcherwindow.h" -#include "config-gammaray-version.h" #include "launchoptions.h" +#include + #include #include @@ -35,7 +36,7 @@ : QDialog(parent), ui(new Ui::LauncherWindow) { ui->setupUi(this); - ui->aboutLabel->setText(ui->aboutLabel->text().arg(GAMMARAY_VERSION_STRING)); + ui->aboutLabel->setText(AboutData::aboutText()); connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChanged())); connect(ui->attachPage, SIGNAL(updateButtonState()), SLOT(tabChanged())); connect(ui->launchPage, SIGNAL(updateButtonState()), SLOT(tabChanged())); diff -Nru gammaray-2.1.0/launcher/ui/launcherwindow.ui gammaray-2.2.0-0ubuntu0/launcher/ui/launcherwindow.ui --- gammaray-2.1.0/launcher/ui/launcherwindow.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/launcher/ui/launcherwindow.ui 2014-10-15 20:32:49.000000000 +0000 @@ -90,7 +90,7 @@ - <html><head/><body><p><span style=" font-weight:600;">GammaRay %1</span></p><p>The Qt application inspection and manipulation tool. Learn more at <a href="http://www.kdab.com/gammaray"><span style=" text-decoration: underline; color:#0057ae;">http://www.kdab.com/gammaray</span></a>.</p><p>Copyright (C) 2010-2014 Klarälvdalens Datakonsult AB, a KDAB Group company, <a href="mailto:info@kdab.com"><span style=" text-decoration: underline; color:#0057ae;">info@kdab.com</span></a></p><p><span style=" text-decoration: underline;">Authors:</span><br/>Allen Winter &lt;allen.winter@kdab.com&gt;<br/>Andreas Holzammer &lt;andreas.holzammer@kdab.com&gt;<br/>David Faure &lt;david.faure@kdab.com&gt;<br/>Kevin Funk &lt;kevin.funk@kdab.com&gt;<br/>Milian Wolff &lt;milian.wolff@kdab.com&gt;<br/>Patrick Spendrin &lt;patrick.spendrin@kdab.com&gt;<br/>Stephen Kelly &lt;stephen.kelly@kdab.com&gt;<br/>Till Adam &lt;till@kdab.com&gt;<br/>Thomas McGuire &lt;thomas.mcguire@kdab.com&gt;<br/>Tobias Koenig &lt;tobias.koenig@kdab.com&gt;<br/>Volker Krause &lt;volker.krause@kdab.com&gt;</p><p>StackWalker code Copyright (c) 2005-2009, Jochen Kalmbach, All rights reserved</p></body></html> + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop diff -Nru gammaray-2.1.0/plugins/actioninspector/actionmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/actioninspector/actionmodel.cpp --- gammaray-2.1.0/plugins/actioninspector/actionmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/actioninspector/actionmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -29,6 +29,8 @@ #include #include +Q_DECLARE_METATYPE(QAction::Priority) + using namespace GammaRay; template @@ -52,6 +54,8 @@ SLOT(handleRowsRemoved(QModelIndex,int,int))); connect(this, SIGNAL(modelReset()), SLOT(handleModelReset())); + + m_duplicateFinder->setActions(actions()); } ActionModel::~ActionModel() @@ -69,7 +73,7 @@ QList ActionModel::actions(const QModelIndex &parent, int start, int end) { QList actions; - for (int i = start; i < end; ++i) { + for (int i = start; i <= end; ++i) { const QModelIndex modelIndex = index(i, 0, parent); actions << actionForIndex(modelIndex); } @@ -163,7 +167,7 @@ case CheckedPropColumn: return VariantHandler::displayString(action->isChecked()); case PriorityPropColumn: - return VariantHandler::displayString(action->priority()); + return Util::enumToString(action->priority(), 0, action); case ShortcutsPropColumn: return toString(action->shortcuts()); default: diff -Nru gammaray-2.1.0/plugins/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/CMakeLists.txt --- gammaray-2.1.0/plugins/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -4,10 +4,15 @@ add_subdirectory(objectvisualizer) add_subdirectory(quickinspector) add_subdirectory(selectionmodelinspector) +add_subdirectory(signalmonitor) add_subdirectory(statemachineviewer) add_subdirectory(timertop) add_subdirectory(webinspector) +if(Qt5Core_FOUND) + add_subdirectory(translatorinspector) +endif() + if(Qt5Widgets_FOUND OR QT_QTGUI_FOUND) add_subdirectory(actioninspector) add_subdirectory(widgetinspector) diff -Nru gammaray-2.1.0/plugins/kjobtracker/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/kjobtracker/CMakeLists.txt --- gammaray-2.1.0/plugins/kjobtracker/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/kjobtracker/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -20,7 +20,6 @@ ) endif() - # probe part if(KDE4_FOUND OR KF5CoreAddons_FOUND) include_directories(${KDE4_INCLUDES}) @@ -36,7 +35,7 @@ ${gammaray_kjob_plugin_srcs} ) - if (KDE4_FOUND) + if(KDE4_FOUND) target_link_libraries(gammaray_kjobtracker_plugin ${KDE4_KDECORE_LIBS} gammaray_core diff -Nru gammaray-2.1.0/plugins/qmlsupport/qmlsupport.cpp gammaray-2.2.0-0ubuntu0/plugins/qmlsupport/qmlsupport.cpp --- gammaray-2.1.0/plugins/qmlsupport/qmlsupport.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/qmlsupport/qmlsupport.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -26,10 +26,13 @@ #include #include #include +#include +#include #include #include #include +#include Q_DECLARE_METATYPE(QQmlError) @@ -44,6 +47,25 @@ .arg(error.description()); } +static QString qmlListPropertyToString(const QVariant &value, bool *ok) +{ + if (qstrncmp(value.typeName(), "QQmlListProperty<", 17) != 0 || !value.isValid()) + return QString(); + + *ok = true; + QQmlListProperty *prop = reinterpret_cast*>(const_cast(value.data())); + const int count = prop->count(prop); + if (!count) + return QObject::tr(""); + + QStringList l; + l.reserve(count); + for (int i = 0; i < prop->count(prop); ++i) { + l.push_back(Util::displayString(prop->at(prop, i))); + } + return l.join(QLatin1String(", ")); +} + QmlSupport::QmlSupport(GammaRay::ProbeInterface* probe, QObject* parent) : QObject(parent) { @@ -72,6 +94,7 @@ MO_ADD_PROPERTY_RO(QQmlEngine, QQmlContext*, rootContext); VariantHandler::registerStringConverter(qmlErrorToString); + VariantHandler::registerGenericStringConverter(qmlListPropertyToString); } QString QmlSupportFactory::name() const diff -Nru gammaray-2.1.0/plugins/quickinspector/annotatedscenepreview.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/annotatedscenepreview.cpp --- gammaray-2.1.0/plugins/quickinspector/annotatedscenepreview.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/annotatedscenepreview.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -56,6 +56,7 @@ p->setTransform(QTransform::fromTranslate(m_margin.width() / 2, m_margin.height() / 2)); p->fillRect(QRect(QPoint(0, 0), m_image.size() * m_zoom), Qt::white); + p->setRenderHint(QPainter::SmoothPixmapTransform); p->drawImage(QRect(QPoint(0, 0), m_image.size() * m_zoom), m_image.transformed(QTransform::fromScale(1, -1))); diff -Nru gammaray-2.1.0/plugins/quickinspector/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/quickinspector/CMakeLists.txt --- gammaray-2.1.0/plugins/quickinspector/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -8,12 +8,13 @@ # shared stuff set(gammaray_quickinspector_shared_srcs quickinspectorinterface.cpp + transferimage.cpp materialextension/materialextensioninterface.cpp geometryextension/sggeometryextensioninterface.cpp ) add_library(gammaray_quickinspector_shared STATIC ${gammaray_quickinspector_shared_srcs}) - target_link_libraries(gammaray_quickinspector_shared gammaray_common) + target_link_libraries(gammaray_quickinspector_shared gammaray_common Qt5::Gui) set_target_properties(gammaray_quickinspector_shared PROPERTIES POSITION_INDEPENDENT_CODE ON) include_directories(${Qt5Quick_PRIVATE_INCLUDE_DIRS}) diff -Nru gammaray-2.1.0/plugins/quickinspector/geometryextension/sggeometrymodel.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/geometryextension/sggeometrymodel.cpp --- gammaray-2.1.0/plugins/quickinspector/geometryextension/sggeometrymodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/geometryextension/sggeometrymodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -90,7 +90,7 @@ return toStringList(index.internalPointer(), attrInfo->tupleSize).join(", "); case GL_FLOAT: return toStringList(index.internalPointer(), attrInfo->tupleSize).join(", "); -#if GL_DOUBLE != GL_FLOAT +#if defined(GL_DOUBLE) && GL_DOUBLE != GL_FLOAT case GL_DOUBLE: return toStringList(index.internalPointer(), attrInfo->tupleSize).join(", "); #endif @@ -130,7 +130,7 @@ return toVariantList(index.internalPointer(), attrInfo->tupleSize); case GL_FLOAT: return toVariantList(index.internalPointer(), attrInfo->tupleSize); -#if GL_DOUBLE != GL_FLOAT +#if defined(GL_DOUBLE) && GL_DOUBLE != GL_FLOAT case GL_DOUBLE: return toVariantList(index.internalPointer(), attrInfo->tupleSize); #endif @@ -214,7 +214,7 @@ case GL_FLOAT: tupleItemSize = sizeof(float); break; -#if GL_DOUBLE != GL_FLOAT +#if defined(GL_DOUBLE) && GL_DOUBLE != GL_FLOAT case GL_DOUBLE: tupleItemSize = sizeof(double); break; diff -Nru gammaray-2.1.0/plugins/quickinspector/geometryextension/sgwireframewidget.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/geometryextension/sgwireframewidget.h --- gammaray-2.1.0/plugins/quickinspector/geometryextension/sgwireframewidget.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/geometryextension/sgwireframewidget.h 2014-10-15 20:32:49.000000000 +0000 @@ -25,12 +25,7 @@ #define GAMMARAY_QUICKINSPECTOR_SGWIREFRAMEWIDGET_H #include - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#else -#include -#endif class QItemSelection; class QPainter; diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialextension.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextension.cpp --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialextension.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextension.cpp 2014-10-15 20:33:15.000000000 +0000 @@ -22,14 +22,24 @@ */ #include "materialextension.h" + +#include #include +#include +#include + #include +#include #include #include +#include +#include +#include #include "config-gammaray.h" #include //krazy:exclude=camelcase +#include using namespace GammaRay; @@ -45,31 +55,58 @@ MaterialExtension::MaterialExtension(PropertyController *controller) : MaterialExtensionInterface(controller->objectBaseName() + ".material", controller), PropertyControllerExtension(controller->objectBaseName() + ".material"), - m_node(0) + m_node(0), + m_materialPropertyModel(new MetaPropertyModel(this)), + m_shaderModel(new QStandardItemModel(this)) { + controller->registerModel(m_materialPropertyModel, "materialPropertyModel"); + controller->registerModel(m_shaderModel, "shaderModel"); } MaterialExtension::~MaterialExtension() { } +#include + +static const char* typeForMaterial(QSGMaterial *material) +{ + std::cerr << typeid(*material).name() << std::endl; +#define MT(type) if (dynamic_cast(material)) return #type; + MT(QSGFlatColorMaterial) + MT(QSGTextureMaterial) + MT(QSGOpaqueTextureMaterial) + MT(QSGVertexColorMaterial) +#undef MT + return "QSGMaterial"; +} + bool MaterialExtension::setObject(void *object, const QString &typeName) { if (typeName == "QSGGeometryNode") { m_node = static_cast(object); + m_materialPropertyModel->setObject(m_node->material(), typeForMaterial(m_node->material())); + QSGMaterialShader *materialShader = m_node->material()->createShader(); SGMaterialShaderThief *thief = reinterpret_cast(materialShader); - QHash shaderSources = thief->getShaderSources(); + const QHash shaderSources = thief->getShaderSources(); - QStringList sourceFiles; - foreach (const QStringList &fileList, shaderSources) { - sourceFiles << fileList; + m_shaderModel->clear(); + m_shaderModel->setHorizontalHeaderLabels(QStringList() << "Shader"); + for (auto it = shaderSources.constBegin(); it != shaderSources.constEnd(); ++it) { + foreach (const QString &source, it.value()) { + auto *item = new QStandardItem(source); + item->setEditable(false); + item->setToolTip(tr("Shader type: %1").arg(VariantHandler::displayString(it.key()))); + m_shaderModel->appendRow(item); + } } - emit shaderListChanged(sourceFiles); return true; } + + m_materialPropertyModel->setObject(0); return false; } diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialextension.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextension.h --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialextension.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextension.h 2014-10-15 20:32:49.000000000 +0000 @@ -28,9 +28,11 @@ #include "materialextensioninterface.h" class QSGGeometryNode; +class QStandardItemModel; namespace GammaRay { +class MetaPropertyModel; class PropertyController; class ObjectEnumModel; @@ -50,6 +52,8 @@ private: QSGGeometryNode *m_node; + MetaPropertyModel *m_materialPropertyModel; + QStandardItemModel *m_shaderModel; }; } diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialextensioninterface.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextensioninterface.h --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialextensioninterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialextensioninterface.h 2014-10-15 20:32:49.000000000 +0000 @@ -39,7 +39,6 @@ const QString &name() const; signals: - void shaderListChanged(const QStringList &materialList); void gotShader(const QString &shaderSource); public slots: diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.cpp --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -36,8 +36,11 @@ { m_ui->setupUi(this); setObjectBaseName(parent->objectBaseName()); - connect(m_ui->shaderList, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(onShaderSelected(QListWidgetItem*))); + connect(m_ui->shaderList->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(shaderSelectionChanged(QItemSelection))); + + m_ui->splitter->setStretchFactor(0, 1); + m_ui->splitter->setStretchFactor(1, 3); } MaterialTab::~MaterialTab() @@ -52,25 +55,21 @@ m_interface = ObjectBroker::object(baseName + ".material"); - connect(m_interface, SIGNAL(shaderListChanged(QStringList)), this, SLOT(setShaders(QStringList))); connect(m_interface, SIGNAL(gotShader(QString)), this, SLOT(showShader(QString))); -} -void MaterialTab::setShaders(const QStringList &shaderSources) -{ - m_shaderSources = shaderSources; - m_ui->shaderEdit->setText(""); - m_ui->shaderList->clear(); - if (shaderSources.size() > 0) { - foreach (const QString &fileName, shaderSources) { - new QListWidgetItem(fileName, m_ui->shaderList); - } - } + m_ui->materialPropertyView->setModel(ObjectBroker::model(baseName + ".materialPropertyModel")); + m_ui->shaderList->setModel(ObjectBroker::model(baseName + ".shaderModel")); } -void MaterialTab::onShaderSelected(QListWidgetItem *item) +void MaterialTab::shaderSelectionChanged(const QItemSelection& selection) { - m_interface->getShader(item->text()); + m_ui->shaderEdit->clear(); + if (selection.isEmpty()) + return; + const QModelIndex index = selection.first().topLeft(); + if (!index.isValid()) + return; + m_interface->getShader(index.data(Qt::DisplayRole).toString()); } void MaterialTab::showShader(const QString &shaderSource) diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.h --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.h 2014-10-15 20:32:49.000000000 +0000 @@ -26,7 +26,7 @@ #include -class QListWidgetItem; +class QItemSelection; namespace GammaRay { @@ -46,14 +46,12 @@ void setObjectBaseName(const QString &baseName); private slots: - void setShaders(const QStringList &shaderSources); - void onShaderSelected(QListWidgetItem *item); + void shaderSelectionChanged(const QItemSelection &selection); void showShader(const QString &shaderSource); private: - Ui_MaterialTab *m_ui; + QScopedPointer m_ui; MaterialExtensionInterface *m_interface; - QStringList m_shaderSources; }; } diff -Nru gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.ui gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.ui --- gammaray-2.1.0/plugins/quickinspector/materialextension/materialtab.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/materialextension/materialtab.ui 2014-10-15 20:32:49.000000000 +0000 @@ -10,22 +10,50 @@ 362 - + - - - - 0 - 0 - + + + Qt::Vertical - - - - - - true + + false + + + false + + + + + + + + + 0 + 0 + + + + false + + + true + + + true + + + + + + + true + + + + + diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorclient.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorclient.cpp --- gammaray-2.1.0/plugins/quickinspector/quickinspectorclient.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorclient.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -99,3 +99,8 @@ { Endpoint::instance()->invokeObject(objectName(), "checkFeatures"); } + +void QuickInspectorClient::setSceneViewActive(bool active) +{ + Endpoint::instance()->invokeObject(objectName(), "setSceneViewActive", QVariantList() << QVariant::fromValue(active)); +} diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorclient.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorclient.h --- gammaray-2.1.0/plugins/quickinspector/quickinspectorclient.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorclient.h 2014-10-15 20:32:49.000000000 +0000 @@ -40,21 +40,23 @@ ~QuickInspectorClient(); public slots: - void selectWindow(int index); - void renderScene(); + void selectWindow(int index) Q_DECL_OVERRIDE; + void renderScene() Q_DECL_OVERRIDE; void sendKeyEvent(int type, int key, int modifiers, const QString &text, - bool autorep, ushort count); + bool autorep, ushort count) Q_DECL_OVERRIDE; void sendMouseEvent(int type, const QPointF &localPos, - int button, int buttons, int modifiers); + int button, int buttons, int modifiers) Q_DECL_OVERRIDE; void sendWheelEvent(const QPointF &localPos, QPoint pixelDelta, - QPoint angleDelta, int buttons, int modifiers); + QPoint angleDelta, int buttons, int modifiers) Q_DECL_OVERRIDE; - void setCustomRenderMode(GammaRay::QuickInspectorInterface::RenderMode customRenderMode); + void setCustomRenderMode(GammaRay::QuickInspectorInterface::RenderMode customRenderMode) Q_DECL_OVERRIDE; - void checkFeatures(); + void checkFeatures() Q_DECL_OVERRIDE; + + void setSceneViewActive(bool active) Q_DECL_OVERRIDE; }; } diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspector.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspector.cpp --- gammaray-2.1.0/plugins/quickinspector/quickinspector.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspector.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -24,6 +24,7 @@ #include "quickinspector.h" #include "quickitemmodel.h" #include "quickscenegraphmodel.h" +#include "transferimage.h" #include "geometryextension/sggeometryextension.h" #include "materialextension/materialextension.h" @@ -54,6 +55,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -78,6 +82,9 @@ Q_DECLARE_METATYPE(const QSGClipNode *) Q_DECLARE_METATYPE(const QSGGeometry *) Q_DECLARE_METATYPE(QSGMaterial *) +Q_DECLARE_METATYPE(QSGMaterial::Flags) +Q_DECLARE_METATYPE(QSGTexture::WrapMode) +Q_DECLARE_METATYPE(QSGTexture::Filtering) using namespace GammaRay; static QString qSGNodeFlagsToString(QSGNode::Flags flags) @@ -98,6 +105,8 @@ if (flags & QSGNode::OwnsOpaqueMaterial) { list << "OwnsOpaqueMaterial"; } + if (list.isEmpty()) + return ""; return list.join(" | "); } static QString qSGNodeDirtyStateToString(QSGNode::DirtyState flags) @@ -135,9 +144,46 @@ if (flags & QSGNode::DirtyPropagationMask) { list << "DirtyPropagationMask"; } + if (list.isEmpty()) + return "Clean"; return list.join(" | "); } +static QString qsgMaterialFlagsToString(QSGMaterial::Flags flags) +{ + QStringList list; +#define F(f) if (flags & QSGMaterial::f) list.push_back(#f); + F(Blending) + F(RequiresDeterminant) + F(RequiresFullMatrixExceptTranslate) + F(RequiresFullMatrix) + F(CustomCompileStep) +#undef F + + if (list.isEmpty()) + return ""; + return list.join(" | "); +} + +static QString qsgTextureFilteringToString(QSGTexture::Filtering filtering) +{ + switch (filtering) { + case QSGTexture::None: return "None"; + case QSGTexture::Nearest: return "Nearest"; + case QSGTexture::Linear: return "Linear"; + } + return QString("Unknown: %1").arg(filtering); +} + +static QString qsgTextureWrapModeToString(QSGTexture::WrapMode wrapMode) +{ + switch (wrapMode) { + case QSGTexture::Repeat: return "Repeat"; + case QSGTexture::ClampToEdge: return "ClampToEdge"; + } + return QString("Unknown: %1").arg(wrapMode); +} + QuickInspector::QuickInspector(ProbeInterface *probe, QObject *parent) : QuickInspectorInterface(parent), m_source(0), @@ -147,7 +193,8 @@ m_sgModel(new QuickSceneGraphModel(this)), m_itemPropertyController(new PropertyController("com.kdab.GammaRay.QuickItem", this)), m_sgPropertyController(new PropertyController("com.kdab.GammaRay.QuickSceneGraph", this)), - m_clientConnected(false) + m_clientViewActive(false), + m_needsNewFrame(false) { registerPCExtensions(); Server::instance()->registerMonitorNotifier( @@ -224,9 +271,7 @@ m_source->setScale(0); // The item shouldn't be visible in the original scene, but it still // needs to be rendered. (i.e. setVisible(false) would cause it to // not be rendered anymore) - m_source->setRecursive(true); - m_source->setSourceItem(contentItem); - + setupPreviewSource(); connect(window, &QQuickWindow::afterRendering, this, &QuickInspector::slotSceneChanged, Qt::DirectConnection); @@ -234,6 +279,19 @@ } } +void QuickInspector::setupPreviewSource() +{ + Q_ASSERT(m_window); + QQuickItem *contentItem = m_window->contentItem(); + const QList children = contentItem->childItems(); + if (children.size() == 2) { // prefer non-recursive shader sources, then we don't re-render all the time + m_source->setSourceItem(children.at(children.indexOf(m_source) == 1 ? 0 : 1)); + } else { + m_source->setRecursive(true); + m_source->setSourceItem(contentItem); + } +} + void QuickInspector::selectItem(QQuickItem *item) { const QAbstractItemModel *model = m_itemModel; @@ -289,12 +347,18 @@ void QuickInspector::renderScene() { - if (!m_clientConnected || !m_window) { + if (!m_clientViewActive || !m_window) { return; } + m_needsNewFrame = true; + m_window->update(); +} + +void QuickInspector::sendRenderedScene() +{ QVariantMap previewData; - previewData.insert("image", QVariant::fromValue(m_currentFrame)); + previewData.insert("rawImage", QVariant::fromValue(TransferImage(m_currentFrame))); // wrap to allow bypassing expensive PNG compression if (m_currentItem) { QQuickItem *parent = m_currentItem->parentItem(); @@ -355,16 +419,26 @@ void QuickInspector::slotSceneChanged() { - if (!m_clientConnected || !m_window) { + if (!m_clientViewActive || !m_window) { + return; + } + + if (!m_needsNewFrame) { + emit sceneChanged(); return; } const QSGTextureProvider *provider = m_source->textureProvider(); Q_ASSERT(provider); +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) const QQuickShaderEffectTexture *texture = qobject_cast(provider->texture()); Q_ASSERT(texture); +#else + const QSGLayer *texture = qobject_cast(provider->texture()); + Q_ASSERT(texture); +#endif QOpenGLContext *ctx = QQuickItemPrivate::get(m_source)->sceneGraphRenderContext()->openglContext(); @@ -372,13 +446,14 @@ m_currentFrame = texture->toImage(); } - emit sceneChanged(); + m_needsNewFrame = false; + QMetaObject::invokeMethod(this, "sendRenderedScene", Qt::AutoConnection); // we are in the render thread here } void QuickInspector::sendKeyEvent(int type, int key, int modifiers, const QString &text, bool autorep, ushort count) { - if (!m_clientConnected || !m_window) { + if (!m_window) { return; } @@ -394,7 +469,7 @@ void QuickInspector::sendMouseEvent(int type, const QPointF &localPos, int button, int buttons, int modifiers) { - if (!m_clientConnected || !m_window) { + if (!m_window) { return; } @@ -409,7 +484,7 @@ void QuickInspector::sendWheelEvent(const QPointF &localPos, QPoint pixelDelta, QPoint angleDelta, int buttons, int modifiers) { - if (!m_clientConnected || !m_window) { + if (!m_window) { return; } @@ -504,11 +579,21 @@ void QuickInspector::clientConnectedChanged(bool connected) { - m_clientConnected = connected; + if (!connected) + setSceneViewActive(false); +} + +void QuickInspector::setSceneViewActive(bool active) +{ + m_clientViewActive = active; - if (connected && m_window) { + if (active && m_window) { + if (m_source) + setupPreviewSource(); m_window->update(); } + if (!active && m_source) + m_source->setSourceItem(0); // no need to render the screenshot as well if nobody is watching } QQuickItem *QuickInspector::recursiveChiltAt(QQuickItem *parent, const QPointF &pos) const @@ -557,10 +642,23 @@ MO_ADD_PROPERTY_RO(QQuickView, QQmlContext *, rootContext); MO_ADD_PROPERTY_RO(QQuickView, QQuickItem *, rootObject); + MO_ADD_METAOBJECT1(QSGTexture, QObject); + MO_ADD_PROPERTY (QSGTexture, QSGTexture::Filtering, filtering, setFiltering); + MO_ADD_PROPERTY_RO(QSGTexture, bool, hasAlphaChannel); + MO_ADD_PROPERTY_RO(QSGTexture, bool, hasMipmaps); + MO_ADD_PROPERTY (QSGTexture, QSGTexture::WrapMode, horizontalWrapMode, setHorizontalWrapMode); + MO_ADD_PROPERTY_RO(QSGTexture, bool, isAtlasTexture); + MO_ADD_PROPERTY (QSGTexture, QSGTexture::Filtering, mipmapFiltering, setMipmapFiltering); + MO_ADD_PROPERTY_RO(QSGTexture, QRectF, normalizedTextureSubRect); + MO_ADD_PROPERTY_RO(QSGTexture, int, textureId); + MO_ADD_PROPERTY_RO(QSGTexture, QSize, textureSize); + MO_ADD_PROPERTY (QSGTexture, QSGTexture::WrapMode, verticalWrapMode, setVerticalWrapMode); + MO_ADD_METAOBJECT0(QSGNode); MO_ADD_PROPERTY_RO(QSGNode, QSGNode *, parent); MO_ADD_PROPERTY_RO(QSGNode, int, childCount); MO_ADD_PROPERTY_RO(QSGNode, QSGNode::Flags, flags); + MO_ADD_PROPERTY_RO(QSGNode, bool, isSubtreeBlocked); MO_ADD_PROPERTY (QSGNode, QSGNode::DirtyState, dirtyState, markDirty); MO_ADD_METAOBJECT1(QSGBasicGeometryNode, QSGNode); @@ -582,15 +680,30 @@ MO_ADD_PROPERTY_RO(QSGClipNode, const QSGClipNode *, clipList); MO_ADD_METAOBJECT1(QSGTransformNode, QSGNode); -// MO_ADD_PROPERTY (QSGTransformNode, const QMatrix4x4&, matrix, setMatrix); -// MO_ADD_PROPERTY (QSGTransformNode, const QMatrix4x4&, combinedMatrix, setCombinedMatrix); + MO_ADD_PROPERTY (QSGTransformNode, const QMatrix4x4&, matrix, setMatrix); + MO_ADD_PROPERTY (QSGTransformNode, const QMatrix4x4&, combinedMatrix, setCombinedMatrix); MO_ADD_METAOBJECT1(QSGRootNode, QSGNode); MO_ADD_METAOBJECT1(QSGOpacityNode, QSGNode); MO_ADD_PROPERTY (QSGOpacityNode, qreal, opacity, setOpacity); MO_ADD_PROPERTY (QSGOpacityNode, qreal, combinedOpacity, setCombinedOpacity); - MO_ADD_PROPERTY_RO(QSGOpacityNode, bool, isSubtreeBlocked); + + MO_ADD_METAOBJECT0(QSGMaterial); + MO_ADD_PROPERTY_RO(QSGMaterial, QSGMaterial::Flags, flags); + + MO_ADD_METAOBJECT1(QSGFlatColorMaterial, QSGMaterial); + MO_ADD_PROPERTY (QSGFlatColorMaterial, const QColor&, color, setColor); + + MO_ADD_METAOBJECT1(QSGOpaqueTextureMaterial, QSGMaterial); + MO_ADD_PROPERTY (QSGOpaqueTextureMaterial, QSGTexture::Filtering, filtering, setFiltering); + MO_ADD_PROPERTY (QSGOpaqueTextureMaterial, QSGTexture::WrapMode, horizontalWrapMode, setHorizontalWrapMode); + MO_ADD_PROPERTY (QSGOpaqueTextureMaterial, QSGTexture::Filtering, mipmapFiltering, setMipmapFiltering); + MO_ADD_PROPERTY (QSGOpaqueTextureMaterial, QSGTexture*, texture, setTexture); + MO_ADD_PROPERTY (QSGOpaqueTextureMaterial, QSGTexture::WrapMode, verticalWrapMode, setVerticalWrapMode); + MO_ADD_METAOBJECT1(QSGTextureMaterial, QSGOpaqueTextureMaterial); + + MO_ADD_METAOBJECT1(QSGVertexColorMaterial, QSGMaterial); } void QuickInspector::registerVariantHandlers() @@ -599,11 +712,19 @@ VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(Util::addressToString); + VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(Util::addressToString); VariantHandler::registerStringConverter(qSGNodeFlagsToString); VariantHandler::registerStringConverter(qSGNodeDirtyStateToString); + VariantHandler::registerStringConverter(Util::addressToString); + VariantHandler::registerStringConverter(Util::addressToString); + VariantHandler::registerStringConverter(Util::addressToString); + VariantHandler::registerStringConverter(Util::addressToString); + VariantHandler::registerStringConverter(qsgMaterialFlagsToString); + VariantHandler::registerStringConverter(qsgTextureFilteringToString); + VariantHandler::registerStringConverter(qsgTextureWrapModeToString); } void QuickInspector::registerPCExtensions() diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspector.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspector.h --- gammaray-2.1.0/plugins/quickinspector/quickinspector.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspector.h 2014-10-15 20:32:49.000000000 +0000 @@ -60,27 +60,30 @@ public slots: void selectWindow(int index) Q_DECL_OVERRIDE; - void renderScene(); + void renderScene() Q_DECL_OVERRIDE; void sendKeyEvent(int type, int key, int modifiers, const QString &text = QString(), bool autorep = false, - ushort count = 1); + ushort count = 1) Q_DECL_OVERRIDE; void sendMouseEvent(int type, const QPointF &localPos, - int button, int buttons, int modifiers); + int button, int buttons, int modifiers) Q_DECL_OVERRIDE; void sendWheelEvent(const QPointF &localPos, QPoint pixelDelta, - QPoint angleDelta, int buttons, int modifiers); + QPoint angleDelta, int buttons, int modifiers) Q_DECL_OVERRIDE; - void setCustomRenderMode(GammaRay::QuickInspectorInterface::RenderMode customRenderMode); + void setCustomRenderMode(GammaRay::QuickInspectorInterface::RenderMode customRenderMode) Q_DECL_OVERRIDE; - void checkFeatures(); + void checkFeatures() Q_DECL_OVERRIDE; + + void setSceneViewActive(bool active) Q_DECL_OVERRIDE; protected: bool eventFilter(QObject *receiver, QEvent *event) Q_DECL_OVERRIDE; private slots: void slotSceneChanged(); + void sendRenderedScene(); void itemSelectionChanged(const QItemSelection &selection); void sgSelectionChanged(const QItemSelection &selection); void clientConnectedChanged(bool connected); @@ -96,6 +99,7 @@ void registerVariantHandlers(); void registerPCExtensions(); QString findSGNodeType(QSGNode *node) const; + void setupPreviewSource(); QQuickItem *recursiveChiltAt(QQuickItem *parent, const QPointF &pos) const; @@ -111,8 +115,9 @@ QItemSelectionModel *m_sgSelectionModel; PropertyController *m_itemPropertyController; PropertyController *m_sgPropertyController; - bool m_clientConnected; QImage m_currentFrame; + bool m_clientViewActive; + bool m_needsNewFrame; }; class QuickInspectorFactory : public QObject, diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorinterface.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorinterface.cpp --- gammaray-2.1.0/plugins/quickinspector/quickinspectorinterface.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorinterface.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -22,6 +22,8 @@ */ #include "quickinspectorinterface.h" +#include "transferimage.h" + #include #include @@ -61,6 +63,7 @@ ObjectBroker::registerObject(this); qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); + qRegisterMetaTypeStreamOperators(); } QuickInspectorInterface::~QuickInspectorInterface() diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorinterface.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorinterface.h --- gammaray-2.1.0/plugins/quickinspector/quickinspectorinterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorinterface.h 2014-10-15 20:32:49.000000000 +0000 @@ -78,10 +78,12 @@ virtual void checkFeatures() = 0; + virtual void setSceneViewActive(bool active) = 0; + signals: /// Emitted when the view has been newly rendered, for the client to request an update. void sceneChanged(); - void sceneRendered(QVariantMap previewData); + void sceneRendered(const QVariantMap &previewData); void features(GammaRay::QuickInspectorInterface::Features features); }; diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.cpp --- gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -31,6 +31,7 @@ #include "materialextension/materialtab.h" #include "annotatedscenepreview.h" #include "quickitemdelegate.h" +#include "transferimage.h" #include "ui_quickinspectorwidget.h" #include @@ -39,6 +40,7 @@ #include #include +#include #include #include #include @@ -179,7 +181,6 @@ this, SLOT(setFeatures(GammaRay::QuickInspectorInterface::Features))); m_interface->checkFeatures(); - m_interface->renderScene(); } QuickInspectorWidget::~QuickInspectorWidget() @@ -206,7 +207,11 @@ m_waitingForImage = false; if (m_rootItem) { - m_rootItem->setProperty("previewData", previewData); + QVariantMap data(previewData); + const TransferImage transfer = data.value("rawImage").value(); + data.remove("rawImage"); + data.insert("image", QVariant::fromValue(transfer.image())); // unwrap for usage in QML + m_rootItem->setProperty("previewData", data); } if (m_sceneChangedSinceLastRequest) { @@ -268,7 +273,7 @@ ObjectBroker::registerClientObjectFactoryCallback( createMaterialExtension); - PropertyWidget::registerTab("material", QObject::tr("Shaders")); + PropertyWidget::registerTab("material", QObject::tr("Material")); ObjectBroker::registerClientObjectFactoryCallback( createSGGeometryExtension); @@ -276,6 +281,16 @@ PropertyWidget::registerTab("sgGeometry", QObject::tr("Geometry")); } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -Q_EXPORT_PLUGIN(QuickInspectorUiFactory) -#endif +void QuickInspectorWidget::showEvent(QShowEvent* event) +{ + QWidget::showEvent(event); + m_waitingForImage = false; + m_sceneChangedSinceLastRequest = true; + m_interface->setSceneViewActive(true); +} + +void QuickInspectorWidget::hideEvent(QHideEvent* event) +{ + m_interface->setSceneViewActive(false); + QWidget::hideEvent(event); +} diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.h --- gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.h 2014-10-15 20:32:49.000000000 +0000 @@ -53,6 +53,10 @@ explicit QuickInspectorWidget(QWidget *parent = 0); ~QuickInspectorWidget(); + private: + void showEvent(QShowEvent *event); + void hideEvent(QHideEvent *event); + private slots: void sceneChanged(); void sceneRendered(const QVariantMap &previewData); diff -Nru gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.ui gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.ui --- gammaray-2.1.0/plugins/quickinspector/quickinspectorwidget.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickinspectorwidget.ui 2014-10-15 20:32:49.000000000 +0000 @@ -40,6 +40,9 @@ + + 10 + true @@ -57,6 +60,9 @@ + + 10 + true diff -Nru gammaray-2.1.0/plugins/quickinspector/quickscenegraphmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickscenegraphmodel.cpp --- gammaray-2.1.0/plugins/quickinspector/quickscenegraphmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/quickscenegraphmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -154,6 +154,9 @@ m_parentChildMap.clear(); } +// indexForNode() is expensive, so only use it when really needed +#define GET_INDEX if (!hasMyIndex) { myIndex = indexForNode(node); hasMyIndex = true; } + void QuickSceneGraphModel::populateFromNode(QSGNode *node) { if (!node) { @@ -168,7 +171,8 @@ newChildList.append(childNode); } - QModelIndex myIndex = indexForNode(node); + QModelIndex myIndex; // don't call indexForNode(node) here yet, in the common case of few changes we waste a lot of time here + bool hasMyIndex = false; std::sort(newChildList.begin(), newChildList.end()); @@ -177,11 +181,13 @@ while (i != oldChildList.end() && j != newChildList.constEnd()) { if (*i < *j) { // We don't have to do anything but inform the client about the change + GET_INDEX beginRemoveRows(myIndex, childList.size(), childList.size()); endRemoveRows(); emit nodeDeleted(*i); i++; } else if (*i > *j) { // Add to new list and inform the client about the change + GET_INDEX beginInsertRows(myIndex, childList.size(), childList.size()); m_childParentMap.insert(*j, node); childList.append(*j); @@ -198,6 +204,7 @@ } if (i == oldChildList.end() && j != newChildList.constEnd()) { // Add remaining new items to list and inform the client + GET_INDEX beginInsertRows(myIndex, childList.size(), childList.size() + std::distance(j, newChildList.constEnd()) - 1); for (;j != newChildList.constEnd(); j++) { @@ -207,6 +214,7 @@ } endInsertRows(); } else if (i != oldChildList.end()) { // Inform the client about the removed rows + GET_INDEX beginRemoveRows(myIndex, childList.size(), childList.size() + std::distance(i, oldChildList.end()) - 1); endRemoveRows(); @@ -216,6 +224,8 @@ } } +#undef GET_INDEX + void QuickSceneGraphModel::collectItemNodes(QQuickItem *item) { if (!item) { @@ -271,6 +281,9 @@ bool QuickSceneGraphModel::verifyNodeValidity(QSGNode *node) { + if (node == m_rootNode) + return true; + QQuickItem *item = itemForSgNode(node); QSGNode *itemNode = QQuickItemPrivate::get(item)->itemNode(); bool valid = itemNode == node || recursivelyFindChild(itemNode, node); diff -Nru gammaray-2.1.0/plugins/quickinspector/resources/quickpreview.qml gammaray-2.2.0-0ubuntu0/plugins/quickinspector/resources/quickpreview.qml --- gammaray-2.1.0/plugins/quickinspector/resources/quickpreview.qml 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/resources/quickpreview.qml 2014-10-15 20:32:49.000000000 +0000 @@ -30,7 +30,7 @@ id: root source: "image://quicksceneprovider/background" fillMode: Image.Tile - property variant previewData: {} + property alias previewData: image.previewData property bool isFirstFrame: true property bool supportsCustomRenderModes: true @@ -272,7 +272,6 @@ AnnotatedScenePreview { id: image anchors.centerIn: parent - previewData: root.previewData margin { width: root.width; height: root.height } onPreviewDataChanged: { diff -Nru gammaray-2.1.0/plugins/quickinspector/transferimage.cpp gammaray-2.2.0-0ubuntu0/plugins/quickinspector/transferimage.cpp --- gammaray-2.1.0/plugins/quickinspector/transferimage.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/transferimage.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,101 @@ +/* + transferimage.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "transferimage.h" + +#include + +using namespace GammaRay; + +TransferImage::TransferImage() +{ +} + +TransferImage::TransferImage(const QImage& image) : m_image(image) +{ +} + +QImage TransferImage::image() const +{ + return m_image; +} + +void TransferImage::setImage(const QImage& image) +{ + m_image = image; +} + + +QDataStream& operator<<(QDataStream& stream, const GammaRay::TransferImage& image) +{ + static const TransferImage::Format format = TransferImage::RawFormat; + + const QImage &img = image.image(); + stream << (quint32)(format); + switch (format) { + case TransferImage::QImageFormat: + stream << img; + break; + case TransferImage::RawFormat: + { + stream << (quint32)img.format() << (quint32)img.width() << (quint32)img.height(); + for (int i = 0; i < img.height(); ++i) { + stream.device()->write((const char*)img.scanLine(i), img.bytesPerLine()); + } + break; + } + } + + return stream; +} + +QDataStream& operator>>(QDataStream& stream, TransferImage& image) +{ + quint32 i; + stream >> i; + const TransferImage::Format format = static_cast(i); + + switch (format) { + case TransferImage::QImageFormat: + { + QImage img; + stream >> img; + image.setImage(img); + break; + } + case TransferImage::RawFormat: + { + quint32 f, w, h; + stream >> f >> w >> h; + QImage img(w, h, static_cast(f)); + for (int i = 0; i < img.height(); ++i) { + const QByteArray buffer = stream.device()->read(img.bytesPerLine()); + qMemCopy(img.scanLine(i), buffer.constData(), img.bytesPerLine()); + } + image.setImage(img); + break; + } + } + + return stream; +} diff -Nru gammaray-2.1.0/plugins/quickinspector/transferimage.h gammaray-2.2.0-0ubuntu0/plugins/quickinspector/transferimage.h --- gammaray-2.1.0/plugins/quickinspector/transferimage.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/quickinspector/transferimage.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,59 @@ +/* + transferimage.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_TRANSFERIMAGE_H +#define GAMMARAY_TRANSFERIMAGE_H + +#include +#include +#include + +namespace GammaRay { + +/** Wrapper class for a QImage to allow raw data transfer over a QDataStream, bypassing the usuale PNG encoding. */ +class TransferImage +{ +public: + TransferImage(); + explicit TransferImage(const QImage &image); + + QImage image() const; + void setImage(const QImage &image); + + enum Format { + QImageFormat, + RawFormat + }; + +private: + QImage m_image; +}; + +} + +QDataStream& operator<<(QDataStream &stream, const GammaRay::TransferImage &image); +QDataStream& operator>>(QDataStream &stream, GammaRay::TransferImage &image); + +Q_DECLARE_METATYPE(GammaRay::TransferImage) + +#endif // GAMMARAY_TRANSFERIMAGE_H diff -Nru gammaray-2.1.0/plugins/sceneinspector/sceneinspectorwidget.ui gammaray-2.2.0-0ubuntu0/plugins/sceneinspector/sceneinspectorwidget.ui --- gammaray-2.1.0/plugins/sceneinspector/sceneinspectorwidget.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/sceneinspector/sceneinspectorwidget.ui 2014-10-15 20:32:49.000000000 +0000 @@ -30,6 +30,9 @@ + + 10 + true diff -Nru gammaray-2.1.0/plugins/signalmonitor/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/CMakeLists.txt --- gammaray-2.1.0/plugins/signalmonitor/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,50 @@ +# shared part +set(gammaray_signalmonitor_shared_srcs + signalmonitorinterface.cpp + signalmonitorcommon.cpp +) +add_library(gammaray_signalmonitor_shared STATIC ${gammaray_signalmonitor_shared_srcs}) +target_link_libraries(gammaray_signalmonitor_shared LINK_PRIVATE gammaray_common) +set_target_properties(gammaray_signalmonitor_shared PROPERTIES POSITION_INDEPENDENT_CODE ON) + +# probe plugin +set(gammaray_signalmonitor_srcs + signalmonitor.cpp + signalhistorymodel.cpp + relativeclock.cpp +) + +gammaray_add_plugin(gammaray_signalmonitor + gammaray_signalmonitor.desktop + ${gammaray_signalmonitor_srcs} +) + +target_link_libraries(gammaray_signalmonitor + gammaray_core + gammaray_signalmonitor_shared +) +if (Qt5_FOUND) + target_link_libraries(gammaray_signalmonitor Qt5::Gui) +endif () + +# ui plugin +set(gammaray_signalmonitor_ui_srcs + signalhistorydelegate.cpp + signalhistoryview.cpp + signalmonitorwidget.cpp + signalmonitorclient.cpp +) + +qt4_wrap_ui(gammaray_signalmonitor_ui_srcs + signalmonitorwidget.ui +) + +gammaray_add_plugin(gammaray_signalmonitor_ui + gammaray_signalmonitor_ui.desktop + ${gammaray_signalmonitor_ui_srcs} +) + +target_link_libraries(gammaray_signalmonitor_ui + gammaray_ui + gammaray_signalmonitor_shared +) diff -Nru gammaray-2.1.0/plugins/signalmonitor/gammaray_signalmonitor.desktop gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/gammaray_signalmonitor.desktop --- gammaray-2.1.0/plugins/signalmonitor/gammaray_signalmonitor.desktop 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/gammaray_signalmonitor.desktop 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Signals +X-GammaRay-Types="QObject" +X-GammaRay-ServiceTypes=com.kdab.GammaRay.ToolFactory +Exec=gammaray_signalmonitor diff -Nru gammaray-2.1.0/plugins/signalmonitor/gammaray_signalmonitor_ui.desktop gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/gammaray_signalmonitor_ui.desktop --- gammaray-2.1.0/plugins/signalmonitor/gammaray_signalmonitor_ui.desktop 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/gammaray_signalmonitor_ui.desktop 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,4 @@ +[Desktop Entry] +X-GammaRay-Id=gammaray_signalmonitor +X-GammaRay-ServiceTypes=com.kdab.GammaRay.ToolUiFactory +Exec=gammaray_signalmonitor_ui diff -Nru gammaray-2.1.0/plugins/signalmonitor/relativeclock.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/relativeclock.cpp --- gammaray-2.1.0/plugins/signalmonitor/relativeclock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/relativeclock.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,60 @@ +/* + relativeclock.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "relativeclock.h" + +#ifdef Q_OS_LINUX +#include +#include +#endif // Q_OS_LINUX + +#include + +using namespace GammaRay; + +static qint64 appStartTime() +{ +#ifdef Q_OS_LINUX + + // On Linux the application start time can be read by procfs. + const QString &self = QString::fromLatin1("/proc/%1").arg(qApp->applicationPid()); + return QFileInfo(self).lastModified().toMSecsSinceEpoch(); + +#else // !Q_OS_LINUX + + // On other platforms this is a rough estimation if called early. + return QDateTime::currentMSecsSinceEpoch(); + +#endif // !Q_OS_LINUX +} + +const RelativeClock* RelativeClock::sinceAppStart() +{ + static const RelativeClock clock(appStartTime()); + return &clock; +} + +qint64 RelativeClock::currentMSecsSinceEpoch() +{ + return QDateTime::currentMSecsSinceEpoch(); +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/relativeclock.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/relativeclock.h --- gammaray-2.1.0/plugins/signalmonitor/relativeclock.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/relativeclock.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,60 @@ +/* + relativeclock.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_RELATIVECLOCK_H +#define GAMMARAY_RELATIVECLOCK_H + +#include + +namespace GammaRay { + +class RelativeClock +{ + public: + explicit RelativeClock(qint64 offset = currentMSecsSinceEpoch()) + : m_offset(offset) + { + } + + qint64 mSecs() const { return currentMSecsSinceEpoch() - offset(); } + qint64 mSecs(qint64 alignment) const; + + qint64 offset() const { return m_offset; } + static const RelativeClock* sinceAppStart(); + + private: + static qint64 currentMSecsSinceEpoch(); + + private: + const qint64 m_offset; +}; + +inline qint64 RelativeClock::mSecs(qint64 alignment) const +{ + const qint64 t = mSecs(); + return t - t % alignment; +} + +} // namespace GammaRay + +#endif // GAMMARAY_RELATIVECLOCK_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistorydelegate.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorydelegate.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalhistorydelegate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorydelegate.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,183 @@ +/* + signalhistorydelegate.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalhistorydelegate.h" +#include "signalhistorymodel.h" +#include "signalmonitorinterface.h" +#include "signalmonitorcommon.h" + +#include + +#include +#include +#include + +#include + +using namespace GammaRay; + +SignalHistoryDelegate::SignalHistoryDelegate(QObject *parent) + : QStyledItemDelegate(parent) + , m_updateTimer(new QTimer(this)) + , m_visibleOffset(0) + , m_visibleInterval(15000) + , m_totalInterval(0) +{ + connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(onUpdateTimeout())); + m_updateTimer->start(1000 / 25); + onUpdateTimeout(); + + SignalMonitorInterface *iface = ObjectBroker::object(); + connect(iface, SIGNAL(clock(qlonglong)), this, SLOT(onServerClockChanged(qlonglong))); + iface->sendClockUpdates(true); +} + +void SignalHistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyledItemDelegate::paint(painter, option, index); + + const qint64 interval = m_visibleInterval; + const qint64 startTime = m_visibleOffset; + const qint64 endTime = startTime + interval; + + const QAbstractItemModel *const model = index.model(); + const QVector &events = model->data(index, SignalHistoryModel::EventsRole).value >(); + const qint64 t0 = qMax(0LL, model->data(index, SignalHistoryModel::StartTimeRole).value() - startTime); + qint64 t1 = model->data(index, SignalHistoryModel::EndTimeRole).value(); + if (t1 < 0) // still alive + t1 = m_totalInterval; + t1 -= startTime; + const qint64 dt = qMax(0LL, t1) - t0; + + const int x0 = option.rect.x() + 1; + const int y0 = option.rect.y(); + const int dx = option.rect.width() - 2; + const int dy = option.rect.height(); + const int x1 = x0 + dx * t0 / interval; + const int x2 = dx * dt / interval + 1; + + if (t1 >= 0) { + painter->fillRect(x1, y0 + 1, x2, dy - 2, option.palette.window()); + } + + painter->setPen(option.palette.color(QPalette::WindowText)); + + foreach (qint64 ev, events) { + const qint64 ts = SignalHistoryModel::timestamp(ev); + if (ts >= startTime && ts < endTime) { + const int x = x0 + dx * (ts - startTime) / interval; + painter->drawLine(x, y0 + 1, x, y0 + dy - 2); + } + } +} + +QSize SignalHistoryDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &) const +{ + return QSize(0, option.fontMetrics.lineSpacing()); // FIXME: minimum height +} + +void SignalHistoryDelegate::setVisibleInterval(qint64 interval) +{ + if (m_visibleInterval != interval) { + m_visibleInterval = interval; + emit visibleIntervalChanged(m_visibleInterval); + } +} + +void SignalHistoryDelegate::setVisibleOffset(qint64 offset) +{ + setActive(false); + + if (m_visibleOffset != offset) { + m_visibleOffset = offset; + emit visibleOffsetChanged(m_visibleOffset); + } +} + +void SignalHistoryDelegate::onUpdateTimeout() +{ + // move the visible region to show the most recent samples + m_visibleOffset = m_totalInterval - m_visibleInterval; + emit visibleOffsetChanged(m_visibleOffset); +} + +void SignalHistoryDelegate::onServerClockChanged(qint64 msecs) +{ + m_totalInterval = msecs; + emit totalIntervalChanged(); +} + +void SignalHistoryDelegate::setActive(bool active) +{ + if (m_updateTimer->isActive() != active) { + if (active) { + m_updateTimer->start(); + } else { + m_updateTimer->stop(); + } + + emit isActiveChanged(isActive()); + } +} + +bool SignalHistoryDelegate::isActive() const +{ + return m_updateTimer->isActive(); +} + +QString SignalHistoryDelegate::toolTipAt(const QModelIndex &index, int position, int width) +{ + const QAbstractItemModel *const model = index.model(); + const QVector &events = model->data(index, SignalHistoryModel::EventsRole).value >(); + + const qint64 t = m_visibleInterval * position / width + m_visibleOffset; + qint64 dtMin = std::numeric_limits::max(); + int signalIndex = -1; + qint64 signalTimestamp = -1; + + for (int i = 0; i < events.size(); ++i) { + signalTimestamp = SignalHistoryModel::timestamp(events.at(i)); + const qint64 dt = qAbs(signalTimestamp - t); + + if (dt < dtMin) { + signalIndex = SignalHistoryModel::signalIndex(events.at(i)); + dtMin = dt; + } + } + + if (signalIndex < 0) + return QString(); + + const auto signalNames = index.data(SignalHistoryModel::SignalMapRole).value >(); + const auto it = signalNames.constFind(signalIndex); + QString signalName; + // see SignalHistoryModel, we store this with offset 1 to fit unknown ones into an unsigned value + if (signalIndex == 0 || it == signalNames.constEnd() || it.value().isEmpty()) + signalName = tr(""); + else + signalName = it.value(); + + const QString &ts = QLocale().toString(signalTimestamp); + return tr("%1 at %2 ms").arg(signalName, ts); +} + diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistorydelegate.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorydelegate.h --- gammaray-2.1.0/plugins/signalmonitor/signalhistorydelegate.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorydelegate.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,76 @@ +/* + signalhistorydelegate.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALHISTORYDELEGATE_H +#define GAMMARAY_SIGNALHISTORYDELEGATE_H + +#include + +namespace GammaRay { + +class SignalHistoryDelegate : public QStyledItemDelegate +{ + Q_OBJECT + Q_PROPERTY(qint64 visibleInterval READ visibleInterval WRITE setVisibleInterval NOTIFY visibleIntervalChanged) + Q_PROPERTY(qint64 visibleOffset READ visibleOffset NOTIFY setVisibleOffset NOTIFY visibleOffsetChanged) + Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged) + + public: + explicit SignalHistoryDelegate(QObject *parent = 0); + + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + + void setVisibleInterval(qint64 interval); + qint64 visibleInterval() const { return m_visibleInterval; } + + void setVisibleOffset(qint64 offset); + qint64 visibleOffset() const { return m_visibleOffset; } + + qint64 totalInterval() const { return m_totalInterval; } + + void setActive(bool isActive); + bool isActive() const; + + QString toolTipAt(const QModelIndex &index, int position, int width); + + signals: + void visibleIntervalChanged(qint64 value); + void visibleOffsetChanged(qint64 value); + void isActiveChanged(bool value); + void totalIntervalChanged(); + + private slots: + void onUpdateTimeout(); + void onServerClockChanged(qlonglong msecs); + + private: + QTimer *const m_updateTimer; + qint64 m_visibleOffset; + qint64 m_visibleInterval; + qint64 m_totalInterval; +}; + +} // namespace GammaRay + +#endif // GAMMARAY_SIGNALHISTORYDELEGATE_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistorymodel.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorymodel.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalhistorymodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorymodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,256 @@ +/* + signalhistorymodel.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalhistorymodel.h" +#include "relativeclock.h" +#include "signalmonitorcommon.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace GammaRay; + +/// Tries to reuse an already existing instances of \param str by checking +/// a global string pool. If no instance of \param str is interned yet the +/// string will be added to the pool. +template +static T internString(const T &str) +{ + static QSet pool; + + // Check if the pool already contains the string... + const typename QSet::const_iterator it = pool.find(str); + + // ...and return it if possible. + if (it != pool.end()) + return *it; + + // Otherwise add the string to the pool. + pool.insert(str); + return str; +} + +static SignalHistoryModel *s_historyModel = 0; + +static void signal_begin_callback(QObject *caller, int method_index, void **argv) +{ + Q_UNUSED(argv); + if (s_historyModel) { + const int signalIndex = method_index + 1; // offset 1, so unknown signals end up at 0 + QMetaObject::invokeMethod(s_historyModel, "onSignalEmitted", Qt::AutoConnection, Q_ARG(QObject*, caller), Q_ARG(int, signalIndex)); + } +} + + +SignalHistoryModel::SignalHistoryModel(ProbeInterface *probe, QObject *parent) + : QAbstractTableModel(parent) +{ + connect(probe->probe(), SIGNAL(objectCreated(QObject*)), this, SLOT(onObjectAdded(QObject*))); + connect(probe->probe(), SIGNAL(objectDestroyed(QObject*)), this, SLOT(onObjectRemoved(QObject*))); + + QSignalSpyCallbackSet spy = { signal_begin_callback, 0, 0, 0 }; + probe->registerSignalSpyCallbackSet(spy); + + s_historyModel = this; +} + +SignalHistoryModel::~SignalHistoryModel() +{ + s_historyModel = 0; +} + +int SignalHistoryModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + return m_tracedObjects.size(); +} + +int SignalHistoryModel::columnCount(const QModelIndex &) const +{ + return 3; +} + +SignalHistoryModel::Item* SignalHistoryModel::item(const QModelIndex& index) const +{ + if (!index.isValid()) + return 0; + return m_tracedObjects.at(index.row()); +} + +QVariant SignalHistoryModel::data(const QModelIndex &index, int role) const +{ + switch (static_cast(index.column())) { + case ObjectColumn: + if (role == Qt::DisplayRole) + return item(index)->objectName; + if (role == Qt::ToolTipRole) + return item(index)->toolTip; + if (role == Qt::DecorationRole) + return item(index)->decoration; + + break; + + case TypeColumn: + if (role == Qt::DisplayRole) + return item(index)->objectType; + if (role == Qt::ToolTipRole) + return item(index)->toolTip; + + break; + + case EventColumn: + if (role == EventsRole) + return QVariant::fromValue(item(index)->events); + if (role == StartTimeRole) + return item(index)->startTime; + if (role == EndTimeRole) + return item(index)->endTime(); + if (role == SignalMapRole) + return QVariant::fromValue(item(index)->signalNames); + + break; + } + + return QVariant(); +} + +QVariant SignalHistoryModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case ObjectColumn: + return tr("Object"); + case TypeColumn: + return tr("Type"); + case EventColumn: + return tr("Events"); + } + } + + return QVariant(); +} + +QMap< int, QVariant > SignalHistoryModel::itemData(const QModelIndex& index) const +{ + QMap d = QAbstractItemModel::itemData(index); + d.insert(EventsRole, data(index, EventsRole)); + d.insert(StartTimeRole, data(index, StartTimeRole)); + d.insert(EndTimeRole, data(index, EndTimeRole)); + d.insert(SignalMapRole, data(index, SignalMapRole)); + return d; +} + +void SignalHistoryModel::onObjectAdded(QObject* object) +{ + Q_ASSERT(thread() == QThread::currentThread()); + + // blacklist event dispatchers + if (qstrncmp(object->metaObject()->className(), "QPAEventDispatcher", 18) == 0 + || qstrncmp(object->metaObject()->className(), "QGuiEventDispatcher", 19) == 0) + return; + + beginInsertRows(QModelIndex(), m_tracedObjects.size(), m_tracedObjects.size()); + + Item *const data = new Item(object); + m_itemIndex.insert(object, m_tracedObjects.size()); + m_tracedObjects.push_back(data); + + endInsertRows(); +} + +void SignalHistoryModel::onObjectRemoved(QObject* object) +{ + Q_ASSERT(thread() == QThread::currentThread()); + + const auto it = m_itemIndex.find(object); + if (it == m_itemIndex.end()) + return; + const int itemIndex = *it; + m_itemIndex.erase(it); + + Item *data = m_tracedObjects.at(itemIndex); + Q_ASSERT(data->object == object); + data->object = 0; + emit dataChanged(index(itemIndex, EventColumn), index(itemIndex, EventColumn)); +} + +void SignalHistoryModel::onSignalEmitted(QObject *sender, int signalIndex) +{ + Q_ASSERT(thread() == QThread::currentThread()); + const qint64 timestamp = RelativeClock::sinceAppStart()->mSecs(); + + const auto it = m_itemIndex.constFind(sender); + if (it == m_itemIndex.constEnd()) + return; + const int itemIndex = *it; + + Item *data = m_tracedObjects.at(itemIndex); + Q_ASSERT(data->object == sender); + // ensure the item is known + if (signalIndex > 0 && !data->signalNames.contains(signalIndex)) { + // protect dereferencing of sender here + ReadOrWriteLocker lock(Probe::instance()->objectLock()); + if (!Probe::instance()->isValidObject(sender)) + return; + const QByteArray signalName = sender->metaObject()->method(signalIndex - 1) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + .signature(); +#else + .methodSignature(); +#endif + data->signalNames.insert(signalIndex, internString(signalName)); + } + + data->events.push_back((timestamp << 16) | signalIndex); + emit dataChanged(index(itemIndex, EventColumn), index(itemIndex, EventColumn)); +} + + +SignalHistoryModel::Item::Item(QObject *obj) + : object(obj) + , startTime(RelativeClock::sinceAppStart()->mSecs()) +{ + objectName = Util::shortDisplayString(object); + objectType = internString(QByteArray(obj->metaObject()->className())); + toolTip = Util::tooltipForObject(object); + decoration = Util::iconForObject(object).value(); +} + +qint64 SignalHistoryModel::Item::endTime() const +{ + if (object) + return -1; // still alive + if (!events.isEmpty()) + return timestamp(events.size() - 1); + + return startTime; +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistorymodel.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorymodel.h --- gammaray-2.1.0/plugins/signalmonitor/signalhistorymodel.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistorymodel.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,103 @@ +/* + signalhistorymodel.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALHISTORYMODEL_H +#define GAMMARAY_SIGNALHISTORYMODEL_H + +#include + +#include +#include +#include +#include +#include + +namespace GammaRay { + +class ProbeInterface; + +class SignalHistoryModel : public QAbstractTableModel +{ + Q_OBJECT + + private: + struct Item + { + Item(QObject *obj); + + QObject* object; // never dereference, might be invalid! + QHash signalNames; + QString objectName; + QByteArray objectType; + QString toolTip; + QIcon decoration; + QVector events; + const qint64 startTime; // FIXME: make them all methods + qint64 endTime() const; + + qint64 timestamp(int i) const { return SignalHistoryModel::timestamp(events.at(i)); } + int signalIndex(int i) const { return SignalHistoryModel::signalIndex(events.at(i)); } + }; + + public: + enum ColumnId { + ObjectColumn, + TypeColumn, + EventColumn + }; + + enum RoleId { + EventsRole = ObjectModel::UserRole + 1, + StartTimeRole, + EndTimeRole, + SignalMapRole + }; + + explicit SignalHistoryModel(ProbeInterface *probe, QObject *parent = 0); + ~SignalHistoryModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QMap itemData(const QModelIndex &index) const; + + static qint64 timestamp(qint64 ev) { return ev >> 16; } + static int signalIndex(qint64 ev) { return ev & 0xffff; } + + private: + Item *item(const QModelIndex &index) const; + + private slots: + void onObjectAdded(QObject *object); + void onObjectRemoved(QObject *object); + void onSignalEmitted(QObject *sender, int signalIndex); + + private: + QVector m_tracedObjects; + QHash m_itemIndex; +}; + +} // namespace GammaRay + +#endif // GAMMARAY_SIGNALHISTORYMODEL_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistoryview.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistoryview.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalhistoryview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistoryview.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,131 @@ +/* + signalhistoryview.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalhistoryview.h" +#include "signalhistorydelegate.h" +#include "signalhistorymodel.h" + +#include + +#include +#include +#include + +using namespace GammaRay; + +SignalHistoryView::SignalHistoryView(QWidget *parent) + : QTreeView(parent) + , m_eventDelegate(new SignalHistoryDelegate(this)) + , m_eventScrollBar(0) +{ + new DeferredResizeModeSetter(header(), 0, QHeaderView::Interactive); + new DeferredResizeModeSetter(header(), 1, QHeaderView::Interactive); + new DeferredResizeModeSetter(header(), 2, QHeaderView::Stretch); + + setItemDelegateForColumn(SignalHistoryModel::EventColumn, m_eventDelegate); + + connect(m_eventDelegate, SIGNAL(visibleOffsetChanged(qint64)), this, SLOT(eventDelegateChanged())); + connect(m_eventDelegate, SIGNAL(visibleIntervalChanged(qint64)), this, SLOT(eventDelegateChanged())); + connect(m_eventDelegate, SIGNAL(totalIntervalChanged()), this, SLOT(eventDelegateChanged())); +} + +void SignalHistoryView::eventDelegateChanged() +{ + viewport()->update(eventColumnPosition(), 0, eventColumnWidth(), height()); + + if (m_eventScrollBar) { + const bool signalsBlocked = m_eventScrollBar->blockSignals(true); + + // With 31 bits we cover more than 24 days when counting milliseconds. + // That's much more time than this tool can handle. IMHO. + m_eventScrollBar->setMaximum(qMax(m_eventDelegate->totalInterval() - + m_eventDelegate->visibleInterval(), + 0LL)); + + m_eventScrollBar->setSingleStep(m_eventDelegate->visibleInterval() / 10); + m_eventScrollBar->setPageStep(m_eventDelegate->visibleInterval()); + + if (m_eventDelegate->isActive()) { + m_eventScrollBar->setValue(m_eventScrollBar->maximum()); + } + + m_eventScrollBar->blockSignals(signalsBlocked); + } +} + +void SignalHistoryView::setEventScrollBar(QScrollBar *scrollBar) +{ + if (m_eventScrollBar != scrollBar) { + if (m_eventScrollBar) { + disconnect(m_eventScrollBar, 0, this, 0); + } + + m_eventScrollBar = scrollBar; + + if (m_eventScrollBar) { + connect(m_eventScrollBar, SIGNAL(sliderMoved(int)), + this, SLOT(eventScrollBarSliderMoved(int))); + } + } +} + +int SignalHistoryView::eventColumnPosition() const +{ + return columnViewportPosition(SignalHistoryModel::EventColumn); +} + +int SignalHistoryView::eventColumnWidth() const +{ + return columnWidth(SignalHistoryModel::EventColumn); +} + +void SignalHistoryView::eventScrollBarSliderMoved(int value) +{ + m_eventDelegate->setActive(false); + m_eventDelegate->setVisibleOffset(value); +} + +bool SignalHistoryView::viewportEvent(QEvent *event) +{ + if (event->type() == QEvent::ToolTip) { + const QHelpEvent *const help = static_cast(event); + const QModelIndex index = indexAt(help->pos()); + + if (index.isValid() && index.column() == SignalHistoryModel::EventColumn) { + const int x0 = help->pos().x() - eventColumnPosition(); + const int dx = eventColumnWidth(); + const QString &toolTipText = m_eventDelegate->toolTipAt(index, x0, dx); + + if (!toolTipText.isEmpty()) { + QToolTip::showText(help->globalPos(), toolTipText); + } else { + QToolTip::hideText(); + event->ignore(); + } + + return true; + } + } + + return QTreeView::viewportEvent(event); +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalhistoryview.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistoryview.h --- gammaray-2.1.0/plugins/signalmonitor/signalhistoryview.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalhistoryview.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,66 @@ +/* + signalhistoryview.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALHISTORYVIEW_H +#define GAMMARAY_SIGNALHISTORYVIEW_H + +#include + +namespace GammaRay { + +class SignalHistoryDelegate; + +class SignalHistoryView : public QTreeView +{ + Q_OBJECT + Q_PROPERTY(QScrollBar *eventScrollBar READ eventScrollBar WRITE setEventScrollBar NOTIFY eventScrollBarChanged) + Q_PROPERTY(SignalHistoryDelegate *eventDelegate READ eventDelegate FINAL CONSTANT) + + public: + explicit SignalHistoryView(QWidget *parent = 0); + + void setEventScrollBar(QScrollBar *scrollBar); + QScrollBar *eventScrollBar() const { return m_eventScrollBar; } + SignalHistoryDelegate *eventDelegate() const { return m_eventDelegate; } + + int eventColumnPosition() const; + int eventColumnWidth() const; + + signals: + void eventScrollBarChanged(QScrollBar *scrollBar); + + protected: + bool viewportEvent(QEvent *event); + + private slots: + void eventDelegateChanged(); + void eventScrollBarSliderMoved(int value); + + private: + SignalHistoryDelegate *const m_eventDelegate; + QScrollBar *m_eventScrollBar; +}; + +} // namespace GammaRay + +#endif // GAMMARAY_SIGNALHISTORYVIEW_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorclient.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorclient.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorclient.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorclient.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,41 @@ +/* + signalmonitorclient.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitorclient.h" + +#include + +using namespace GammaRay; + +SignalMonitorClient::SignalMonitorClient(QObject* parent): SignalMonitorInterface(parent) +{ +} + +SignalMonitorClient::~SignalMonitorClient() +{ +} + +void SignalMonitorClient::sendClockUpdates(bool enabled) +{ + Endpoint::instance()->invokeObject(objectName(), "sendClockUpdates", QVariantList() << QVariant::fromValue(enabled)); +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorclient.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorclient.h --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorclient.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorclient.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,45 @@ +/* + signalmonitorclient.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITORCLIENT_H +#define GAMMARAY_SIGNALMONITORCLIENT_H + +#include "signalmonitorinterface.h" + +namespace GammaRay { + +class SignalMonitorClient : public SignalMonitorInterface +{ + Q_OBJECT + Q_INTERFACES(GammaRay::SignalMonitorInterface) +public: + explicit SignalMonitorClient(QObject* parent = 0); + ~SignalMonitorClient(); + +public slots: + void sendClockUpdates(bool enabled) /*Q_DECL_OVERRIDE*/; +}; + +} + +#endif // GAMMARAY_SIGNALMONITORCLIENT_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorcommon.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorcommon.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorcommon.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorcommon.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,34 @@ +/* + signalmonitorcommon.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitorcommon.h" + +#include + +using namespace GammaRay; + +void GammaRay::StreamOperators::registerSignalMonitorStreamOperators() +{ + qRegisterMetaTypeStreamOperators >(); + qRegisterMetaTypeStreamOperators >(); +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorcommon.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorcommon.h --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorcommon.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorcommon.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,49 @@ +/* + signalmonitorcommon.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITORCOMMON_H +#define GAMMARAY_SIGNALMONITORCOMMON_H + +#include +#include +#include +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_DECLARE_METATYPE(QVector) + +typedef QHash IntByteArrayHash; +Q_DECLARE_METATYPE(IntByteArrayHash) +#endif + +namespace GammaRay { + +namespace StreamOperators { + +void registerSignalMonitorStreamOperators(); + +} + +} + +#endif // GAMMARAY_SIGNALMONITORCOMMON_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitor.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitor.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalmonitor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitor.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,66 @@ +/* + signalmonitor.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitor.h" +#include "signalhistorymodel.h" +#include "relativeclock.h" +#include "signalmonitorcommon.h" + +#include + +using namespace GammaRay; + +SignalMonitor::SignalMonitor(ProbeInterface *probe, QObject *parent) + : SignalMonitorInterface(parent) +{ + StreamOperators::registerSignalMonitorStreamOperators(); + + SignalHistoryModel *model = new SignalHistoryModel(probe, this); + probe->registerModel("com.kdab.GammaRay.SignalHistoryModel", model); + + m_clock = new QTimer(this); + m_clock->setInterval(1000/25); // update frequency of the delegate, we could slow this down a lot, and let the client interpolate, if necessary + m_clock->setSingleShot(false); + connect(m_clock, SIGNAL(timeout()), this, SLOT(timeout())); +} + +SignalMonitor::~SignalMonitor() +{ +} + +void SignalMonitor::timeout() +{ + emit clock(RelativeClock::sinceAppStart()->mSecs()); +} + +void SignalMonitor::sendClockUpdates(bool enabled) +{ + if (enabled) + m_clock->start(); + else + m_clock->stop(); +} + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_EXPORT_PLUGIN(SignalMonitorFactory) +#endif diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitor.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitor.h --- gammaray-2.1.0/plugins/signalmonitor/signalmonitor.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitor.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,72 @@ +/* + signalmonitor.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITOR_H +#define GAMMARAY_SIGNALMONITOR_H + +#include "signalmonitorinterface.h" + +#include + +class QTimer; + +namespace GammaRay { + +class SignalMonitor : public SignalMonitorInterface +{ + Q_OBJECT + Q_INTERFACES(GammaRay::SignalMonitorInterface) + public: + explicit SignalMonitor(ProbeInterface *probe, QObject *parent = 0); + ~SignalMonitor(); + + public slots: + void sendClockUpdates(bool enabled) /*Q_DECL_OVERRIDE*/; + + private slots: + void timeout(); + + private: + QTimer *m_clock; + +}; + +class SignalMonitorFactory : public QObject, public StandardToolFactory +{ + Q_OBJECT + Q_INTERFACES(GammaRay::ToolFactory) + Q_PLUGIN_METADATA(IID "com.kdab.gammaray.SignalMonitor") + public: + explicit SignalMonitorFactory(QObject *parent = 0) : QObject(parent) + { + } + + virtual inline QString name() const + { + return tr("Signals"); + } +}; + +} // namespace GammaRay + +#endif // GAMMARAY_SIGNALMONITOR_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorinterface.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorinterface.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorinterface.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorinterface.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,37 @@ +/* + signalmonitorinterface.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitorinterface.h" + +#include + +using namespace GammaRay; + +SignalMonitorInterface::SignalMonitorInterface(QObject* parent): QObject(parent) +{ + ObjectBroker::registerObject(this); +} + +SignalMonitorInterface::~SignalMonitorInterface() +{ +} diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorinterface.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorinterface.h --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorinterface.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorinterface.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,49 @@ +/* + signalmonitorinterface.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITORINTERFACE_H +#define GAMMARAY_SIGNALMONITORINTERFACE_H + +#include + +namespace GammaRay { + +class SignalMonitorInterface : public QObject +{ + Q_OBJECT +public: + explicit SignalMonitorInterface(QObject *parent = 0); + ~SignalMonitorInterface(); + +public slots: + virtual void sendClockUpdates(bool enabled) = 0; + +signals: + void clock(qlonglong msecs); +}; + +} + +Q_DECLARE_INTERFACE(GammaRay::SignalMonitorInterface, "com.kdab.GammaRay.SignalMonitorInterface/1.0") + +#endif // GAMMARAY_SIGNALMONITORINTERFACE_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.cpp gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.cpp --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,114 @@ +/* + signalmonitorwidget.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitorwidget.h" +#include "ui_signalmonitorwidget.h" +#include "signalhistorydelegate.h" +#include "signalhistorymodel.h" +#include "signalmonitorclient.h" +#include "signalmonitorcommon.h" + +#include +#include + +#include + +using namespace GammaRay; + +static QObject* signalMonitorClientFactory(const QString&, QObject *parent) +{ + return new SignalMonitorClient(parent); +} + +SignalMonitorWidget::SignalMonitorWidget(QWidget *parent) + : QWidget(parent) + , ui(new Ui::SignalMonitorWidget) +{ + StreamOperators::registerSignalMonitorStreamOperators(); + + ObjectBroker::registerClientObjectFactoryCallback(signalMonitorClientFactory); + + ui->setupUi(this); + + QAbstractItemModel *const signalHistory = ObjectBroker::model("com.kdab.GammaRay.SignalHistoryModel"); + + QSortFilterProxyModel *const searchProxy = new KRecursiveFilterProxyModel(this); + searchProxy->setSourceModel(signalHistory); + searchProxy->setDynamicSortFilter(true); + ui->objectSearchLine->setProxy(searchProxy); + + ui->objectTreeView->setModel(searchProxy); + + //ui->objectTreeView->setSelectionModel(ObjectBroker::selectionModel(ui->objectTreeView->model())); + ui->objectTreeView->setEventScrollBar(ui->eventScrollBar); + + connect(ui->pauseButton, SIGNAL(toggled(bool)), this, SLOT(pauseAndResume(bool))); + connect(ui->intervalScale, SIGNAL(valueChanged(int)), this, SLOT(intervalScaleValueChanged(int))); + connect(ui->objectTreeView->eventDelegate(), SIGNAL(isActiveChanged(bool)), this, SLOT(eventDelegateIsActiveChanged(bool))); + connect(ui->objectTreeView->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(adjustEventScrollBarSize())); +} + +SignalMonitorWidget::~SignalMonitorWidget() +{ +} + +void SignalMonitorWidget::intervalScaleValueChanged(int value) +{ + // FIXME: Define a more reasonable formula. + qint64 i = 5000 / std::pow(1.07, value); + ui->objectTreeView->eventDelegate()->setVisibleInterval(i); +} + +void SignalMonitorWidget::adjustEventScrollBarSize() +{ + // FIXME: Would like to have this in SignalHistoryView, but letting that + // widget manage layouts of this widget would be nasty. Still I also I don't + // feel like hooking a custom scrollbar into QTreeView. Sleeping between a + // rock and a hard place. + const QWidget *const scrollBar = ui->objectTreeView->verticalScrollBar(); + const QWidget *const viewport = ui->objectTreeView->viewport(); + + const int eventColumnLeft = ui->objectTreeView->eventColumnPosition(); + const int scrollBarLeft = scrollBar->mapTo(this, scrollBar->pos()).x(); + const int viewportLeft = viewport->mapTo(this, viewport->pos()).x(); + const int viewportRight = viewportLeft + viewport->width(); + + ui->eventScrollBarLayout->setContentsMargins(eventColumnLeft, + scrollBarLeft - viewportRight, + width() - viewportRight, + 0); +} + +void SignalMonitorWidget::pauseAndResume(bool pause) +{ + ui->objectTreeView->eventDelegate()->setActive(!pause); +} + +void SignalMonitorWidget::eventDelegateIsActiveChanged(bool active) +{ + ui->pauseButton->setChecked(!active); +} + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_EXPORT_PLUGIN(SignalMonitorUiFactory) +#endif diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.h gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.h --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,64 @@ +/* + signalmonitorwidget.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITORWIDGET_H +#define GAMMARAY_SIGNALMONITORWIDGET_H + +#include "ui/tooluifactory.h" + +#include + +namespace GammaRay { + +namespace Ui { + class SignalMonitorWidget; +} + +class SignalMonitorWidget : public QWidget +{ + Q_OBJECT + public: + explicit SignalMonitorWidget(QWidget *parent = 0); + ~SignalMonitorWidget(); + + private slots: + void intervalScaleValueChanged(int value); + void adjustEventScrollBarSize(); + void pauseAndResume(bool pause); + void eventDelegateIsActiveChanged(bool active); + + private: + static const QString ITEM_TYPE_NAME_OBJECT; + QScopedPointer ui; +}; + +class SignalMonitorUiFactory : public QObject, public StandardToolUiFactory +{ + Q_OBJECT + Q_INTERFACES(GammaRay::ToolUiFactory) + Q_PLUGIN_METADATA(IID "com.kdab.gammaray.SignalMonitorUi") +}; + +} // namespace GammaRay + +#endif // GAMMARAY_SIGNALMONITORWIDGET_H diff -Nru gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.ui gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.ui --- gammaray-2.1.0/plugins/signalmonitor/signalmonitorwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/signalmonitor/signalmonitorwidget.ui 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,131 @@ + + + GammaRay::SignalMonitorWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + + + 6 + + + + + + + + Pause + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Zoom Level: + + + + + + + -100 + + + 100 + + + 0 + + + Qt::Horizontal + + + + + + + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::SingleSelection + + + false + + + true + + + + + + + + + + 0 + 0 + + + + true + + + Qt::Horizontal + + + + + + + + + + KFilterProxySearchLine + QWidget +
kde/kfilterproxysearchline.h
+
+ + GammaRay::SignalHistoryView + QTreeView +
signalhistoryview.h
+
+
+ + +
diff -Nru gammaray-2.1.0/plugins/statemachineviewer/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/CMakeLists.txt --- gammaray-2.1.0/plugins/statemachineviewer/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -37,13 +37,27 @@ # gui & client statemachineviewerclient.cpp statemachineview.cpp - statemachineviewerwidget.cpp # this part depends on graphviz gvgraph/gvgraph.cpp gvgraph/gvgraphitems.cpp gvgraph/gvutils.cpp ) +find_package(KDSME CONFIG) +if (KDSME_FOUND AND Qt5Quick_FOUND) + list(APPEND gammaray_statemachineviewer_ui_plugin_srcs + statemachineviewerwidgetng.cpp + ) + list(APPEND gammaray_statemachineviewer_ui_plugin_libs + KDSME::Core + KDSME::View + ) +else() + list(APPEND gammaray_statemachineviewer_ui_plugin_srcs + statemachineviewerwidget.cpp + ) +endif() + include_directories( ${GRAPHVIZ_INCLUDE_DIR} diff -Nru gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerinterface.h gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerinterface.h --- gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerinterface.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerinterface.h 2014-10-15 20:32:49.000000000 +0000 @@ -91,7 +91,8 @@ enum StateType { OtherState, FinalState, - HistoryState, + ShallowHistoryState, + DeepHistoryState, StateMachineState }; diff -Nru gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerserver.cpp gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerserver.cpp --- gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerserver.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerserver.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -45,6 +45,28 @@ using namespace GammaRay; using namespace std; +namespace { + +QString labelForTransition(QAbstractTransition *transition) +{ + const QString objectName = transition->objectName(); + if (!objectName.isEmpty()) { + return objectName; + } + + // Try to get a label for the transition if it is a QSignalTransition. + QSignalTransition *signalTransition = qobject_cast(transition); + if (signalTransition) { + return QString::fromLatin1("%1::%2"). + arg(Util::displayString(signalTransition->senderObject())). + arg(QString::fromLatin1(signalTransition->signal().mid(1))); + } + + return Util::displayString(transition); +} + +} + StateMachineViewerServer::StateMachineViewerServer(ProbeInterface *probe, QObject *parent) : StateMachineViewerInterface(parent), m_stateModel(new StateModel(this)), @@ -318,8 +340,8 @@ StateType type = OtherState; if (qobject_cast(state)) { type = FinalState; - } else if (qobject_cast(state)) { - type = HistoryState; + } else if (auto historyState = qobject_cast(state)) { + type = historyState->historyType() == QHistoryState::ShallowHistory ? ShallowHistoryState : DeepHistoryState; } else if (qobject_cast(state)) { type = StateMachineState; } @@ -345,19 +367,7 @@ addState(sourceState); addState(targetState); - QString label = transition->objectName(); - if (label.isEmpty()) { - // Try to get a label for the transition if it is a QSignalTransition. - QSignalTransition *signalTransition = qobject_cast(transition); - if (signalTransition) { - label = QString::fromLatin1("%1::%2"). - arg(Util::displayString(signalTransition->senderObject())). - arg(QString::fromLatin1(signalTransition->signal().mid(1))); - } else { - label = Util::displayString(transition); - } - } - + const QString label = labelForTransition(transition); emit transitionAdded(TransitionId(transition), StateId(sourceState), StateId(targetState), label); } diff -Nru gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidget.cpp gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidget.cpp --- gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidget.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -340,11 +340,16 @@ m_graph->setNodeAttribute(nodeId, "heigh", "0.15"); m_graph->setNodeAttribute(nodeId, "width", "0.15"); break; - case HistoryState: - m_graph->setNodeAttribute(nodeId, "GammaRayStateType", "history"); + case ShallowHistoryState: + m_graph->setNodeAttribute(nodeId, "GammaRayStateType", "shallowhistory"); m_graph->setNodeAttribute(nodeId, "label", "H"); m_graph->setNodeAttribute(nodeId, "shape", "circle"); break; + case DeepHistoryState: + m_graph->setNodeAttribute(nodeId, "GammaRayStateType", "deephistory"); + m_graph->setNodeAttribute(nodeId, "label", "H*"); + m_graph->setNodeAttribute(nodeId, "shape", "circle"); + break; case StateMachineState: case OtherState: m_graph->setNodeAttribute(nodeId, "GammaRayStateType", "other"); diff -Nru gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidgetng.cpp gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidgetng.cpp --- gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidgetng.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidgetng.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,271 @@ +/* + statemachineviewerwidgetng.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Funk + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "statemachineviewerwidgetng.h" +#include "ui_statemachineviewer.h" + +#include "statemachineviewerclient.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define IF_DEBUG(x) + +using namespace GammaRay; +using namespace KDSME; + +namespace { + +QObject* createStateMachineViewerClient(const QString &/*name*/, QObject *parent) +{ + return new StateMachineViewerClient(parent); +} + +ConfigurationController::Configuration toSmeConfiguration(const StateMachineConfiguration& config, const QHash& map) +{ + ConfigurationController::Configuration result; + foreach (const StateId& id, config) { + result << map[id]; + } + return result; +} + +} + +StateMachineViewerWidgetNG::StateMachineViewerWidgetNG(QWidget* parent, Qt::WindowFlags f) + : QWidget(parent, f) + , m_ui(new Ui::StateMachineViewer) + , m_machine(0) +{ + ObjectBroker::registerClientObjectFactoryCallback(createStateMachineViewerClient); + m_interface = ObjectBroker::object(); + + m_ui->setupUi(this); + + m_ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag); + m_ui->graphicsView->setScene(new QGraphicsScene(this)); + m_ui->graphicsView->setRenderHint(QPainter::Antialiasing); + + QAbstractItemModel *stateMachineModel = ObjectBroker::model("com.kdab.GammaRay.StateMachineModel"); + m_ui->stateMachinesView->setModel(stateMachineModel); + m_ui->stateMachinesView->setSelectionModel(ObjectBroker::selectionModel(stateMachineModel)); + new DeferredResizeModeSetter(m_ui->stateMachinesView->header(), 0, QHeaderView::Stretch); + new DeferredResizeModeSetter(m_ui->stateMachinesView->header(), 1, QHeaderView::ResizeToContents); + new DeferredTreeViewConfiguration(m_ui->stateMachinesView, false); + + QAbstractItemModel *stateModel = ObjectBroker::model("com.kdab.GammaRay.StateModel"); + connect(stateModel, SIGNAL(modelReset()), this, SLOT(stateModelReset())); + + m_ui->singleStateMachineView->setModel(stateModel); + m_ui->singleStateMachineView->setSelectionMode(QAbstractItemView::ExtendedSelection); + new DeferredResizeModeSetter(m_ui->singleStateMachineView->header(), 0, QHeaderView::Stretch); + new DeferredResizeModeSetter(m_ui->singleStateMachineView->header(), 1, QHeaderView::ResizeToContents); + new DeferredTreeViewConfiguration(m_ui->singleStateMachineView, true, false); + + connect(m_ui->depthSpinBox, SIGNAL(valueChanged(int)), m_interface, SLOT(setMaximumDepth(int))); + connect(m_ui->startStopButton, SIGNAL(clicked()), m_interface, SLOT(toggleRunning())); + + // TODO: Re-enable? + //connect(m_ui->exportButton, SIGNAL(clicked()), SLOT(exportAsImage())); + m_ui->exportButton->setDisabled(true); + + m_ui->maxMegaPixelsSpinBox->setValue(maximumMegaPixels()); + connect(m_ui->maxMegaPixelsSpinBox, SIGNAL(valueChanged(int)), SLOT(setMaximumMegaPixels(int))); + + m_currentView = new View(this); + m_stateMachineView = new KDSME::StateMachineView; + m_stateMachineView->setView(m_currentView); + + // FIXME: Do it properly + delete m_ui->graphicsView; + m_ui->verticalSplitter->setChildrenCollapsible(false); + m_ui->verticalSplitter->addWidget(m_stateMachineView); + m_ui->verticalSplitter->setStretchFactor(m_ui->verticalSplitter->indexOf(m_stateMachineView), 3); + + connect(m_interface, SIGNAL(message(QString)), this, SLOT(showMessage(QString))); + connect(m_interface, SIGNAL(stateConfigurationChanged(GammaRay::StateMachineConfiguration)), + this, SLOT(stateConfigurationChanged(GammaRay::StateMachineConfiguration))); + connect(m_interface, SIGNAL(stateAdded(GammaRay::StateId,GammaRay::StateId,bool,QString,GammaRay::StateType,bool)), + this, SLOT(stateAdded(GammaRay::StateId,GammaRay::StateId,bool,QString,GammaRay::StateType,bool))); + connect(m_interface, SIGNAL(transitionAdded(GammaRay::TransitionId,GammaRay::StateId,GammaRay::StateId,QString)), + this, SLOT(transitionAdded(GammaRay::TransitionId,GammaRay::StateId,GammaRay::StateId,QString))); + connect(m_interface, SIGNAL(statusChanged(bool,bool)), this, SLOT(statusChanged(bool,bool))); + connect(m_interface, SIGNAL(transitionTriggered(GammaRay::TransitionId,QString)), + this, SLOT(transitionTriggered(GammaRay::TransitionId,QString))); + + connect(m_interface, SIGNAL(aboutToRepopulateGraph()), this, SLOT(clearGraph())); + connect(m_interface, SIGNAL(graphRepopulated()), this, SLOT(repopulateView())); + + // append actions for the state machine view + StateMachineToolBar* toolBar = new StateMachineToolBar(m_stateMachineView, this); + toolBar->setHidden(true); + addActions(toolBar->actions()); + + m_interface->repopulateGraph(); +} + +StateMachineViewerWidgetNG::~StateMachineViewerWidgetNG() +{ +} + +int StateMachineViewerWidgetNG::maximumMegaPixels() const +{ + return QSettings().value("StateMachineViewerServer/maximumMegaPixels", 10).toInt(); +} + +void StateMachineViewerWidgetNG::setMaximumMegaPixels(int megaPixels) +{ + QSettings().setValue("StateMachineViewerServer/maximumMegaPixels", megaPixels); +} + +void StateMachineViewerWidgetNG::showMessage(const QString& message) +{ + // update log + QPlainTextEdit *plainTextEdit = m_ui->plainTextEdit; + plainTextEdit->appendPlainText(message); + + // auto-scroll hack + QScrollBar *sb = plainTextEdit->verticalScrollBar(); + sb->setValue(sb->maximum()); +} + +void StateMachineViewerWidgetNG::stateConfigurationChanged(const StateMachineConfiguration& config) +{ + m_stateMachineView->configurationController()->setActiveConfiguration(toSmeConfiguration(config, m_idToStateMap)); +} + +void StateMachineViewerWidgetNG::stateAdded(const StateId stateId, const StateId parentId, const bool hasChildren, + const QString& label, const StateType type, const bool connectToInitial) +{ + IF_DEBUG(qDebug() << "stateAdded" << stateId << parentId << label << type); + + if (m_idToStateMap.contains(stateId)) { + return; + } + + State* parentState = m_idToStateMap.value(parentId); + State* state = 0; + if (type == StateMachineState) { + state = m_machine = new StateMachine; + } else if (type == GammaRay::FinalState) { + state = new KDSME::FinalState(parentState); + } else if (type == GammaRay::ShallowHistoryState) { + state = new KDSME::HistoryState(HistoryState::ShallowHistory, parentState); + } else if (type == GammaRay::DeepHistoryState) { + state = new KDSME::HistoryState(HistoryState::DeepHistory, parentState); + } else { + state = new State(parentState); + } + + if (connectToInitial && parentState) { + State* initialState = new PseudoState(PseudoState::InitialState, parentState); + Transition* transition = new Transition(initialState); + transition->setTargetState(state); + } + + Q_ASSERT(state); + state->setLabel(label); + state->setInternalId(stateId); + m_idToStateMap[stateId] = state; +} + +void StateMachineViewerWidgetNG::transitionAdded(const TransitionId transitionId, const StateId sourceId, const StateId targetId, const QString& label) +{ + if (m_idToTransitionMap.contains(transitionId)) + return; + + IF_DEBUG(qDebug() << "transitionAdded" << transitionId << label << sourceId << targetId); + + State* source = m_idToStateMap.value(sourceId); + State* target = m_idToStateMap.value(targetId); + if (!source || !target) { + qDebug() << "Null source or target for transition:" << transitionId; + return; + } + + Transition* transition = new Transition(source); + transition->setTargetState(target); + transition->setLabel(label); + m_idToTransitionMap[transitionId] = transition; +} + +void StateMachineViewerWidgetNG::statusChanged(const bool haveStateMachine, const bool running) +{ + m_stateMachineView->configurationController()->setIsRunning(running); + + if (!running) { + m_ui->startStopButton->setChecked(false); + m_ui->startStopButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); + } else { + m_ui->startStopButton->setChecked(true); + m_ui->startStopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); + } + m_ui->startStopButton->setEnabled(haveStateMachine); +} + +void StateMachineViewerWidgetNG::transitionTriggered(TransitionId transitionId, const QString& label) +{ + m_stateMachineView->configurationController()->setLastTransition(m_idToTransitionMap.value(transitionId)); +} + +void StateMachineViewerWidgetNG::clearGraph() +{ + IF_DEBUG(qDebug() << Q_FUNC_INFO); + + m_currentView->setStateMachine(0); + + m_idToStateMap.clear(); + m_idToTransitionMap.clear(); +} + +void StateMachineViewerWidgetNG::repopulateView() +{ + IF_DEBUG(qDebug() << Q_FUNC_INFO); + + m_currentView->setStateMachine(m_machine); + m_currentView->layout(); + + IF_DEBUG(m_machine->dumpObjectTree();) + + m_stateMachineView->fitInView(); +} + +void StateMachineViewerWidgetNG::stateModelReset() +{ + m_ui->singleStateMachineView->expandAll(); + m_stateMachineView->configurationController()->clear(); +} + diff -Nru gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidgetng.h gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidgetng.h --- gammaray-2.1.0/plugins/statemachineviewer/statemachineviewerwidgetng.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/statemachineviewer/statemachineviewerwidgetng.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,92 @@ +/* + statemachineviewerwidgetng.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Funk + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef STATEMACHINEVIEWERWIDGETNG_H +#define STATEMACHINEVIEWERWIDGETNG_H + +#include +#include "statemachineviewerinterface.h" + +#include + +namespace KDSME { +class State; +class StateMachine; +class StateMachineView; +class Transition; +class View; +} + +namespace GammaRay { +namespace Ui { +class StateMachineViewer; +} + +class StateMachineViewerWidgetNG : public QWidget +{ + Q_OBJECT + +public: + explicit StateMachineViewerWidgetNG(QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~StateMachineViewerWidgetNG(); + +private slots: + void showMessage(const QString &message); + void stateAdded(const GammaRay::StateId stateId, const GammaRay::StateId parentId, const bool hasChildren, + const QString& label, const GammaRay::StateType type, const bool connectToInitial); + void stateConfigurationChanged(const GammaRay::StateMachineConfiguration &config); + void transitionAdded(const GammaRay::TransitionId transitionId, const GammaRay::StateId source, + const GammaRay::StateId target, const QString& label); + void statusChanged(const bool haveStateMachine, const bool running); + void transitionTriggered(GammaRay::TransitionId transition, const QString &label); + void stateModelReset(); + + void repopulateView(); + void clearGraph(); + + void setMaximumMegaPixels(int); + +private: + int maximumMegaPixels() const; + + QScopedPointer m_ui; + + KDSME::StateMachineView* m_stateMachineView; + KDSME::View* m_currentView; + StateMachineViewerInterface *m_interface; + + QHash m_idToStateMap; + QHash m_idToTransitionMap; + KDSME::StateMachine* m_machine; +}; + +class StateMachineViewerUiFactory : public QObject, public StandardToolUiFactory +{ + Q_OBJECT + Q_INTERFACES(GammaRay::ToolUiFactory) + Q_PLUGIN_METADATA(IID "com.kdab.gammaray.StateMachineViewerNGUi") +}; + +} + +#endif // STATEMACHINEVIEWERWIDGETNG_H diff -Nru gammaray-2.1.0/plugins/styleinspector/complexcontrolmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/styleinspector/complexcontrolmodel.cpp --- gammaray-2.1.0/plugins/styleinspector/complexcontrolmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/styleinspector/complexcontrolmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -42,7 +42,7 @@ #define MAKE_CC2( control, factory ) { #control, QStyle:: control, &StyleOption:: factory, 0 } #define MAKE_CC3( control, factory, subControls ) { #control, QStyle:: control, &StyleOption:: factory, subControls } -static complex_control_element_t complexControlElements[] = { +static const complex_control_element_t complexControlElements[] = { MAKE_CC3(CC_SpinBox, makeSpinBoxStyleOption, QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown | QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField), MAKE_CC3(CC_ComboBox, makeComboBoxStyleOption, QStyle::SC_ComboBoxFrame | QStyle::SC_ComboBoxArrow | QStyle::SC_ComboBoxEditField | QStyle::SC_ComboBoxListBoxPopup), MAKE_CC3(CC_ScrollBar, makeSliderStyleOption, QStyle::SC_ScrollBarAddLine | QStyle::SC_ScrollBarSubLine | QStyle::SC_ScrollBarAddPage | QStyle::SC_ScrollBarSubPage | QStyle::SC_ScrollBarFirst | QStyle::SC_ScrollBarLast | QStyle::SC_ScrollBarSlider | QStyle::SC_ScrollBarGroove), diff -Nru gammaray-2.1.0/plugins/styleinspector/controlmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/styleinspector/controlmodel.cpp --- gammaray-2.1.0/plugins/styleinspector/controlmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/styleinspector/controlmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -41,7 +41,7 @@ #define MAKE_CE( control ) { #control , QStyle:: control, &StyleOption::makeStyleOption } #define MAKE_CE_X( control, factory ) { #control, QStyle:: control, &StyleOption:: factory } -static control_element_t controlElements[] = { +static const control_element_t controlElements[] = { MAKE_CE_X(CE_PushButton, makeButtonStyleOption), MAKE_CE_X(CE_PushButtonBevel, makeButtonStyleOption), MAKE_CE_X(CE_PushButtonLabel, makeButtonStyleOption), diff -Nru gammaray-2.1.0/plugins/styleinspector/pixelmetricmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/styleinspector/pixelmetricmodel.cpp --- gammaray-2.1.0/plugins/styleinspector/pixelmetricmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/styleinspector/pixelmetricmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -35,7 +35,7 @@ #define MAKE_PM(metric) { #metric, QStyle:: metric } -static pixel_metric_t pixelMetrics[] = { +static const pixel_metric_t pixelMetrics[] = { MAKE_PM(PM_ButtonMargin), MAKE_PM(PM_ButtonDefaultIndicator), MAKE_PM(PM_MenuButtonIndicator), diff -Nru gammaray-2.1.0/plugins/styleinspector/primitivemodel.cpp gammaray-2.2.0-0ubuntu0/plugins/styleinspector/primitivemodel.cpp --- gammaray-2.1.0/plugins/styleinspector/primitivemodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/styleinspector/primitivemodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -41,7 +41,7 @@ #define MAKE_PE( primitive ) { #primitive , QStyle:: primitive, &StyleOption::makeStyleOption } #define MAKE_PE_X( primitive, factory ) { #primitive, QStyle:: primitive, &StyleOption:: factory } -static primitive_element_t primititveElements[] = { +static const primitive_element_t primititveElements[] = { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) MAKE_PE(PE_Q3CheckListController), MAKE_PE(PE_Q3CheckListExclusiveIndicator), diff -Nru gammaray-2.1.0/plugins/styleinspector/styleoption.cpp gammaray-2.2.0-0ubuntu0/plugins/styleinspector/styleoption.cpp --- gammaray-2.1.0/plugins/styleinspector/styleoption.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/styleinspector/styleoption.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -34,7 +34,7 @@ #define MAKE_STATE( state ) { #state, QStyle:: state } -static style_state_t styleStates[] = { +static const style_state_t styleStates[] = { MAKE_STATE(State_None), MAKE_STATE(State_Enabled), MAKE_STATE(State_Raised), diff -Nru gammaray-2.1.0/plugins/timertop/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/timertop/CMakeLists.txt --- gammaray-2.1.0/plugins/timertop/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -18,6 +18,10 @@ gammaray_core ) +if (LINUX) + target_link_libraries(pthread) +endif() + if(NOT WIN32 AND NOT APPLE) target_link_libraries(gammaray_timertop_plugin rt) endif() @@ -43,7 +47,7 @@ target_link_libraries(gammaray_timertop_ui_plugin ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES} - gammaray_common + gammaray_ui ) endif() diff -Nru gammaray-2.1.0/plugins/timertop/functioncalltimer.cpp gammaray-2.2.0-0ubuntu0/plugins/timertop/functioncalltimer.cpp --- gammaray-2.1.0/plugins/timertop/functioncalltimer.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/functioncalltimer.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -51,7 +51,8 @@ #endif FunctionCallTimer::FunctionCallTimer() - : m_active(false) + : m_startTime() + , m_active(false) { } diff -Nru gammaray-2.1.0/plugins/timertop/gammaray_timertop.desktop gammaray-2.2.0-0ubuntu0/plugins/timertop/gammaray_timertop.desktop --- gammaray-2.1.0/plugins/timertop/gammaray_timertop.desktop 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/gammaray_timertop.desktop 2014-10-15 20:32:49.000000000 +0000 @@ -1,5 +1,5 @@ [Desktop Entry] Name=Timers -X-GammaRay-Types=QTimer; +X-GammaRay-Types="QTimer;QQmlTimer;QUnifiedTimer" X-GammaRay-ServiceTypes=com.kdab.GammaRay.ToolFactory Exec=gammaray_timertop_plugin diff -Nru gammaray-2.1.0/plugins/timertop/timerinfo.cpp gammaray-2.2.0-0ubuntu0/plugins/timertop/timerinfo.cpp --- gammaray-2.1.0/plugins/timertop/timerinfo.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timerinfo.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -31,13 +31,17 @@ static const int maxTimeoutEvents = 1000; static const int maxTimeSpan = 10000; -TimerInfo::TimerInfo(QTimer *timer) - : m_type(QTimerType), +TimerInfo::TimerInfo(QObject* timer) : + m_type(QQmlTimerType), m_totalWakeups(0), m_timer(timer), - m_timerId(timer->timerId()), + m_timerId(-1), m_lastReceiver(0) { + if (QTimer *t = qobject_cast(timer)) { + m_type = QTimerType; + m_timerId = t->timerId(); + } } TimerInfo::TimerInfo(int timerId) @@ -47,6 +51,11 @@ { } +TimerInfo::Type TimerInfo::type() const +{ + return m_type; +} + void TimerInfo::addEvent(const TimeoutEvent &timeoutEvent) { m_timeoutEvents.append(timeoutEvent); @@ -59,11 +68,18 @@ return m_timeoutEvents.size(); } -QTimer *TimerInfo::timer() const +QObject* TimerInfo::timerObject() const { return m_timer; } +QTimer *TimerInfo::timer() const +{ + if (m_type != QTimerType) + return 0; + return qobject_cast(m_timer); +} + int TimerInfo::timerId() const { return m_timerId; @@ -144,19 +160,36 @@ QString TimerInfo::state() const { - if (!m_timer){ - return QObject::tr("None"); - } - - if (!m_timer->isActive()) { - return QObject::tr("Inactive"); - } else { - if (m_timer->isSingleShot()) { - return QObject::tr("Singleshot (%1 ms)").arg(m_timer->interval()); - } else { - return QObject::tr("Repeating (%1 ms)").arg(m_timer->interval()); + switch (type()) { + case QTimerType: + { + const QTimer *t = timer(); + if (!t) + return QObject::tr("None"); + if (!t->isActive()) + return QObject::tr("Inactive"); + if (t->isSingleShot()) + return QObject::tr("Singleshot (%1 ms)").arg(t->interval()); + return QObject::tr("Repeating (%1 ms)").arg(t->interval()); + } + case QQmlTimerType: + { + const QObject *obj = timerObject(); + if (!obj) + return QObject::tr("None"); + const int interval = obj->property("interval").toInt(); + if (!obj->property("running").toBool()) + return QObject::tr("Inactive (%1 ms)").arg(interval); + if (obj->property("repeat").toBool()) + return QObject::tr("Repeating (%1 ms)").arg(interval); + return QObject::tr("Singleshot (%1 ms)").arg(interval); } + case QObjectType: + return "N/A"; } + + Q_ASSERT(false); + return QString(); } void TimerInfo::removeOldEvents() @@ -173,13 +206,18 @@ QString TimerInfo::displayName() const { - if (timer()) { - return Util::displayString(timer()); - } else { - if (m_lastReceiver) { - return Util::displayString(m_lastReceiver); - } else { - return QObject::tr("Unknown QObject"); - } + switch (m_type) { + case QTimerType: + case QQmlTimerType: + return Util::displayString(timerObject()); + case QObjectType: + if (m_lastReceiver) { + return Util::displayString(m_lastReceiver); + } else { + return QObject::tr("Unknown QObject"); + } } + + Q_ASSERT(false); + return QString(); } diff -Nru gammaray-2.1.0/plugins/timertop/timerinfo.h gammaray-2.2.0-0ubuntu0/plugins/timertop/timerinfo.h --- gammaray-2.1.0/plugins/timertop/timerinfo.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timerinfo.h 2014-10-15 20:32:49.000000000 +0000 @@ -38,7 +38,8 @@ public: enum Type { QTimerType, - QObjectType + QObjectType, + QQmlTimerType }; struct TimeoutEvent @@ -47,12 +48,14 @@ int executionTime; }; - explicit TimerInfo(QTimer *timer); + explicit TimerInfo(QObject *timer); explicit TimerInfo(int timerId); + Type type() const; void addEvent(const TimeoutEvent &timeoutEvent); void setLastReceiver(QObject *receiver); int numEvents() const; QTimer *timer() const; + QObject *timerObject() const; int timerId() const; FunctionCallTimer *functionCallTimer(); QString wakeupsPerSec() const; @@ -66,8 +69,8 @@ Type m_type; int m_totalWakeups; - // Only for QTimer timers - QPointer m_timer; + // Only for QTimer/QQmlTimers timers + QPointer m_timer; int m_timerId; FunctionCallTimer m_functionCallTimer; diff -Nru gammaray-2.1.0/plugins/timertop/timermodel.cpp gammaray-2.2.0-0ubuntu0/plugins/timertop/timermodel.cpp --- gammaray-2.1.0/plugins/timertop/timermodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timermodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -23,6 +23,7 @@ #include "timermodel.h" #include +#include #include //krazy:exclude=camelcase @@ -78,8 +79,13 @@ : QAbstractTableModel(parent), m_sourceModel(0), m_probe(0), - m_timeoutIndex(QTimer::staticMetaObject.indexOfSignal("timeout()")) -{ + m_pendingChanedRowsTimer(new QTimer(this)), + m_timeoutIndex(QTimer::staticMetaObject.indexOfSignal("timeout()")), + m_qmlTimerTriggeredIndex(-1) +{ + m_pendingChanedRowsTimer->setInterval(5000); + m_pendingChanedRowsTimer->setSingleShot(true); + connect(m_pendingChanedRowsTimer, SIGNAL(timeout()), this, SLOT(flushEmitPendingChangedRows())); } TimerModel::~TimerModel() @@ -118,7 +124,7 @@ return timerInfo; } -TimerInfoPtr TimerModel::findOrCreateQTimerTimerInfo(QTimer *timer) +TimerInfoPtr TimerModel::findOrCreateQTimerTimerInfo(QObject *timer) { if (!timer) { return TimerInfoPtr(); @@ -126,13 +132,17 @@ QVariant timerInfoVariant = timer->property(timerInfoPropertyName); if (!timerInfoVariant.isValid()) { - timerInfoVariant.setValue(TimerInfoPtr(new TimerInfo(timer))); + const TimerInfoPtr info = TimerInfoPtr(new TimerInfo(timer)); + if (m_qmlTimerTriggeredIndex < 0 && info->type() == TimerInfo::QQmlTimerType) { + m_qmlTimerTriggeredIndex = timer->metaObject()->indexOfMethod("triggered()"); + } + timerInfoVariant.setValue(info); if (timer->thread() == QThread::currentThread()) // ### FIXME: we shouldn't use setProperty() in the first place... timer->setProperty(timerInfoPropertyName, timerInfoVariant); } const TimerInfoPtr timerInfo = timerInfoVariant.value(); - Q_ASSERT(timerInfo->timer() == timer); + Q_ASSERT(timerInfo->timerObject() == timer); return timerInfo; } @@ -155,7 +165,7 @@ if (index.row() < m_sourceModel->rowCount()){ const QModelIndex sourceIndex = m_sourceModel->index(index.row(), 0); QObject *const timerObject = sourceIndex.data(ObjectModel::ObjectRole).value(); - return findOrCreateQTimerTimerInfo(qobject_cast(timerObject)); + return findOrCreateQTimerTimerInfo(timerObject); } else { const int freeListIndex = index.row() - m_sourceModel->rowCount(); Q_ASSERT(freeListIndex >= 0); @@ -166,11 +176,11 @@ return TimerInfoPtr(); } -int TimerModel::rowFor(QTimer *timer) +int TimerModel::rowFor(QObject *timer) { for (int i = 0; i < rowCount(); i++) { const TimerInfoPtr timerInfo = findOrCreateTimerInfo(index(i, 0)); - if (timerInfo && timerInfo->timer() == timer) { + if (timerInfo && timerInfo->timerObject() == timer) { return i; } } @@ -179,16 +189,13 @@ void TimerModel::preSignalActivate(QObject *caller, int methodIndex) { - if (methodIndex != m_timeoutIndex) { - return; - } - - QTimer *timer = qobject_cast(caller); - if (!timer || timer->objectName().toLower().startsWith(QLatin1String("gammaray"))) { + if (!(methodIndex == m_timeoutIndex && qobject_cast(caller)) && + !(methodIndex == m_qmlTimerTriggeredIndex && caller->inherits("QQmlTimer"))) + { return; } - const TimerInfoPtr timerInfo = findOrCreateQTimerTimerInfo(timer); + const TimerInfoPtr timerInfo = findOrCreateQTimerTimerInfo(caller); if (!timerInfo) { // Ok, likely a GammaRay timer @@ -199,7 +206,7 @@ if (!timerInfo->functionCallTimer()->start()) { cout << "TimerModel::preSignalActivate(): Recursive timeout for timer " - << (void*)timer << " (" << timer->objectName().toStdString() << ")!" << endl; + << (void*)caller << " (" << caller->objectName().toStdString() << ")!" << endl; return; } @@ -209,28 +216,31 @@ void TimerModel::postSignalActivate(QObject *caller, int methodIndex) { - if (methodIndex != m_timeoutIndex) { - return; - } QHash::iterator it = m_currentSignals.find(caller); if (it == m_currentSignals.end()) { // Ok, likely a GammaRay timer - //cout << "TimerModel::postSignalActivate(): Unable to find timer " - // << (void*)timer << " (" << timer->objectName().toStdString() << ")!" << endl; + // cout << "TimerModel::postSignalActivate(): Unable to find timer " + // << (void*)caller << " (" << caller->objectName().toStdString() << ")!" << endl; return; } const TimerInfoPtr timerInfo = *it; Q_ASSERT(timerInfo); + if (!(timerInfo->type() == TimerInfo::QTimerType && methodIndex == m_timeoutIndex) && + !(timerInfo->type() == TimerInfo::QQmlTimerType && methodIndex == m_qmlTimerTriggeredIndex)) + { + return; + } + m_currentSignals.erase(it); - if (!timerInfo->timer()) { + if (!timerInfo->timerObject()) { // timer got killed in a slot return; } - Q_ASSERT(static_cast(caller) == timerInfo->timer()); + Q_ASSERT(caller == timerInfo->timerObject()); if (!timerInfo->functionCallTimer()->active()) { cout << "TimerModel::postSignalActivate(): Timer not active: " @@ -242,22 +252,13 @@ event.timeStamp = QTime::currentTime(); event.executionTime = timerInfo->functionCallTimer()->stop(); timerInfo->addEvent(event); - const int row = rowFor(timerInfo->timer()); - if (row != -1) { - emit dataChanged(index(row, 0), index(row, columnCount() - 1)); - } + const int row = rowFor(timerInfo->timerObject()); + emitTimerObjectChanged(row); } void TimerModel::setProbe(ProbeInterface *probe) { m_probe = probe; -} - -void TimerModel::setSourceModel(ObjectTypeFilterProxyModel *sourceModel) -{ - Q_ASSERT(!m_sourceModel); - m_sourceModel = sourceModel; - qApp->installEventFilter(this); QSignalSpyCallbackSet callbacks; callbacks.slot_begin_callback = 0; @@ -265,7 +266,14 @@ callbacks.signal_begin_callback = signal_begin_callback; callbacks.signal_end_callback = signal_end_callback; - qt_register_signal_spy_callbacks(callbacks); + probe->registerSignalSpyCallbackSet(callbacks); +} + +void TimerModel::setSourceModel(QAbstractItemModel *sourceModel) +{ + Q_ASSERT(!m_sourceModel); + m_sourceModel = sourceModel; + qApp->installEventFilter(this); connect(m_sourceModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(slotBeginInsertRows(QModelIndex,int,int))); @@ -370,6 +378,7 @@ timerInfo->addEvent(timeoutEvent); timerInfo->setLastReceiver(watched); + emitFreeTimerChanged(m_freeTimers.indexOf(timerInfo)); } return false; } @@ -377,6 +386,7 @@ void TimerModel::slotBeginRemoveRows(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); + flushEmitPendingChangedRows(); beginRemoveRows(QModelIndex(), start, end); } @@ -388,6 +398,7 @@ void TimerModel::slotBeginInsertRows(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); + flushEmitPendingChangedRows(); beginInsertRows(QModelIndex(), start, end); } @@ -398,6 +409,8 @@ void TimerModel::slotBeginReset() { + m_pendingChangedTimerObjects.clear(); + m_pendingChangedFreeTimers.clear(); beginResetModel(); } @@ -405,3 +418,36 @@ { endResetModel(); } + +void TimerModel::emitTimerObjectChanged(int row) +{ + if (row < 0 || row >= rowCount()) + return; + + m_pendingChangedTimerObjects.insert(row); + if (!m_pendingChanedRowsTimer->isActive()) + m_pendingChanedRowsTimer->start(); +} + +void TimerModel::emitFreeTimerChanged(int row) +{ + if (row < 0 || row >= m_freeTimers.count()) + return; + + m_pendingChangedFreeTimers.insert(row); + if (!m_pendingChanedRowsTimer->isActive()) + m_pendingChanedRowsTimer->start(); +} + +void TimerModel::flushEmitPendingChangedRows() +{ + foreach (int row, m_pendingChangedTimerObjects) { + emit dataChanged(index(row, 0), index(row, LastRole - FirstRole - 2)); + } + m_pendingChangedTimerObjects.clear(); + + foreach (int row, m_pendingChangedFreeTimers) { + emit dataChanged(index(m_sourceModel->rowCount() + row, 0), index(m_sourceModel->rowCount() + row, LastRole - FirstRole - 2)); + } + m_pendingChangedFreeTimers.clear(); +} diff -Nru gammaray-2.1.0/plugins/timertop/timermodel.h gammaray-2.2.0-0ubuntu0/plugins/timertop/timermodel.h --- gammaray-2.1.0/plugins/timertop/timermodel.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timermodel.h 2014-10-15 20:32:49.000000000 +0000 @@ -25,10 +25,10 @@ #include "timerinfo.h" -#include #include #include +#include class QTimer; @@ -66,7 +66,7 @@ /// if set, filters out object owned by the probe void setProbe(ProbeInterface *probe); - void setSourceModel(ObjectTypeFilterProxyModel *sourceModel); + void setSourceModel(QAbstractItemModel *sourceModel); /* reimp */ int columnCount(const QModelIndex &parent = QModelIndex()) const; @@ -90,6 +90,7 @@ void slotEndInsertRows(); void slotBeginReset(); void slotEndReset(); + void flushEmitPendingChangedRows(); private: explicit TimerModel(QObject *parent = 0); @@ -101,20 +102,27 @@ TimerInfoPtr findOrCreateTimerInfo(const QModelIndex &index); // Finds QTimer timers - TimerInfoPtr findOrCreateQTimerTimerInfo(QTimer *timer); + TimerInfoPtr findOrCreateQTimerTimerInfo(QObject* timer); // Finds QObject timers TimerInfoPtr findOrCreateFreeTimerInfo(int timerId); - int rowFor(QTimer *timer) ; + int rowFor(QObject *timer) ; + void emitTimerObjectChanged(int row); + void emitFreeTimerChanged(int row); - ObjectTypeFilterProxyModel *m_sourceModel; + QAbstractItemModel *m_sourceModel; QList m_freeTimers; ProbeInterface *m_probe; // current timer signals that are being processed QHash m_currentSignals; + // pending dataChanged() signals + QSet m_pendingChangedTimerObjects; + QSet m_pendingChangedFreeTimers; + QTimer *m_pendingChanedRowsTimer; // the method index of the timeout() signal of a QTimer const int m_timeoutIndex; + int m_qmlTimerTriggeredIndex; }; } diff -Nru gammaray-2.1.0/plugins/timertop/timertop.cpp gammaray-2.2.0-0ubuntu0/plugins/timertop/timertop.cpp --- gammaray-2.1.0/plugins/timertop/timertop.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timertop.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -25,6 +25,7 @@ #include "timermodel.h" #include +#include #include @@ -57,14 +58,27 @@ // Flash delegate when timer triggered // Color cell in view redish, depending on how active the timer is +class TimerFilterModel : public ObjectTypeFilterProxyModel +{ + public: + explicit TimerFilterModel(QObject *parent) : ObjectTypeFilterProxyModel(parent) {} + + bool filterAcceptsObject(QObject *object) const + { + if (object && object->inherits("QQmlTimer")) + return true; + return ObjectTypeFilterProxyModel::filterAcceptsObject(object); + } +}; + + TimerTop::TimerTop(ProbeInterface *probe, QObject *parent) : QObject(parent), m_updateTimer(new QTimer(this)) { Q_ASSERT(probe); - ObjectTypeFilterProxyModel * const filterModel = - new ObjectTypeFilterProxyModel(this); + QSortFilterProxyModel* const filterModel = new TimerFilterModel(this); filterModel->setDynamicSortFilter(true); filterModel->setSourceModel(probe->objectListModel()); TimerModel::instance()->setParent(this); // otherwise it's not filtered out diff -Nru gammaray-2.1.0/plugins/timertop/timertopwidget.cpp gammaray-2.2.0-0ubuntu0/plugins/timertop/timertopwidget.cpp --- gammaray-2.1.0/plugins/timertop/timertopwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timertopwidget.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -26,6 +26,7 @@ #include "timermodel.h" #include +#include #include #include @@ -45,23 +46,14 @@ ui->timerView->sortByColumn(TimerModel::WakeupsPerSecRole - TimerModel::FirstRole - 1, Qt::DescendingOrder); - // TODO is this even necessary? for sure it wont work remotely since model data is cached, would need to be put into the model itself in that case - m_updateTimer->setObjectName("GammaRay update timer"); - m_updateTimer->setSingleShot(false); - m_updateTimer->setInterval(500); - m_updateTimer->start(); - connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateView())); + new DeferredResizeModeSetter(ui->timerView->header(), 0, QHeaderView::ResizeToContents); + new DeferredResizeModeSetter(ui->timerView->header(), 1, QHeaderView::ResizeToContents); } TimerTopWidget::~TimerTopWidget() { } -void TimerTopWidget::slotUpdateView() -{ - ui->timerView->viewport()->update(); -} - #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) Q_EXPORT_PLUGIN(TimerTopUiFactory) #endif diff -Nru gammaray-2.1.0/plugins/timertop/timertopwidget.h gammaray-2.2.0-0ubuntu0/plugins/timertop/timertopwidget.h --- gammaray-2.1.0/plugins/timertop/timertopwidget.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/timertop/timertopwidget.h 2014-10-15 20:32:49.000000000 +0000 @@ -42,9 +42,6 @@ explicit TimerTopWidget(QWidget *parent = 0); ~TimerTopWidget(); - private slots: - void slotUpdateView(); - private: QScopedPointer ui; QTimer *m_updateTimer; diff -Nru gammaray-2.1.0/plugins/translatorinspector/CMakeLists.txt gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/CMakeLists.txt --- gammaray-2.1.0/plugins/translatorinspector/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/CMakeLists.txt 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,21 @@ +gammaray_add_plugin(gammaray_translatorinspector gammaray_translatorinspector.desktop + translatorinspector.cpp + translatorinspectorinterface.cpp + translatorwrapper.cpp + translatorsmodel.cpp +) +target_link_libraries(gammaray_translatorinspector gammaray_core Qt5::Core Qt5::Gui) + +qt5_wrap_ui(translatorinspector_ui_srcs + translatorinspectorwidget.ui +) +gammaray_add_plugin(gammaray_translatorinspector_ui gammaray_translatorinspector_ui.desktop translatorinspectorwidget.cpp translatorinspectorinterface.cpp ${translatorinspector_ui_srcs}) +target_link_libraries(gammaray_translatorinspector_ui gammaray_ui) + +add_executable(translator_test main.cpp) +qt5_use_modules(translator_test Widgets) + +add_custom_target(translator_test_qm + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/translation.qm ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translation.qm +) +add_dependencies(translator_test translator_test_qm) diff -Nru gammaray-2.1.0/plugins/translatorinspector/gammaray_translatorinspector.desktop gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/gammaray_translatorinspector.desktop --- gammaray-2.1.0/plugins/translatorinspector/gammaray_translatorinspector.desktop 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/gammaray_translatorinspector.desktop 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Translators +X-GammaRay-Types=QTranslator +X-GammaRay-ServiceTypes=com.kdab.GammaRay.ToolFactory +Exec=gammaray_translatorinspector diff -Nru gammaray-2.1.0/plugins/translatorinspector/gammaray_translatorinspector_ui.desktop gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/gammaray_translatorinspector_ui.desktop --- gammaray-2.1.0/plugins/translatorinspector/gammaray_translatorinspector_ui.desktop 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/gammaray_translatorinspector_ui.desktop 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,4 @@ +[Desktop Entry] +X-GammaRay-Id=gammaray_translatorinspector +X-GammaRay-ServiceTypes=com.kdab.GammaRay.ToolUiFactory +Exec=gammaray_translatorinspector_ui diff -Nru gammaray-2.1.0/plugins/translatorinspector/main.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/main.cpp --- gammaray-2.1.0/plugins/translatorinspector/main.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/main.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,115 @@ +/* + main.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +class Widget : public QWidget +{ + Q_OBJECT + public: + Widget(QWidget *parent = 0) : QWidget(parent) + { + m_label1 = new QLabel(this); + m_label2 = new QLabel(this); + m_label3 = new QLabel(this); + m_button = new QPushButton(this); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_label1); + m_layout->addWidget(m_label2); + m_layout->addWidget(m_label3); + m_layout->addWidget(m_button); + setLayout(m_layout); + + connect(m_button, SIGNAL(clicked()), SLOT(openFonts())); + + retranslate(); + + qApp->installEventFilter(this); + } + + void retranslate() + { + m_label1->setText(tr("One")); + m_label2->setText(tr("Two")); + m_label3->setText(tr("Three")); + m_button->setText(tr("&Fonts")); + } + + private slots: + void openFonts() + { + QFontDialog dialog(this); + dialog.exec(); + } + + protected: + bool eventFilter(QObject *object, QEvent *event) + { + if (event->type() == QEvent::LanguageChange) { + retranslate(); + } + return QWidget::eventFilter(object, event); + } + + private: + QLabel *m_label1; + QLabel *m_label2; + QLabel *m_label3; + QPushButton *m_button; + QVBoxLayout *m_layout; +}; + +void loadTranslation(const QString &filename, const QString &name) +{ + Q_ASSERT(QDir().exists(filename)); + QTranslator *translator = new QTranslator; + translator->setObjectName(name); + translator->load(filename); + qApp->installTranslator(translator); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + loadTranslation(app.applicationDirPath() + "/translation.qm", + "App translator"); + loadTranslation(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + + "/qt_sv.qm", + "Qt translator"); + + Widget widget; + widget.show(); + + return app.exec(); +} + +#include "main.moc" Binary files /tmp/ywlpDajlE8/gammaray-2.1.0/plugins/translatorinspector/translation.qm and /tmp/xxPD3rYGys/gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translation.qm differ diff -Nru gammaray-2.1.0/plugins/translatorinspector/translation.ts gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translation.ts --- gammaray-2.1.0/plugins/translatorinspector/translation.ts 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translation.ts 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,22 @@ + + + + + Widget + + + One + En + + + + Two + Två + + + + Three + Tre + + + diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspector.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspector.cpp --- gammaray-2.1.0/plugins/translatorinspector/translatorinspector.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspector.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,141 @@ +/* + translatorinspector.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "translatorinspector.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "translatorwrapper.h" +#include "translatorsmodel.h" + +using namespace GammaRay; + +TranslatorInspector::TranslatorInspector(ProbeInterface *probe, + QObject *parent) + : TranslatorInspectorInterface("com.kdab.GammaRay.TranslatorInspector", + parent), + m_probe(probe) +{ + m_translatorsModel = new TranslatorsModel(this); + probe->registerModel("com.kdab.GammaRay.TranslatorsModel", + m_translatorsModel); + + m_translationsModel = new QIdentityProxyModel(this); + probe->registerModel("com.kdab.GammaRay.TranslationsModel", + m_translationsModel); + + m_selectionModel = ObjectBroker::selectionModel(m_translatorsModel); + connect(m_selectionModel, + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + SLOT(selectionChanged(QItemSelection))); + + m_translationsSelectionModel = + ObjectBroker::selectionModel(m_translationsModel); + + m_fallbackWrapper = new TranslatorWrapper(new FallbackTranslator(this), this); + m_translatorsModel->registerTranslator(m_fallbackWrapper); + QCoreApplicationPrivate *obj = static_cast( + QCoreApplicationPrivate::get(qApp)); + obj->translators.append(m_fallbackWrapper); + + qApp->installEventFilter(this); + sendLanguageChangeEvent(); +} + +void TranslatorInspector::sendLanguageChangeEvent() +{ + QEvent event(QEvent::LanguageChange); + qApp->sendEvent(qApp, &event); +} +void TranslatorInspector::resetTranslations() +{ + const QItemSelection translatorsSelection = m_selectionModel->selection(); + if (translatorsSelection.isEmpty()) { + return; + } + TranslatorWrapper *translator = + m_translatorsModel->translator(translatorsSelection.first().topLeft()); + Q_ASSERT(translator); + const QItemSelection translationsSelection = + m_translationsSelectionModel->selection(); + if (translationsSelection.isEmpty()) { + return; + } + translator->model()->resetTranslations( + translationsSelection.first().topLeft(), + translationsSelection.last().bottomRight()); +} +bool TranslatorInspector::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) { + QCoreApplicationPrivate *obj = static_cast( + QCoreApplicationPrivate::get(qApp)); + for (int i = 0; i < obj->translators.size(); ++i) { + if (obj->translators.at(i)->metaObject()->className() == + TranslatorWrapper::staticMetaObject.className()) { + continue; // it's already setup correctly + } else { + /* wrap the translator set with installTranslator in a TranslatorWrapper + * and make sure we use the TranslatorWrapper instead of the original + * translator + */ + TranslatorWrapper *wrapper = + new TranslatorWrapper(obj->translators[i], this); + obj->translators[i] = wrapper; + m_translatorsModel->registerTranslator(wrapper); + connect(wrapper, + &TranslatorWrapper::destroyed, +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + m_translationsModel, +#endif + [wrapper, this](QObject *) { m_translatorsModel->unregisterTranslator(wrapper); }); + } + } + for (auto it = obj->translators.begin(); it != obj->translators.end(); ++it) + { + TranslatorWrapper *wrapper = qobject_cast(*it); + Q_ASSERT(wrapper); + wrapper->model()->resetAllUnchanged(); + } + } + return QObject::eventFilter(object, event); +} +void TranslatorInspector::selectionChanged(const QItemSelection &selection) +{ + m_translationsModel->setSourceModel(0); + if (!selection.isEmpty()) { + TranslatorWrapper *translator = + m_translatorsModel->translator(selection.first().topLeft()); + if (translator) { + m_translationsModel->setSourceModel(translator->model()); + } + } +} diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspector.h gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspector.h --- gammaray-2.1.0/plugins/translatorinspector/translatorinspector.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspector.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,88 @@ +/* + translatorinspector.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef TRANSLATORINSPECTOR_H +#define TRANSLATORINSPECTOR_H + +#include "translatorinspectorinterface.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QItemSelectionModel; +class QItemSelection; +class QAbstractProxyModel; +QT_END_NAMESPACE + +namespace GammaRay { +class TranslatorsModel; +class TranslatorWrapper; +class FallbackTranslator; + +class TranslatorInspector : public TranslatorInspectorInterface +{ + Q_OBJECT + Q_INTERFACES(GammaRay::TranslatorInspectorInterface) + + public: + explicit TranslatorInspector(GammaRay::ProbeInterface *probe, + QObject *parent = 0); + + public slots: + void sendLanguageChangeEvent() Q_DECL_OVERRIDE; + void resetTranslations() Q_DECL_OVERRIDE; + + private slots: + void selectionChanged(const QItemSelection &selection); + + protected: + bool eventFilter(QObject *object, QEvent *event); + + private: + QItemSelectionModel *m_selectionModel; + QItemSelectionModel *m_translationsSelectionModel; + TranslatorsModel *m_translatorsModel; + QAbstractProxyModel *m_translationsModel; + ProbeInterface *m_probe; + TranslatorWrapper *m_fallbackWrapper; +}; + +class TranslatorInspectorFactory + : public QObject, + public StandardToolFactory +{ + Q_OBJECT + Q_INTERFACES(GammaRay::ToolFactory) + Q_PLUGIN_METADATA(IID "com.kdab.GammaRay.TranslatorInspector") + + public: + explicit TranslatorInspectorFactory(QObject *parent = 0) : QObject(parent) {} + + inline QString name() const { return tr("Translators"); } +}; +} + +#endif diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspectorinterface.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorinterface.cpp --- gammaray-2.1.0/plugins/translatorinspector/translatorinspectorinterface.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorinterface.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,36 @@ +/* + translatorinspectorinterface.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "translatorinspectorinterface.h" + +#include + +using namespace GammaRay; + +TranslatorInspectorInterface::TranslatorInspectorInterface(const QString &name, + QObject *parent) + : QObject(parent), m_name(name) +{ + ObjectBroker::registerObject(name, this); +} +TranslatorInspectorInterface::~TranslatorInspectorInterface() {} diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspectorinterface.h gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorinterface.h --- gammaray-2.1.0/plugins/translatorinspector/translatorinspectorinterface.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorinterface.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,55 @@ +/* + translatorinspectorinterface.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef TRANSLATORINSPECTORINTERFACE_H +#define TRANSLATORINSPECTORINTERFACE_H + +#include + +namespace GammaRay +{ + +class TranslatorInspectorInterface : public QObject +{ + Q_OBJECT + + public: + explicit TranslatorInspectorInterface(const QString &name, QObject *parent); + virtual ~TranslatorInspectorInterface(); + + const QString &name() const { return m_name; } + + public slots: + virtual void sendLanguageChangeEvent() = 0; + virtual void resetTranslations() = 0; + + private: + QString m_name; +}; + +} + +Q_DECLARE_INTERFACE(GammaRay::TranslatorInspectorInterface, + "com.kdab.GammaRay.TranslatorInspectorInterface") + +#endif diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.cpp --- gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,81 @@ +/* + translatorinspectorwidget.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "translatorinspectorwidget.h" +#include "ui_translatorinspectorwidget.h" + +#include + +#include +#include + +using namespace GammaRay; + +TranslatorInspectorClient::TranslatorInspectorClient(const QString &name, QObject *parent) + : TranslatorInspectorInterface(name, parent) +{ +} +void TranslatorInspectorClient::sendLanguageChangeEvent() +{ + Endpoint::instance()->invokeObject(name(), "sendLanguageChangeEvent"); +} +void TranslatorInspectorClient::resetTranslations() +{ + Endpoint::instance()->invokeObject(name(), "resetTranslations"); +} + +TranslatorInspectorWidget::TranslatorInspectorWidget(QWidget *parent) : + QWidget(parent), ui(new Ui::TranslatorInspectorWidget) +{ + ui->setupUi(this); + QAbstractItemModel *translators = ObjectBroker::model("com.kdab.GammaRay.TranslatorsModel"); + ui->translatorList->setModel(translators); + ui->translatorList->setSelectionModel(ObjectBroker::selectionModel(translators)); + + m_inspector = ObjectBroker::object("com.kdab.GammaRay.TranslatorInspector"); + + connect(ui->languageChangeButton, SIGNAL(clicked()), m_inspector, SLOT(sendLanguageChangeEvent())); + connect(ui->resetTranslationsButton, SIGNAL(clicked()), m_inspector, SLOT(resetTranslations())); + + // searching for translations + { + QSortFilterProxyModel *translationsFilter = new QSortFilterProxyModel(this); + translationsFilter->setSourceModel(ObjectBroker::model("com.kdab.GammaRay.TranslationsModel")); + ui->translationsView->setModel(translationsFilter); + ui->translationsSearchLine->setProxy(translationsFilter); + ui->translationsView->setSelectionModel(ObjectBroker::selectionModel(translationsFilter)); + } +} +TranslatorInspectorWidget::~TranslatorInspectorWidget() +{ +} + +static QObject* translatorInspectorClientFactory(const QString &name, QObject *parent) +{ + return new TranslatorInspectorClient(name, parent); +} + +void TranslatorInspectorWidgetFactory::initUi() +{ + ObjectBroker::registerClientObjectFactoryCallback(translatorInspectorClientFactory); +} diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.h gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.h --- gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,79 @@ +/* + translatorinspectorwidget.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef TRANSLATORINSPECTORWIDGET_H +#define TRANSLATORINSPECTORWIDGET_H + +#include +#include + +#include "translatorinspectorinterface.h" + +namespace GammaRay { + +namespace Ui +{ +class TranslatorInspectorWidget; +} + +class TranslatorInspectorClient : public TranslatorInspectorInterface +{ + Q_OBJECT + Q_INTERFACES(GammaRay::TranslatorInspectorInterface) + + public: + explicit TranslatorInspectorClient(const QString &name, QObject *parent = 0); + + public slots: + void sendLanguageChangeEvent() Q_DECL_OVERRIDE; + void resetTranslations() Q_DECL_OVERRIDE; +}; + +class TranslatorInspectorWidget : public QWidget +{ + Q_OBJECT + + public: + explicit TranslatorInspectorWidget(QWidget *parent); + ~TranslatorInspectorWidget(); + + private: + QScopedPointer ui; + TranslatorInspectorInterface *m_inspector; +}; + +class TranslatorInspectorWidgetFactory + : public QObject, + public StandardToolUiFactory +{ + Q_OBJECT + Q_INTERFACES(GammaRay::ToolUiFactory) + Q_PLUGIN_METADATA(IID "com.kdab.GammaRay.TranslatorInspectorUi") + + public: + void initUi() Q_DECL_OVERRIDE; +}; + +} + +#endif diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.ui gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.ui --- gammaray-2.1.0/plugins/translatorinspector/translatorinspectorwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorinspectorwidget.ui 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,67 @@ + + + GammaRay::TranslatorInspectorWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Qt::Horizontal + + + + + + + + + + + QAbstractItemView::ContiguousSelection + + + false + + + + + + + Reset selected + + + + + + + + + + + Send QEvent::LanguageChange + + + + + + + + KFilterProxySearchLine + QWidget +
kde/kfilterproxysearchline.h
+
+
+ + +
diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorsmodel.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorsmodel.cpp --- gammaray-2.1.0/plugins/translatorinspector/translatorsmodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorsmodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,127 @@ +/* + translatorsmodel.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "translatorsmodel.h" + +#include + +#include "translatorwrapper.h" + +using namespace GammaRay; + +TranslatorsModel::TranslatorsModel(QObject *parent) + : QAbstractTableModel(parent) +{ +} +int TranslatorsModel::columnCount(const QModelIndex &) const +{ + return 3; +} +int TranslatorsModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) { + return 0; + } + return m_translators.size(); +} +QVariant TranslatorsModel::data(const QModelIndex &index, int role) const +{ + if (role == TranslatorRole) { + return QVariant::fromValue(m_translators.at(index.row())); + } + TranslatorWrapper *trans = m_translators.at(index.row()); + Q_ASSERT(trans); + if (role == Qt::DisplayRole) { + if (index.column() == 0) { + return Util::shortDisplayString(trans->translator()); + } else if (index.column() == 1) { + return QString(trans->translator()->metaObject()->className()); + } else if (index.column() == 2) { + return trans->model()->rowCount(QModelIndex()); + } + } else if (role == Qt::ToolTipRole) { + return Util::tooltipForObject(trans->translator()); + } + return QVariant(); +} +QVariant TranslatorsModel::headerData(int section, + Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + if (section == 0) { + return tr("Object"); + } else if (section == 1) { + return tr("Type"); + } else if (section == 2) { + return tr("Translations"); + } + } + return QVariant(); +} +Qt::ItemFlags TranslatorsModel::flags(const QModelIndex &index) const +{ + Q_UNUSED(index); + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} +TranslatorWrapper *TranslatorsModel::translator(const QModelIndex &index) + const +{ + return m_translators.at(index.row()); +} +void TranslatorsModel::sourceDataChanged() +{ + const int row = m_translators.indexOf(qobject_cast(sender())->translator()); + if (row == -1) { + return; + } + const QModelIndex index = this->index(row, 2, QModelIndex()); + if (!index.isValid()) { + return; + } + // needed to make sure these things also update + emit dataChanged(index, index, + QVector() << Qt::DisplayRole << Qt::EditRole); +} + +void TranslatorsModel::registerTranslator(TranslatorWrapper *translator) +{ + beginInsertRows(QModelIndex(), m_translators.size(), m_translators.size()); + m_translators.append(translator); + endInsertRows(); + connect(translator->model(), SIGNAL(rowCountChanged()), + SLOT(sourceDataChanged())); +} +void TranslatorsModel::unregisterTranslator(TranslatorWrapper *translator) +{ + const int index = m_translators.indexOf(translator); + if (index == -1) { + qWarning("TranslatorsModel::unregisterTranslator: translator %s is not registered", + qPrintable(Util::addressToString(translator))); + return; + } + disconnect(translator->model(), 0, this, 0); + beginRemoveRows(QModelIndex(), index, index); + m_translators.removeAt(index); + endRemoveRows(); +} diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorsmodel.h gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorsmodel.h --- gammaray-2.1.0/plugins/translatorinspector/translatorsmodel.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorsmodel.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,67 @@ +/* + translatorsmodel.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef TRANSLATORSMODEL_H +#define TRANSLATORSMODEL_H + +#include + +namespace GammaRay { +class TranslatorWrapper; + +class TranslatorsModel : public QAbstractTableModel +{ + Q_OBJECT + + public: + explicit TranslatorsModel(QObject *parent = 0); + + enum ExtraRoles + { + TranslatorRole = Qt::UserRole + }; + + int columnCount( + const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &proxyIndex, int role) const Q_DECL_OVERRIDE; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + + TranslatorWrapper *translator(const QModelIndex &index) const; + + public slots: + void registerTranslator(TranslatorWrapper *translator); + void unregisterTranslator(TranslatorWrapper *translator); + + private slots: + void sourceDataChanged(); + + private: + QList m_translators; +}; + +} + +#endif diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorwrapper.cpp gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorwrapper.cpp --- gammaray-2.1.0/plugins/translatorinspector/translatorwrapper.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorwrapper.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,244 @@ +/* + translatorwrapper.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "translatorwrapper.h" + +#include + +using namespace GammaRay; + +TranslationsModel::TranslationsModel(TranslatorWrapper *translator) + : QAbstractListModel(translator), m_translator(translator) +{ + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), + SIGNAL(rowCountChanged())); + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), + SIGNAL(rowCountChanged())); +} +int TranslationsModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) { + return 0; + } + return m_nodes.size(); +} +int TranslationsModel::columnCount(const QModelIndex &) const +{ + return 4; +} +QVariant TranslationsModel::data(const QModelIndex &index, int role) const +{ + if (index.parent().isValid()) { + return QVariant(); + } + Row node = m_nodes.at(index.row()); + if (role == Qt::DisplayRole || role == Qt::EditRole) { + switch (index.column()) { + case 0: + return node.context; + case 1: + return node.sourceText; + case 2: + return node.disambiguation; + case 3: + return node.translation; + } + } + if (role == Qt::FontRole && index.column() == 3 && node.isOverriden) { + QFont font; + font.setItalic(true); + return font; + } + return QVariant(); +} +bool TranslationsModel::setData(const QModelIndex &index, const QVariant &value, + int role) +{ + if (role == Qt::EditRole && index.column() == 3) { + Row &node = m_nodes[index.row()]; + if (node.translation == value.toString()) { + return true; + } + node.translation = value.toString(); + node.isOverriden = true; + emit dataChanged(index, index, QVector() << Qt::DisplayRole + << Qt::EditRole); + return true; + } + return false; +} +QVariant TranslationsModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + switch (section) { + case 0: + return tr("Context"); + case 1: + return tr("Source Text"); + case 2: + return tr("Disambiguation"); + case 3: + return tr("Translation"); + } + } + return QVariant(); +} +Qt::ItemFlags TranslationsModel::flags(const QModelIndex &index) const +{ + if (index.column() == 3) { + return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } else { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } +} +void TranslationsModel::resetTranslations(const QModelIndex &first, + const QModelIndex &last) +{ + if (!first.isValid() || !last.isValid()) { + return; + } + int top = first.row(); + int bottom = last.row(); + beginRemoveRows(QModelIndex(), top, bottom); + for (int i = 0; i < (bottom - top + 1); ++i) { + m_nodes.remove(top); + } + endRemoveRows(); +} +QString TranslationsModel::translation(const QByteArray &context, + const QByteArray &sourceText, + const QByteArray &disambiguation, + const int n, const QString &default_) +{ + QModelIndex existingIndex = + findNode(context, sourceText, disambiguation, n, true); + Row &row = m_nodes[existingIndex.row()]; + if (!row.isOverriden) { + setTranslation(existingIndex, default_); + } + return row.translation; +} +void TranslationsModel::resetAllUnchanged() +{ + for (int i = 0; i < m_nodes.size(); ++i) { + if (!m_nodes[i].isOverriden) { + resetTranslations(index(i), index(i)); + } + } +} +void TranslationsModel::setTranslation(const QModelIndex &index, + const QString &translation) +{ + if (!index.isValid()) { + return; + } + if (m_nodes[index.row()].isOverriden) { + return; + } + m_nodes[index.row()].translation = translation; + emit dataChanged(index, index); +} +QModelIndex TranslationsModel::findNode(const QByteArray &context, + const QByteArray &sourceText, + const QByteArray &disambiguation, + const int n, const bool create) +{ + Q_UNUSED(n); + // QUESTION make use of n? + for (int i = 0; i < m_nodes.size(); ++i) { + const Row node = m_nodes.at(i); + if (node.context == context && node.sourceText == sourceText && + node.disambiguation == disambiguation) { + return index(i, 0); + } + } + if (create) { + Row node; + node.context = context; + node.sourceText = sourceText; + node.disambiguation = disambiguation; + const int newRow = m_nodes.size(); + beginInsertRows(QModelIndex(), newRow, newRow); + m_nodes.append(node); + endInsertRows(); + return index(newRow, 0); + } + return QModelIndex(); +} + +TranslatorWrapper::TranslatorWrapper(QObject *parent) + : QTranslator(parent), m_wrapped(0), m_model(new TranslationsModel(this)) +{ +} +TranslatorWrapper::TranslatorWrapper(QTranslator *wrapped, QObject *parent) + : QTranslator(parent), m_wrapped(wrapped), + m_model(new TranslationsModel(this)) +{ + connect(wrapped, SIGNAL(destroyed()), SLOT(deleteLater())); +} +bool TranslatorWrapper::isEmpty() const +{ + return translator()->isEmpty(); +} +QString TranslatorWrapper::translate(const char *context, + const char *sourceText, + const char *disambiguation, int n) const +{ + const QString translation = + translateInternal(context, sourceText, disambiguation, n); + + if (QByteArray(context).startsWith("GammaRay::")) { + return translation; + } + // it's not for this translator + if (translation.isNull()) { + return translation; + } + return m_model->translation(context, sourceText, disambiguation, n, + translation); +} +QString TranslatorWrapper::translateInternal(const char *context, + const char *sourceText, + const char *disambiguation, int n) + const +{ + return translator()->translate(context, sourceText, disambiguation, n); +} +const QTranslator *TranslatorWrapper::translator() const +{ + return m_wrapped == 0 ? this : m_wrapped; +} + +FallbackTranslator::FallbackTranslator(QObject *parent) + : QTranslator(parent) +{ + setObjectName("Fallback Translator"); +} +QString FallbackTranslator::translate(const char *context, const char *sourceText, const char *disambiguation, int n) const +{ + Q_UNUSED(context); + Q_UNUSED(disambiguation); + Q_UNUSED(n); + return QString::fromUtf8(sourceText); +} diff -Nru gammaray-2.1.0/plugins/translatorinspector/translatorwrapper.h gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorwrapper.h --- gammaray-2.1.0/plugins/translatorinspector/translatorwrapper.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/translatorinspector/translatorwrapper.h 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,132 @@ +/* + translatorwrapper.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Jan Dalheimer + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef TRANSLATORWRAPPER_H +#define TRANSLATORWRAPPER_H + +#include +#include + +namespace GammaRay { +class TranslatorWrapper; + +class TranslationsModel : public QAbstractListModel +{ + Q_OBJECT + + public: + explicit TranslationsModel(TranslatorWrapper *translator); + + int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + bool setData(const QModelIndex &index, const QVariant &value, + int role) Q_DECL_OVERRIDE; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + + void resetTranslations(const QModelIndex &first, const QModelIndex &last); + QString translation(const QByteArray &context, const QByteArray &sourceText, + const QByteArray &disambiguation, const int n, + const QString &default_); + + void resetAllUnchanged(); + + TranslatorWrapper *translator() const + { + return m_translator; + } + + signals: + void rowCountChanged(); + + private: + friend class TranslatorWrapper; + TranslatorWrapper *m_translator; + + struct Row + { + Row() : isOverriden(false) {} + QByteArray context; + QByteArray sourceText; + QByteArray disambiguation; + QString translation; + bool isOverriden; + }; + QVector m_nodes; + + QModelIndex findNode(const QByteArray &context, const QByteArray &sourceText, + const QByteArray &disambiguation, const int n, + const bool create); + void setTranslation(const QModelIndex &index, const QString &translation); +}; + +class TranslatorWrapper : public QTranslator +{ + Q_OBJECT + + public: + TranslatorWrapper(QObject *parent = 0); + TranslatorWrapper(QTranslator *wrapped, QObject *parent = 0); + + TranslationsModel *model() const { return m_model; } + + bool isEmpty() const Q_DECL_OVERRIDE; + QString translate(const char *context, const char *sourceText, + const char *disambiguation, int n) const Q_DECL_OVERRIDE; + const QTranslator *translator() const; + + private: + QTranslator *m_wrapped; + TranslationsModel *m_model; + + QString translateInternal(const char *context, const char *sourceText, + const char *disambiguation, int n) const; +}; + +class FallbackTranslator : public QTranslator +{ + Q_OBJECT + + public: + FallbackTranslator(QObject *parent = 0); + + bool isEmpty() const Q_DECL_OVERRIDE + { + return false; + } + + QString translate(const char *context, const char *sourceText, + const char *disambiguation, int n) const Q_DECL_OVERRIDE; + + private: +#ifndef Q_NO_USING_KEYWORD + // hide + using QTranslator::load; +#endif +}; + +} + +#endif diff -Nru gammaray-2.1.0/plugins/widgetinspector/paintbuffermodel.cpp gammaray-2.2.0-0ubuntu0/plugins/widgetinspector/paintbuffermodel.cpp --- gammaray-2.1.0/plugins/widgetinspector/paintbuffermodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/plugins/widgetinspector/paintbuffermodel.cpp 2014-10-15 20:32:49.000000000 +0000 @@ -34,7 +34,7 @@ #define CMD(cmd) { QPaintBufferPrivate::Cmd_ ## cmd, #cmd } -static cmd_t cmdTypes[] = { +static const cmd_t cmdTypes[] = { CMD(Save), CMD(Restore), CMD(SetBrush), diff -Nru gammaray-2.1.0/ReadMe.md gammaray-2.2.0-0ubuntu0/ReadMe.md --- gammaray-2.1.0/ReadMe.md 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ReadMe.md 2014-10-15 20:32:49.000000000 +0000 @@ -1,9 +1,15 @@ Introduction ============ -GammaRay is a tool to poke around in a Qt-application and also to manipulate the -application to some extent. GammaRay uses various DLL injection techniques to -hook into an application at runtime and provide access to a lot of interesting -information. + +GammaRay is a free software introspection tool for Qt applications developed by +KDAB. Leveraging the QObject introspection mechanism it allows you to observe +and manipulate your application at runtime. This works both locally on your +workstation and remotely on an embedded target. + +Augmenting your instruction-level debugger, GammaRay allows you to work on a +much higher level, with the same concepts as the frameworks you use. This is +especially useful for the more complex Qt frameworks such as model/view, state +machines or scene graphs. GammaRay can: @@ -11,27 +17,36 @@ * View, and to some extent, edit QObject static and dynamic properties. - * View and call slots of a QObject (similar to qdbusviewer). + * View and call slots of a QObject. - * View other QObject elements such as signals, enums and class infos - introspectively. + * View other QObject elements such as signals, enums and class infos. * List all QObject inbound and outbound signal/slot connections. - * Provide live widget preview. Useful for finding layout issues). + * Provide a layout information overlay for QWidget applications. + + * Inspect all QPainter operations used to draw a specific widget. + + * Browse the QtQuick2 item tree and scenegraph. - * View the content of any QAbstractItemModel (QAIM). Very useful when + * Plot object lifetime and emitted signals. + + * View the content of any QAbstractItemModel. Very useful when debugging a proxy model chain for example. - * Browse the QAbstractProxyModel (QAPM) hierarchy. + * Browse the QAbstractProxyModel hierarchy. - * Browse the QGraphicsView (QGV) item tree of any QGV scene. + * Browse the item tree of any QGraphicsView scene. - * Show a live preview of QGV items, including showing their coordinate system, + * Show a live preview of QGraphicsView items, including showing their coordinate system, transformation origin, rotate/zoom/pan, etc. + * Intercept translations and change them at runtime. + + * Inspect all building blocks of a QStyle. + * Act as a complete java script debugger, attachable to any QScriptEngine - (including the usually not accessible one used by QML internally). + (including the usually not accessible one used by QtQuick1 internally). * Perform HTML/CSS/DOM/JS introspection/editing/profiling on any QWebPage, thanks to QWebInspector. @@ -51,7 +66,6 @@ * Show all QTimers and their statistics (number of wakeups, wakeup time, ...) -Head Engineer for GammaRay is Volker Krause Contact ======= diff -Nru gammaray-2.1.0/ReadMe.txt gammaray-2.2.0-0ubuntu0/ReadMe.txt --- gammaray-2.1.0/ReadMe.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ReadMe.txt 2014-10-15 20:32:49.000000000 +0000 @@ -1,9 +1,15 @@ Introduction ============ -GammaRay is a tool to poke around in a Qt-application and also to manipulate the -application to some extent. GammaRay uses various DLL injection techniques to -hook into an application at runtime and provide access to a lot of interesting -information. + +GammaRay is a free software introspection tool for Qt applications developed by +KDAB. Leveraging the QObject introspection mechanism it allows you to observe +and manipulate your application at runtime. This works both locally on your +workstation and remotely on an embedded target. + +Augmenting your instruction-level debugger, GammaRay allows you to work on a +much higher level, with the same concepts as the frameworks you use. This is +especially useful for the more complex Qt frameworks such as model/view, state +machines or scene graphs. GammaRay can: @@ -11,27 +17,36 @@ * View, and to some extent, edit QObject static and dynamic properties. - * View and call slots of a QObject (similar to qdbusviewer). + * View and call slots of a QObject. - * View other QObject elements such as signals, enums and class infos - introspectively. + * View other QObject elements such as signals, enums and class infos. * List all QObject inbound and outbound signal/slot connections. - * Provide live widget preview. Useful for finding layout issues). + * Provide a layout information overlay for QWidget applications. + + * Inspect all QPainter operations used to draw a specific widget. + + * Browse the QtQuick2 item tree and scenegraph. - * View the content of any QAbstractItemModel (QAIM). Very useful when + * Plot object lifetime and emitted signals. + + * View the content of any QAbstractItemModel. Very useful when debugging a proxy model chain for example. - * Browse the QAbstractProxyModel (QAPM) hierarchy. + * Browse the QAbstractProxyModel hierarchy. - * Browse the QGraphicsView (QGV) item tree of any QGV scene. + * Browse the item tree of any QGraphicsView scene. - * Show a live preview of QGV items, including showing their coordinate system, + * Show a live preview of QGraphicsView items, including showing their coordinate system, transformation origin, rotate/zoom/pan, etc. + * Intercept translations and change them at runtime. + + * Inspect all building blocks of a QStyle. + * Act as a complete java script debugger, attachable to any QScriptEngine - (including the usually not accessible one used by QML internally). + (including the usually not accessible one used by QtQuick1 internally). * Perform HTML/CSS/DOM/JS introspection/editing/profiling on any QWebPage, thanks to QWebInspector. @@ -51,7 +66,6 @@ * Show all QTimers and their statistics (number of wakeups, wakeup time, ...) -Head Engineer for GammaRay is Volker Krause Contact ======= diff -Nru gammaray-2.1.0/resources/authors gammaray-2.2.0-0ubuntu0/resources/authors --- gammaray-2.1.0/resources/authors 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/resources/authors 2014-10-15 20:32:49.000000000 +0000 @@ -0,0 +1,19 @@ +Allen Winter +Andreas Holzammer +Anton Kreuzkamp +David Faure +Frank Osterfeld +James Turner +Jan Dalheimer +Kevin Funk +Laurent Montel +Mathias Hasselmann +Milian Wolff +Patrick Spendrin +Peter Kümmel +Rafael Roquetto +Stephen Kelly +Thomas McGuire +Till Adam +Tobias Koenig +Volker Krause diff -Nru gammaray-2.1.0/resources/gammaray.qrc gammaray-2.2.0-0ubuntu0/resources/gammaray.qrc --- gammaray-2.1.0/resources/gammaray.qrc 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/resources/gammaray.qrc 2014-10-15 20:32:49.000000000 +0000 @@ -1,5 +1,6 @@ + authors GammaRay-512x512.png GammaRay-256x256.png GammaRay-128x128.png diff -Nru gammaray-2.1.0/resources/update_authors.sh gammaray-2.2.0-0ubuntu0/resources/update_authors.sh --- gammaray-2.1.0/resources/update_authors.sh 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/resources/update_authors.sh 2014-10-15 20:32:50.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh + +git log --pretty=format:"%an <%ae>" | sort | uniq > authors diff -Nru gammaray-2.1.0/tests/CMakeLists.txt gammaray-2.2.0-0ubuntu0/tests/CMakeLists.txt --- gammaray-2.1.0/tests/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/tests/CMakeLists.txt 2014-10-15 20:32:50.000000000 +0000 @@ -1,6 +1,5 @@ ### BENCH SUITE - if(Qt5Widgets_FOUND OR QT_QTGUI_FOUND) add_executable(benchsuite benchsuite.cpp) @@ -104,5 +103,4 @@ target_link_libraries(probeabidetectortest gammaray_common_internal ${QT_QTTEST_LIBRARIES}) add_test(probeabidetectortest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/probeabidetectortest) - add_subdirectory(manual) diff -Nru gammaray-2.1.0/tests/manual/CMakeLists.txt gammaray-2.2.0-0ubuntu0/tests/manual/CMakeLists.txt --- gammaray-2.1.0/tests/manual/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/tests/manual/CMakeLists.txt 2014-10-15 20:32:50.000000000 +0000 @@ -1,16 +1,4 @@ if(Qt5Widgets_FOUND OR QT_QTGUI_FOUND) - add_executable(propertywidgettest - propertywidgettest.cpp - ) - - target_link_libraries(propertywidgettest - ${QT_QTCORE_LIBRARIES} - ${QT_QTGUI_LIBRARIES} - gammaray_ui - gammaray_core - gammaray_common - ) - set(gammaray_messagemodeltest_srcs messagemodeltest.cpp ) @@ -51,8 +39,14 @@ target_link_libraries(wk2application Qt5::Quick) endif() +add_executable(signalmonitortest signalmonitortest.cpp) + +target_link_libraries(signalmonitortest + ${QT_QTCORE_LIBRARIES} + ${QT_QTGUI_LIBRARIES} +) + if(QNXNTO) - target_link_libraries(propertywidgettest cpp) target_link_libraries(messagemodeltest cpp) endif() @@ -61,6 +55,5 @@ variantinspector.cpp variantinspectorapplication.cpp ) - set_property(TARGET variantinspectortest PROPERTY AUTOMOC TRUE) target_link_libraries(variantinspectortest Qt5::Widgets) endif() diff -Nru gammaray-2.1.0/tests/manual/propertywidgettest.cpp gammaray-2.2.0-0ubuntu0/tests/manual/propertywidgettest.cpp --- gammaray-2.1.0/tests/manual/propertywidgettest.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/tests/manual/propertywidgettest.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - propertywidgettest.cpp - - This file is part of GammaRay, the Qt application inspection and - manipulation tool. - - Copyright (C) 2012-2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com - Author: Kevin Funk - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ui/propertywidget.h" - -#include -#include -#include - -using namespace GammaRay; - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - PropertyWidget widget; - //widget.setMetaObject((new QTreeView())->metaObject()); - //widget.setObject(new QTreeView()); - //widget.setObject(new QGraphicsRectItem, "QGraphicsRectItem"); - widget.show(); - - return app.exec(); -} diff -Nru gammaray-2.1.0/tests/manual/signalmonitortest.cpp gammaray-2.2.0-0ubuntu0/tests/manual/signalmonitortest.cpp --- gammaray-2.1.0/tests/manual/signalmonitortest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/tests/manual/signalmonitortest.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -0,0 +1,61 @@ +/* + signalmonitortest.cpp + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "signalmonitortest.h" + +#include +#include + +SignalMonitorTest::SignalMonitorTest(QObject *parent) + : QObject(parent) + , m_timerCount(0) +{ + QTimer *t1 = new QTimer(this); + t1->setObjectName(nextTimerName()); + t1->start(250); + + QTimer *t2 = new QTimer(this); + t2->setObjectName(nextTimerName()); + connect(t2, SIGNAL(timeout()), this, SLOT(onTimeout())); + t2->start(1500); +} + +QString SignalMonitorTest::nextTimerName() +{ + return QString::fromLatin1("SignalMonitorTest_t%1").arg(++m_timerCount); +} + +void SignalMonitorTest::onTimeout() +{ + QTimer *tx = new QTimer(this); + tx->setObjectName(nextTimerName()); + connect(tx, SIGNAL(timeout()), tx, SLOT(deleteLater())); + tx->start(2500); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + new SignalMonitorTest(&app); + return app.exec(); +} diff -Nru gammaray-2.1.0/tests/manual/signalmonitortest.h gammaray-2.2.0-0ubuntu0/tests/manual/signalmonitortest.h --- gammaray-2.1.0/tests/manual/signalmonitortest.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/tests/manual/signalmonitortest.h 2014-10-15 20:32:50.000000000 +0000 @@ -0,0 +1,46 @@ +/* + signalmonitortest.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Mathias Hasselmann + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_SIGNALMONITORTEST_H +#define GAMMARAY_SIGNALMONITORTEST_H + +#include + +class SignalMonitorTest : public QObject +{ + Q_OBJECT + + public: + SignalMonitorTest(QObject *parent = 0); + + private: + QString nextTimerName(); + + private slots: + void onTimeout(); + + private: + int m_timerCount; +}; + +#endif // GAMMARAY_SIGNALMONITORTEST_H diff -Nru gammaray-2.1.0/ui/aboutdata.cpp gammaray-2.2.0-0ubuntu0/ui/aboutdata.cpp --- gammaray-2.1.0/ui/aboutdata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/aboutdata.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -0,0 +1,50 @@ +#include +#include "aboutdata.h" + +#include +#include + +using namespace GammaRay; + +QStringList AboutData::authors() +{ + QFile f(":/gammaray/authors"); + f.open(QFile::ReadOnly); + Q_ASSERT(f.isOpen()); + return QString::fromUtf8(f.readAll()).split("\n", QString::SkipEmptyParts); +} + +QStringList AboutData::authorsAsHtml() +{ + QStringList a; + foreach (const QString &author, authors()) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + a.push_back(Qt::escape(author)); +#else + a.push_back(author.toHtmlEscaped()); +#endif + } + return a; +} + +QString AboutData::aboutTitle() +{ + return QObject::trUtf8("GammaRay %1").arg(GAMMARAY_VERSION_STRING); +} + +QString AboutData::aboutBody() +{ + return QObject::trUtf8( + "

The Qt application inspection and manipulation tool." + "Learn more at http://www.kdab.com/gammaray/.

" + "

Copyright (C) 2010-2014 Klarälvdalens Datakonsult AB, " + "a KDAB Group company, info@kdab.com

" + "

Authors:
%1

" + "

StackWalker code Copyright (c) 2005-2009, Jochen Kalmbach, All rights reserved

") + .arg(authorsAsHtml().join("
")); +} + +QString AboutData::aboutText() +{ + return aboutTitle() + aboutBody(); +} diff -Nru gammaray-2.1.0/ui/aboutdata.h gammaray-2.2.0-0ubuntu0/ui/aboutdata.h --- gammaray-2.1.0/ui/aboutdata.h 1970-01-01 00:00:00.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/aboutdata.h 2014-10-15 20:32:50.000000000 +0000 @@ -0,0 +1,44 @@ +/* + aboutdata.h + + This file is part of GammaRay, the Qt application inspection and + manipulation tool. + + Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Volker Krause + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GAMMARAY_ABOUTDATA_H +#define GAMMARAY_ABOUTDATA_H + +#include "gammaray_ui_export.h" + +#include + +namespace GammaRay { + +namespace AboutData +{ + QStringList authors(); + QStringList authorsAsHtml(); + GAMMARAY_UI_EXPORT QString aboutTitle(); + GAMMARAY_UI_EXPORT QString aboutBody(); + GAMMARAY_UI_EXPORT QString aboutText(); +} + +} + +#endif // GAMMARAY_ABOUTDATA_H diff -Nru gammaray-2.1.0/ui/clienttoolmodel.cpp gammaray-2.2.0-0ubuntu0/ui/clienttoolmodel.cpp --- gammaray-2.1.0/ui/clienttoolmodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/clienttoolmodel.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -64,7 +64,7 @@ MAKE_FACTORY(ModelInspector, true); MAKE_FACTORY(ResourceBrowser, true); MAKE_FACTORY(StandardPaths, true); -MAKE_FACTORY(TextDocumentInspector, false); +MAKE_FACTORY(TextDocumentInspector, true); ClientToolModel::ClientToolModel(QObject* parent) : QSortFilterProxyModel(parent) { diff -Nru gammaray-2.1.0/ui/CMakeLists.txt gammaray-2.2.0-0ubuntu0/ui/CMakeLists.txt --- gammaray-2.1.0/ui/CMakeLists.txt 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/CMakeLists.txt 2014-10-15 20:32:50.000000000 +0000 @@ -7,6 +7,7 @@ ${CMAKE_SOURCE_DIR}/3rdparty/other/modelutils.cpp + aboutdata.cpp palettemodel.cpp propertywidget.cpp deferredresizemodesetter.cpp diff -Nru gammaray-2.1.0/ui/mainwindow.cpp gammaray-2.2.0-0ubuntu0/ui/mainwindow.cpp --- gammaray-2.1.0/ui/mainwindow.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/mainwindow.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -22,12 +22,12 @@ */ #include "mainwindow.h" -#include #include "ui_mainwindow.h" #include "aboutpluginsdialog.h" #include "aboutdialog.h" #include "clienttoolmodel.h" +#include "aboutdata.h" #include "common/objectbroker.h" #include "common/modelroles.h" @@ -43,26 +43,13 @@ #include //krazy:exclude=camelcase #endif -#include #include #include -#include #include -#include -#include #include -#include -#include -#include -#include using namespace GammaRay; -static const char progName[] = "GammaRay"; -static const char progVersion[] = GAMMARAY_VERSION_STRING; -static const char progDesc[] = "The Qt application inspection and manipulation tool"; -static const char progURL[] = "http://www.kdab.com/gammaray"; - MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) { if (!Endpoint::instance()->isRemoteClient()) { @@ -124,7 +111,7 @@ // hide unused tool bar for now ui->mainToolBar->setHidden(true); - setWindowTitle(tr("%1 (%2)").arg(progName).arg(Endpoint::instance()->label())); + setWindowTitle(tr("GammaRay (%1)").arg(Endpoint::instance()->label())); selectInitialTool(); connect(ui->toolSelector->model(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(selectInitialTool())); @@ -146,27 +133,9 @@ void MainWindow::about() { AboutDialog dialog(this); - dialog.setWindowTitle(tr("About %1").arg(progName)); - dialog.setTitle(tr("%1 %2

%3").arg(progName).arg(progVersion).arg(progDesc)); - dialog.setText( - trUtf8("" - "

Copyright (C) 2010-2014 Klarälvdalens Datakonsult AB, " - "a KDAB Group company, info@kdab.com

" - "

Authors:
" - "Allen Winter <allen.winter@kdab.com>
" - "Andreas Holzammer <andreas.holzammer@kdab.com>
" - "David Faure <david.faure@kdab.com>
" - "Kevin Funk <kevin.funk@kdab.com>
" - "Laurent Montel <laurent.montel@kdab.com>
" - "Milian Wolff <milian.wolff@kdab.com>
" - "Patrick Spendrin <patrick.spendrin@kdab.com>
" - "Stephen Kelly <stephen.kelly@kdab.com>
" - "Till Adam <till@kdab.com>
" - "Thomas McGuire <thomas.mcguire@kdab.com>
" - "Tobias Koenig <tobias.koenig@kdab.com>
" - "Volker Krause <volker.krause@kdab.com>

" - "

StackWalker code Copyright (c) 2005-2009, Jochen Kalmbach, All rights reserved

" - "")); + dialog.setWindowTitle(tr("About GammaRay")); + dialog.setTitle(AboutData::aboutTitle()); + dialog.setText(AboutData::aboutBody()); dialog.setLogo(":gammaray/GammaRay-128x128.png"); dialog.setWindowIcon(QPixmap(":gammaray/GammaRay-128x128.png")); dialog.exec(); @@ -185,7 +154,7 @@ dialog.setWindowTitle(tr("About KDAB")); dialog.setTitle(trUtf8("Klarälvdalens Datakonsult AB (KDAB)")); dialog.setText( - tr("

%1 is supported and maintained by KDAB

" + tr("

GammaRay is supported and maintained by KDAB

" "KDAB, the Qt experts, provide consulting and mentoring for developing " "Qt applications from scratch and in porting from all popular and legacy " "frameworks to Qt. We continue to help develop parts of Qt and are one " @@ -193,7 +162,7 @@ "standard trainings anywhere around the globe.

" "

Please visit http://www.kdab.com " "to meet the people who write code like this." - "

").arg(progName)); + "

")); dialog.setLogo(":gammaray/kdablogo160.png"); dialog.setWindowIcon(QPixmap(":gammaray/kdablogo160.png")); dialog.exec(); @@ -274,4 +243,3 @@ { ObjectBroker::object()->detachProbe(); } - diff -Nru gammaray-2.1.0/ui/palettemodel.cpp gammaray-2.2.0-0ubuntu0/ui/palettemodel.cpp --- gammaray-2.1.0/ui/palettemodel.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/palettemodel.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -34,7 +34,7 @@ QPalette::ColorRole role; }; -static role_t paletteRoles[] = { +static const role_t paletteRoles[] = { { "Window", QPalette::Window }, { "WindowText", QPalette::WindowText }, { "Base", QPalette::Base }, @@ -61,7 +61,7 @@ QPalette::ColorGroup group; }; -static group_t paletteGroups[] = { +static const group_t paletteGroups[] = { { "Active", QPalette::Active }, { "Inactive", QPalette::Inactive }, { "Disabled", QPalette::Disabled }, diff -Nru gammaray-2.1.0/ui/propertyeditor/propertyeditordelegate.cpp gammaray-2.2.0-0ubuntu0/ui/propertyeditor/propertyeditordelegate.cpp --- gammaray-2.1.0/ui/propertyeditor/propertyeditordelegate.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/propertyeditor/propertyeditordelegate.cpp 2014-10-15 20:32:50.000000000 +0000 @@ -24,11 +24,16 @@ #include "propertyeditordelegate.h" #include "propertyeditorfactory.h" +#include +#include +#include +#include + using namespace GammaRay; PropertyEditorDelegate::PropertyEditorDelegate(QObject* parent): QStyledItemDelegate(parent) { - setItemEditorFactory(PropertyEditorFactory::instance()); + setItemEditorFactory(PropertyEditorFactory::instance()); } PropertyEditorDelegate::~PropertyEditorDelegate() @@ -37,7 +42,99 @@ void PropertyEditorDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { - editor->setProperty("displayString", index.data(Qt::DisplayRole)); - QStyledItemDelegate::setEditorData(editor, index); + editor->setProperty("displayString", index.data(Qt::DisplayRole)); + QStyledItemDelegate::setEditorData(editor, index); +} + +void PropertyEditorDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + const QVariant value = index.data(Qt::EditRole); + if (value.canConvert()) { + paint(painter, option, index, value.value()); + } else { + QStyledItemDelegate::paint(painter, option, index); + } +} + +QSize PropertyEditorDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + const QVariant value = index.data(Qt::EditRole); + if (value.canConvert()) { + return sizeHint(option, index, value.value()); + } + return QStyledItemDelegate::sizeHint(option, index); +} + +void PropertyEditorDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index, const QMatrix4x4& matrix) const +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QStyleOptionViewItem opt = option; +#else + QStyleOptionViewItemV4 opt = option; +#endif + initStyleOption(&opt, index); + opt.text.clear(); + QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); + + QRect textRect = QApplication::style()->subElementRect(QStyle::SE_ItemViewItemText, &opt, opt.widget); + const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1; + textRect = textRect.adjusted(textMargin, 0, -textMargin, 0); + + static const int parenthesisLineWidth = 1; + const int matrixSpacing = opt.fontMetrics.width("x"); + const int matrixHMargin = matrixSpacing / 2; + const int parenthesisWidth = qMax(matrixHMargin, 3); + + painter->save(); + painter->setClipRect(textRect); + painter->translate(textRect.topLeft()); + painter->setPen(opt.palette.color(opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text)); + int xOffset = 0; + painter->drawLine(xOffset, 0, xOffset, textRect.height()); + painter->drawLine(xOffset, 0, xOffset + parenthesisWidth, 0); + painter->drawLine(xOffset, textRect.height() - 1, xOffset + parenthesisWidth, textRect.height() - 1); + xOffset += matrixHMargin + parenthesisLineWidth; + for (int col = 0; col < 4; ++col) { + const int colWidth = columnWidth(opt, matrix, col); + for (int row = 0; row < 4; ++row) { + const QRect r(xOffset, row * opt.fontMetrics.lineSpacing(), colWidth, opt.fontMetrics.lineSpacing()); + painter->drawText(r, Qt::AlignHCenter | Qt::AlignRight, QString::number(matrix(row, col))); + } + xOffset += colWidth + matrixSpacing; + } + xOffset += -matrixSpacing + matrixHMargin; + painter->drawLine(xOffset, 0, xOffset, textRect.height()); + painter->drawLine(xOffset, 0, xOffset - parenthesisWidth, 0); + painter->drawLine(xOffset, textRect.height() - 1, xOffset - parenthesisWidth, textRect.height() - 1); + painter->restore(); +} + +QSize PropertyEditorDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex &index, const QMatrix4x4& matrix) const +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QStyleOptionViewItem opt = option; +#else + QStyleOptionViewItemV4 opt = option; +#endif + initStyleOption(&opt, index); + + static const int parenthesisLineWidth = 1; + const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1; + + int width = 0; + for (int col = 0; col < 4; ++col) + width += columnWidth(opt, matrix, col); + width += opt.fontMetrics.width("x") * 4 + 2 * parenthesisLineWidth + 2 * textMargin; + + const int height = opt.fontMetrics.lineSpacing() * 4; + + return QSize(width, height); } +int PropertyEditorDelegate::columnWidth(const QStyleOptionViewItem& option, const QMatrix4x4 &matrix, int column) const +{ + int width = 0; + for (int row = 0; row < 4; ++row) + width = qMax(width, option.fontMetrics.width(QString::number(matrix(row, column)))); + return width; +} diff -Nru gammaray-2.1.0/ui/propertyeditor/propertyeditordelegate.h gammaray-2.2.0-0ubuntu0/ui/propertyeditor/propertyeditordelegate.h --- gammaray-2.1.0/ui/propertyeditor/propertyeditordelegate.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/propertyeditor/propertyeditordelegate.h 2014-10-15 20:32:50.000000000 +0000 @@ -27,6 +27,8 @@ #include "gammaray_ui_export.h" #include +class QMatrix4x4; + namespace GammaRay { class GAMMARAY_UI_EXPORT PropertyEditorDelegate : public QStyledItemDelegate @@ -37,6 +39,13 @@ ~PropertyEditorDelegate(); /*override*/ void setEditorData(QWidget* editor, const QModelIndex& index) const; + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + +private: + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex &index, const QMatrix4x4 &matrix) const; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex &index, const QMatrix4x4 &matrix) const; + int columnWidth(const QStyleOptionViewItem& option, const QMatrix4x4& matrix, int column) const; }; } diff -Nru gammaray-2.1.0/ui/tools/modelinspector/modelinspectorwidget.cpp gammaray-2.2.0-0ubuntu0/ui/tools/modelinspector/modelinspectorwidget.cpp --- gammaray-2.1.0/ui/tools/modelinspector/modelinspectorwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/modelinspector/modelinspectorwidget.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -60,6 +62,7 @@ connect(ui->modelView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(modelSelected(QItemSelection))); + new DeferredResizeModeSetter(ui->modelView->header(), 0, QHeaderView::ResizeToContents); ui->modelCellView->setModel(ObjectBroker::model("com.kdab.GammaRay.ModelCellModel")); diff -Nru gammaray-2.1.0/ui/tools/objectinspector/methodsextensionclient.cpp gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodsextensionclient.cpp --- gammaray-2.1.0/ui/tools/objectinspector/methodsextensionclient.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodsextensionclient.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -49,3 +49,8 @@ { Endpoint::instance()->invokeObject(name(), "invokeMethod", QVariantList() << QVariant::fromValue(type)); } + +void MethodsExtensionClient::connectToSignal() +{ + Endpoint::instance()->invokeObject(name(), "connectToSignal"); +} diff -Nru gammaray-2.1.0/ui/tools/objectinspector/methodsextensionclient.h gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodsextensionclient.h --- gammaray-2.1.0/ui/tools/objectinspector/methodsextensionclient.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodsextensionclient.h 2014-10-15 20:32:51.000000000 +0000 @@ -34,11 +34,12 @@ Q_INTERFACES(GammaRay::MethodsExtensionInterface) public: explicit MethodsExtensionClient(const QString &name, QObject *parent = 0); - virtual ~MethodsExtensionClient(); + ~MethodsExtensionClient(); public slots: - virtual void activateMethod(); - virtual void invokeMethod(Qt::ConnectionType type); + void activateMethod(); + void invokeMethod(Qt::ConnectionType type); + void connectToSignal(); }; } diff -Nru gammaray-2.1.0/ui/tools/objectinspector/methodstab.cpp gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodstab.cpp --- gammaray-2.1.0/ui/tools/objectinspector/methodstab.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/objectinspector/methodstab.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -57,6 +57,8 @@ QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(ObjectBroker::model(baseName + '.' + "methods")); + proxy->setSortCaseSensitivity(Qt::CaseInsensitive); + proxy->setSortRole(ObjectMethodModelRole::MethodSignature); m_ui->methodView->setModel(proxy); m_ui->methodView->sortByColumn(0, Qt::AscendingOrder); m_ui->methodView->setSelectionModel(ObjectBroker::selectionModel(proxy)); @@ -79,14 +81,10 @@ } m_interface->activateMethod(); - const QMetaMethod::MethodType methodType = - index.data(ObjectMethodModelRole::MetaMethodType).value(); - if (methodType == QMetaMethod::Slot || methodType == QMetaMethod::Method) { - MethodInvocationDialog dlg(this); - dlg.setArgumentModel(ObjectBroker::model(m_objectBaseName + '.' + "methodArguments")); - if (dlg.exec()) { - m_interface->invokeMethod(dlg.connectionType()); - } + MethodInvocationDialog dlg(this); + dlg.setArgumentModel(ObjectBroker::model(m_objectBaseName + '.' + "methodArguments")); + if (dlg.exec()) { + m_interface->invokeMethod(dlg.connectionType()); } } @@ -100,15 +98,20 @@ const QMetaMethod::MethodType methodType = index.data(ObjectMethodModelRole::MetaMethodType).value(); QMenu contextMenu; + QAction *invokeAction = 0, *connectToAction = 0; if (methodType == QMetaMethod::Slot || methodType == QMetaMethod::Method) { - contextMenu.addAction(tr("Invoke")); + invokeAction = contextMenu.addAction(tr("Invoke")); } else if (methodType == QMetaMethod::Signal) { - contextMenu.addAction(tr("Connect to")); + connectToAction = contextMenu.addAction(tr("Connect to")); + invokeAction = contextMenu.addAction(tr("Emit")); } else { return; // Can't do any action, so don't try to show an empty context menu. } - if (contextMenu.exec(m_ui->methodView->viewport()->mapToGlobal(pos))) { + QAction *action = contextMenu.exec(m_ui->methodView->viewport()->mapToGlobal(pos)); + if (action == invokeAction) { methodActivated(index); + } else if (action == connectToAction) { + m_interface->connectToSignal(); } } diff -Nru gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserclient.cpp gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserclient.cpp --- gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserclient.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserclient.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -24,6 +24,8 @@ #include "resourcebrowserclient.h" +#include + using namespace GammaRay; ResourceBrowserClient::ResourceBrowserClient(QObject *parent) @@ -33,6 +35,9 @@ ResourceBrowserClient::~ResourceBrowserClient() { - } +void ResourceBrowserClient::downloadResource(const QString &sourceFilePath, const QString &targetFilePath) +{ + Endpoint::instance()->invokeObject(objectName(), "downloadResource", QVariantList() << sourceFilePath << targetFilePath); +} diff -Nru gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserclient.h gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserclient.h --- gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserclient.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserclient.h 2014-10-15 20:32:51.000000000 +0000 @@ -36,6 +36,8 @@ public: explicit ResourceBrowserClient(QObject *parent); virtual ~ResourceBrowserClient(); + + void downloadResource(const QString &sourceFilePath, const QString &targetFilePath); }; } diff -Nru gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.cpp gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.cpp --- gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -32,7 +32,9 @@ #include #include +#include #include +#include #include using namespace GammaRay; @@ -53,6 +55,8 @@ connect(m_interface, SIGNAL(resourceDeselected()), this, SLOT(resourceDeselected())); connect(m_interface, SIGNAL(resourceSelected(QPixmap)), this, SLOT(resourceSelected(QPixmap))); connect(m_interface, SIGNAL(resourceSelected(QByteArray)), this, SLOT(resourceSelected(QByteArray))); + connect(m_interface, SIGNAL(resourceDownloaded(QString,QPixmap)), this, SLOT(resourceDownloaded(QString,QPixmap))); + connect(m_interface, SIGNAL(resourceDownloaded(QString,QByteArray)), this, SLOT(resourceDownloaded(QString,QByteArray))); ui->setupUi(this); ClientResourceModel* model = new ClientResourceModel(this); @@ -66,6 +70,9 @@ connect(ui->treeView->model(), SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(rowsInserted())); + ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleCustomContextMenu(QPoint))); + ui->resourceLabel->setText(tr("Select a Resource to Preview")); ui->stackedWidget->setCurrentWidget(ui->contentLabelPage); @@ -126,3 +133,101 @@ ui->stackedWidget->setCurrentWidget(ui->contentTextPage); } +void ResourceBrowserWidget::resourceDownloaded(const QString &targetFilePath, const QPixmap &pixmap) +{ + if (!pixmap.save(targetFilePath)) { + qWarning("Unable to write resource content to %s", qPrintable(targetFilePath)); + return; + } +} + +void ResourceBrowserWidget::resourceDownloaded(const QString &targetFilePath, const QByteArray &contents) +{ + QFile file(targetFilePath); + if (!file.open(QIODevice::WriteOnly)) { + qWarning("Unable to write resource content to %s", qPrintable(targetFilePath)); + return; + } + + file.write(contents); + file.close(); +} + +static QStringList collectDirectories(const QModelIndex &index, const QString &baseDirectory) +{ + QStringList result; + + const QAbstractItemModel *model = index.model(); + const QString directoryPath = index.data(ResourceModel::FilePathRole).toString(); + + const QString relativeDirectory = directoryPath.mid(baseDirectory.size()); + result << relativeDirectory; + + for (int row = 0; row < model->rowCount(index); ++row) { + const QModelIndex childIndex = model->index(row, 0, index); + if (model->hasChildren(childIndex)) + result += collectDirectories(childIndex, baseDirectory); + } + + return result; +} + +static QStringList collectFiles(const QModelIndex &index, const QString &baseDirectory) +{ + QStringList result; + + const QAbstractItemModel *model = index.model(); + for (int row = 0; row < model->rowCount(index); ++row) { + const QModelIndex childIndex = model->index(row, 0, index); + if (model->hasChildren(childIndex)) { + result += collectFiles(childIndex, baseDirectory); + } else { + const QString filePath = childIndex.data(ResourceModel::FilePathRole).toString(); + const QString relativeFilePath = filePath.mid(baseDirectory.size()); + result << relativeFilePath; + } + } + + return result; +} + +void ResourceBrowserWidget::handleCustomContextMenu(const QPoint &pos) +{ + const QModelIndex selectedIndex = ui->treeView->indexAt(pos); + if (!selectedIndex.isValid()) + return; + + QMenu menu; + menu.addAction(tr("Save As...")); + if (!menu.exec(ui->treeView->mapToGlobal(pos))) + return; + + if (selectedIndex.model()->hasChildren(selectedIndex)) { + const QString sourceDirectory = selectedIndex.data(ResourceModel::FilePathRole).toString(); + const QString targetDirectory = QFileDialog::getExistingDirectory(this, tr("Save As")); + + // create local target directory tree + foreach (const QString &directoryPath, collectDirectories(selectedIndex, sourceDirectory)) { + if (directoryPath.isEmpty()) + continue; + + QDir dir(targetDirectory + "/" + directoryPath); + dir.mkpath("."); + } + + // request all resource files + foreach (const QString &filePath, collectFiles(selectedIndex, sourceDirectory)) { + m_interface->downloadResource(sourceDirectory + filePath, targetDirectory + filePath); + } + + } else { + const QString sourceFilePath = selectedIndex.data(ResourceModel::FilePathRole).toString(); + const QString sourceFileName = sourceFilePath.mid(sourceFilePath.lastIndexOf('/') + 1); + + const QString targetFilePath = QFileDialog::getSaveFileName(this, tr("Save As"), sourceFileName); + if (targetFilePath.isEmpty()) + return; + + m_interface->downloadResource(sourceFilePath, targetFilePath); + } +} diff -Nru gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.h gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.h --- gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.h 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.h 2014-10-15 20:32:51.000000000 +0000 @@ -50,6 +50,10 @@ void resourceDeselected(); void resourceSelected(const QPixmap &pixmap); void resourceSelected(const QByteArray &contents); + void resourceDownloaded(const QString &fileName, const QPixmap &pixmap); + void resourceDownloaded(const QString &fileName, const QByteArray &contents); + + void handleCustomContextMenu(const QPoint &pos); private: QScopedPointer ui; diff -Nru gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.ui gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.ui --- gammaray-2.1.0/ui/tools/resourcebrowser/resourcebrowserwidget.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/resourcebrowser/resourcebrowserwidget.ui 2014-10-15 20:32:51.000000000 +0000 @@ -6,17 +6,29 @@ 0 0 - 400 - 300 + 1036 + 846 - + + + 0 + + + 0 + + + 0 + + + 0 + Qt::Horizontal - + @@ -32,46 +44,66 @@ + + 0 + + + 0 + + + 0 + + + 0 + - + + + 0 + + + 0 + + + 0 + + + 0 + - - - Qt::Horizontal + + + QFrame::NoFrame - - - 40 - 20 - + + true - - - - - - + + Qt::AlignCenter + + + + 0 + 0 + 527 + 846 + + + + + + + Qt::AlignCenter + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff -Nru gammaray-2.1.0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.cpp gammaray-2.2.0-0ubuntu0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.cpp --- gammaray-2.1.0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.cpp 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.cpp 2014-10-15 20:32:51.000000000 +0000 @@ -25,8 +25,11 @@ #include "ui_textdocumentinspectorwidget.h" #include "core/tools/textdocumentinspector/textdocumentmodel.h" +#include + #include #include +#include #include @@ -50,6 +53,10 @@ connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(documentElementSelected(QItemSelection,QItemSelection))); ui->documentFormatView->setModel(ObjectBroker::model("com.kdab.GammaRay.TextDocumentFormatModel")); + new DeferredResizeModeSetter(ui->documentFormatView->header(), 0, QHeaderView::ResizeToContents); + + if (Endpoint::instance()->isRemoteClient()) // FIXME: content preview doesn't work remotely yet + ui->tabWidget->hide(); } TextDocumentInspectorWidget::~TextDocumentInspectorWidget() diff -Nru gammaray-2.1.0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.ui gammaray-2.2.0-0ubuntu0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.ui --- gammaray-2.1.0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.ui 2014-07-06 16:08:59.000000000 +0000 +++ gammaray-2.2.0-0ubuntu0/ui/tools/textdocumentinspector/textdocumentinspectorwidget.ui 2014-10-15 20:32:51.000000000 +0000 @@ -55,6 +55,9 @@ + + 10 + true