Provide a contextmenu for the ignore list
[quassel.git] / src / common / types.h
index 64bfbbc..fc46881 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  *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _TYPES_H_
-#define _TYPES_H_
+#ifndef TYPES_H_
+#define TYPES_H_
 
 #include <QDebug>
 #include <QString>
 #include <QVariant>
+#include <QTextStream>
 
 class SignedId {
   protected:
@@ -32,10 +33,14 @@ class SignedId {
   public:
     inline SignedId(int _id = 0) { id = _id; }
     inline qint32 toInt() const { return id; }
+    inline bool isValid() const { return id > 0; }
 
     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; }
     inline bool operator!=(int i) const { return id != i; }
     inline bool operator<(int i) const { return id < i; }
@@ -50,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()); }
 
@@ -78,11 +84,20 @@ struct IdentityId : public SignedId {
   //inline operator QVariant() const { return QVariant::fromValue<IdentityId>(*this); }
 };
 
-Q_DECLARE_METATYPE(UserId);
-Q_DECLARE_METATYPE(MsgId);
-Q_DECLARE_METATYPE(BufferId);
-Q_DECLARE_METATYPE(NetworkId);
-Q_DECLARE_METATYPE(IdentityId);
+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)
+
+// a few typedefs
+typedef QList<MsgId> MsgIdList;
+typedef QList<BufferId> BufferIdList;
 
 //! Base class for exceptions.
 struct Exception {
@@ -92,7 +107,6 @@ struct Exception {
 
   protected:
     QString _msg;
-
 };
 
 #endif