Qt5 fixes
authorHarald Fernengel <harald.fernengel@nokia.com>
Thu, 16 Aug 2012 08:07:31 +0000 (10:07 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 24 Mar 2014 23:21:25 +0000 (00:21 +0100)
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
src/common/eventmanager.cpp
src/common/signalproxy.cpp
src/common/syncableobject.cpp
src/common/types.h
src/core/CMakeLists.txt
src/core/coreeventmanager.cpp [new file with mode: 0644]
src/uisupport/actioncollection.cpp
src/uisupport/actioncollection.h

index 7e866e9..42841c4 100644 (file)
@@ -52,7 +52,11 @@ const QHash<QString, int> &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;
index be16805..dd3bd4c 100644 (file)
@@ -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) {
index 2c9d268..68125ab 100644 (file)
@@ -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<int> &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<int, int> &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<int, int> &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"))
index 144dddf..3d058ca 100644 (file)
@@ -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;
         }
 
index 6c2ee04..c989123 100644 (file)
@@ -24,6 +24,7 @@
 #include <QDebug>
 #include <QString>
 #include <QVariant>
+#include <QDataStream>
 #include <QTextStream>
 #include <QHostAddress>
 #include <QDataStream>
index e337235..cd29875 100644 (file)
@@ -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 (file)
index 0000000..8aeb149
--- /dev/null
@@ -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"
index 7dc0390..4ebb65b 100644 (file)
@@ -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
 }
 
 
index 0eb9d55..22b0748 100644 (file)
@@ -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: