fixes #513 - crash when connection fails
[quassel.git] / src / common / types.h
index 381c5d6..104deb7 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -24,6 +24,7 @@
 #include <QDebug>
 #include <QString>
 #include <QVariant>
+#include <QTextStream>
 
 class SignedId {
   protected:
@@ -37,6 +38,7 @@ class SignedId {
     inline bool operator==(const SignedId &other) const { return id == other.id; }
     inline bool operator!=(const SignedId &other) const { return id != other.id; }
     inline bool operator<(const SignedId &other) const { return id < other.id; }
+    inline bool operator<=(const SignedId &other) const { return id <= other.id; }
     inline bool operator>(const SignedId &other) const { return id > other.id; }
     inline bool operator>=(const SignedId &other) const { return id >= other.id; }
     inline bool operator==(int i) const { return id == i; }
@@ -53,6 +55,7 @@ class SignedId {
 
 inline QDataStream &operator<<(QDataStream &out, const SignedId &signedId) { out << signedId.toInt(); return out; }
 inline QDataStream &operator>>(QDataStream &in, SignedId &signedId) { in >> signedId.id; return in; }
+inline QTextStream &operator<<(QTextStream &out, const SignedId &signedId) { out << QString::number(signedId.toInt()); return out; }
 inline QDebug operator<<(QDebug dbg, const SignedId &signedId) { dbg.space() << signedId.toInt(); return dbg; }
 inline uint qHash(const SignedId &id) { return qHash(id.toInt()); }
 
@@ -85,12 +88,12 @@ struct AccountId : public SignedId {
   inline AccountId(int _id = 0) : SignedId(_id) {};
 };
 
-Q_DECLARE_METATYPE(UserId);
-Q_DECLARE_METATYPE(MsgId);
-Q_DECLARE_METATYPE(BufferId);
-Q_DECLARE_METATYPE(NetworkId);
-Q_DECLARE_METATYPE(IdentityId);
-Q_DECLARE_METATYPE(AccountId);
+Q_DECLARE_METATYPE(UserId)
+Q_DECLARE_METATYPE(MsgId)
+Q_DECLARE_METATYPE(BufferId)
+Q_DECLARE_METATYPE(NetworkId)
+Q_DECLARE_METATYPE(IdentityId)
+Q_DECLARE_METATYPE(AccountId)
 
 //! Base class for exceptions.
 struct Exception {