Make MsgId work properly with QVariant
[quassel.git] / src / common / global.cpp
index cdb3376..300d182 100644 (file)
@@ -1,11 +1,11 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   Copyright (C) 2005-08 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) any later version.                                   *
+ *   (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        *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 #include <QObject>
-#include <QStringList>
+#include <QMetaType>
 
 #include "global.h"
 #include "logger.h"
 #include "message.h"
-#include "util.h"
+#include "identity.h"
+#include "network.h"
+#include "bufferinfo.h"
+#include "types.h"
+#include "syncableobject.h"
 
 extern void messageHandler(QtMsgType type, const char *msg);
 
@@ -59,5 +63,53 @@ void Global::initIconMap() {
 //  return 0;
 //}
 
+//! Register our custom types with Qt's Meta Object System.
+/**  This makes them available for QVariant and in signals/slots, among other things.
+ *
+ */
+void Global::registerMetaTypes() {
+  // Complex types
+  qRegisterMetaType<QVariant>("QVariant");
+  qRegisterMetaType<Message>("Message");
+  qRegisterMetaType<BufferInfo>("BufferInfo");
+  qRegisterMetaType<NetworkInfo>("NetworkInfo");
+  qRegisterMetaType<Identity>("Identity");
+  qRegisterMetaType<Network::ConnectionState>("Network::ConnectionState");
+
+  qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
+  qRegisterMetaTypeStreamOperators<Message>("Message");
+  qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
+  qRegisterMetaTypeStreamOperators<NetworkInfo>("NetworkInfo");
+  qRegisterMetaTypeStreamOperators<Identity>("Identity");
+  qRegisterMetaTypeStreamOperators<qint8>("Network::ConnectionState");
+
+  qRegisterMetaType<IdentityId>("IdentityId");
+  qRegisterMetaType<BufferId>("BufferId");
+  qRegisterMetaType<NetworkId>("NetworkId");
+  qRegisterMetaType<UserId>("UserId");
+  qRegisterMetaType<AccountId>("AccountId");
+  qRegisterMetaType<MsgId>("MsgId");
+
+  qRegisterMetaTypeStreamOperators<IdentityId>("IdentityId");
+  qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
+  qRegisterMetaTypeStreamOperators<NetworkId>("NetworkId");
+  qRegisterMetaTypeStreamOperators<UserId>("UserId");
+  qRegisterMetaTypeStreamOperators<AccountId>("AccountId");
+  qRegisterMetaTypeStreamOperators<MsgId>("MsgId");
+
+}
+
+// Static variables
+
+QString Global::quasselVersion;
+QString Global::quasselDate;
+uint Global::quasselBuild;
+uint Global::clientBuildNeeded;
+QString Global::clientVersionNeeded;
+uint Global::coreBuildNeeded;
+QString Global::coreVersionNeeded;
+
 Global::RunMode Global::runMode;
-QString Global::quasselDir;
+uint Global::defaultPort;
+
+bool Global::SPUTDEV;