From f13ee12590d103b3512ba74c0bef3b0817c4c947 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 16 Aug 2012 10:07:31 +0200 Subject: [PATCH] Qt5 fixes Mostly due to the metatobject changes. Also, for some reason, my cmake on the mac refused to create a moc file for coreeventmanager unless there's a *.cpp file --- src/common/basichandler.cpp | 6 ++++- src/common/eventmanager.cpp | 6 ++++- src/common/signalproxy.cpp | 36 ++++++++++++++++++++++++++++++ src/common/syncableobject.cpp | 4 ++++ src/common/types.h | 1 + src/core/CMakeLists.txt | 1 + src/core/coreeventmanager.cpp | 21 +++++++++++++++++ src/uisupport/actioncollection.cpp | 13 ++++++++++- src/uisupport/actioncollection.h | 4 ++++ 9 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 src/core/coreeventmanager.cpp diff --git a/src/common/basichandler.cpp b/src/common/basichandler.cpp index 7e866e95..42841c42 100644 --- a/src/common/basichandler.cpp +++ b/src/common/basichandler.cpp @@ -52,7 +52,11 @@ const QHash &BasicHandler::handlerHash() { if (!_initDone) { for (int i = metaObject()->methodOffset(); i < metaObject()->methodCount(); i++) { - QString methodSignature(metaObject()->method(i).signature()); +#if QT_VERSION >= 0x050000 + QString methodSignature = metaObject()->method(i).methodSignature(); +#else + QString methodSignature = metaObject()->method(i).signature(); +#endif if (methodSignature.startsWith("defaultHandler")) { _defaultHandler = i; continue; diff --git a/src/common/eventmanager.cpp b/src/common/eventmanager.cpp index be16805a..dd3bd4c9 100644 --- a/src/common/eventmanager.cpp +++ b/src/common/eventmanager.cpp @@ -148,7 +148,11 @@ int EventManager::findEventType(const QString &methodSignature_, const QString & void EventManager::registerObject(QObject *object, Priority priority, const QString &methodPrefix, const QString &filterPrefix) { for (int i = object->metaObject()->methodOffset(); i < object->metaObject()->methodCount(); i++) { - QString methodSignature(object->metaObject()->method(i).signature()); +#if QT_VERSION >= 0x050000 + QString methodSignature = object->metaObject()->method(i).methodSignature(); +#else + QString methodSignature = object->metaObject()->method(i).signature(); +#endif int eventType = findEventType(methodSignature, methodPrefix); if (eventType > 0) { diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index 2c9d268a..68125ab6 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -96,7 +96,11 @@ void SignalProxy::SignalRelay::attachSignal(QObject *sender, int signalId, const } else { fn = SIGNAL(fakeMethodSignature()); +#if QT_VERSION >= 0x050000 + fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).methodSignature()); +#else fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature()); +#endif } _slots[slotId] = Signal(sender, signalId, fn); @@ -141,7 +145,11 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void ** const QList &argTypes = eMeta->argTypes(signal.signalId); for (int i = 0; i < argTypes.size(); i++) { if (argTypes[i] == 0) { +#if QT_VERSION >= 0x050000 + qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(_id).methodSignature().constData()); +#else qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(_id).signature()); +#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return _id; } @@ -636,7 +644,11 @@ bool SignalProxy::invokeSlot(QObject *receiver, int methodId, const QVariantList // check for argument compatibility and build params array for (int i = 0; i < numArgs; i++) { if (!params[i].isValid()) { +#if QT_VERSION >= 0x050000 + qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).methodSignature().constData()); +#else qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).signature()); +#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return false; } @@ -805,7 +817,11 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo if (_meta->method(i).methodType() != QMetaMethod::Slot) continue; +#if QT_VERSION >= 0x050000 + if (_meta->method(i).methodSignature().contains('*')) +#else if (QByteArray(_meta->method(i).signature()).contains('*')) +#endif continue; // skip methods with ptr params QByteArray method = methodName(_meta->method(i)); @@ -834,7 +850,11 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo } if (checkConflicts) { qWarning() << "class" << meta->className() << "contains overloaded methods which is currently not supported!"; +#if QT_VERSION >= 0x050000 + qWarning() << " - " << _meta->method(i).methodSignature() << "conflicts with" << _meta->method(_methodIds[method]).methodSignature(); +#else qWarning() << " - " << _meta->method(i).signature() << "conflicts with" << _meta->method(_methodIds[method]).signature(); +#endif } continue; } @@ -874,7 +894,11 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() if (QMetaType::Void == (QMetaType::Type)returnType(i)) continue; +#if QT_VERSION >= 0x050000 + signature = requestSlot.methodSignature(); +#else signature = QByteArray(requestSlot.signature()); +#endif if (!signature.startsWith("request")) continue; @@ -908,14 +932,22 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() QByteArray SignalProxy::ExtendedMetaObject::methodName(const QMetaMethod &method) { +#if QT_VERSION >= 0x050000 + QByteArray sig(method.methodSignature()); +#else QByteArray sig(method.signature()); +#endif return sig.left(sig.indexOf("(")); } QString SignalProxy::ExtendedMetaObject::methodBaseName(const QMetaMethod &method) { +#if QT_VERSION >= 0x050000 + QString methodname = QString(method.methodSignature()).section("(", 0, 0); +#else QString methodname = QString(method.signature()).section("(", 0, 0); +#endif // determine where we have to chop: int upperCharPos; @@ -953,7 +985,11 @@ SignalProxy::ExtendedMetaObject::MethodDescriptor::MethodDescriptor(const QMetaM _argTypes = argTypes; // determine minArgCount +#if QT_VERSION >= 0x050000 + QString signature(method.methodSignature()); +#else QString signature(method.signature()); +#endif _minArgCount = method.parameterTypes().count() - signature.count("="); _receiverMode = (_methodName.startsWith("request")) diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index 144dddf3..3d058caa 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -114,7 +114,11 @@ QVariantMap SyncableObject::toVariantMap() QVariant::Type variantType = QVariant::nameToType(method.typeName()); if (variantType == QVariant::Invalid && !QByteArray(method.typeName()).isEmpty()) { +#if QT_VERSION >= 0x050000 + qWarning() << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.methodSignature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName()); +#else qWarning() << "SyncableObject::toVariantMap(): cannot fetch init data for:" << this << method.signature() << "- Returntype is unknown to Qt's MetaSystem:" << QByteArray(method.typeName()); +#endif continue; } diff --git a/src/common/types.h b/src/common/types.h index 6c2ee04e..c9891231 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e3372355..cd298759 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -12,6 +12,7 @@ set(SOURCES corebufferviewconfig.cpp corebufferviewmanager.cpp corecoreinfo.cpp + coreeventmanager.cpp coreidentity.cpp coreignorelistmanager.cpp coreircchannel.cpp diff --git a/src/core/coreeventmanager.cpp b/src/core/coreeventmanager.cpp new file mode 100644 index 00000000..8aeb149c --- /dev/null +++ b/src/core/coreeventmanager.cpp @@ -0,0 +1,21 @@ +/*************************************************************************** + * Copyright (C) 2012 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "coreeventmanager.h" diff --git a/src/uisupport/actioncollection.cpp b/src/uisupport/actioncollection.cpp index 7dc03909..4ebb65b0 100644 --- a/src/uisupport/actioncollection.cpp +++ b/src/uisupport/actioncollection.cpp @@ -202,12 +202,19 @@ void ActionCollection::actionDestroyed(QObject *obj) unlistAction(action); } - +#if QT_VERSION >= 0x050000 +void ActionCollection::connectNotify(const QMetaMethod &method) +#else void ActionCollection::connectNotify(const char *signal) +#endif { if (_connectHovered && _connectTriggered) return; +#if QT_VERSION >= 0x050000 + QByteArray signal = method.methodSignature(); +#endif + if (QMetaObject::normalizedSignature(SIGNAL(actionHovered(QAction *))) == signal) { if (!_connectHovered) { _connectHovered = true; @@ -223,7 +230,11 @@ void ActionCollection::connectNotify(const char *signal) } } +#if QT_VERSION >= 0x050000 + QObject::connectNotify(method); +#else QObject::connectNotify(signal); +#endif } diff --git a/src/uisupport/actioncollection.h b/src/uisupport/actioncollection.h index 0eb9d558..22b07485 100644 --- a/src/uisupport/actioncollection.h +++ b/src/uisupport/actioncollection.h @@ -96,7 +96,11 @@ signals: void actionTriggered(QAction *action); protected slots: +#if QT_VERSION >= 0x050000 + virtual void connectNotify(const QMetaMethod &method); +#else virtual void connectNotify(const char *signal); +#endif virtual void slotActionTriggered(); private slots: -- 2.20.1