X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fbufferinfo.h;h=7bfde0c3a67706c4eabb79826afcb34976df9446;hp=82293634caf95247ab41e6ecb3287e23cb21fac6;hb=HEAD;hpb=45d9ea6ed5d64eec3ca351fdcf7610c7cff3529d diff --git a/src/common/bufferinfo.h b/src/common/bufferinfo.h index 82293634..7bfde0c3 100644 --- a/src/common/bufferinfo.h +++ b/src/common/bufferinfo.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,49 +15,74 @@ * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef _BUFFERINFO_H_ -#define _BUFFERINFO_H_ -#include +#pragma once + +#include "common-export.h" + +#include "types.h" class QString; class QDataStream; -class BufferInfo { +class COMMON_EXPORT BufferInfo +{ public: - BufferInfo(); - BufferInfo(uint id, uint networkid, uint gid = 0, QString net = QString(), QString buf = QString()); - - inline uint uid() const { return _id; } - inline uint networkId() const { return _netid; } - inline uint groupId() const { return _gid; } - inline QString network() const { return _networkName; } - QString buffer() const; - - void setGroupId(uint gid) { _gid = gid; } - - inline bool operator==(const BufferInfo &other) const { return _id == other._id; } + enum Type + { + InvalidBuffer = 0x00, + StatusBuffer = 0x01, + ChannelBuffer = 0x02, + QueryBuffer = 0x04, + GroupBuffer = 0x08 + }; + + enum Activity + { + NoActivity = 0x00, + OtherActivity = 0x01, + NewMessage = 0x02, + Highlight = 0x40 + }; + Q_DECLARE_FLAGS(ActivityLevel, Activity) + + BufferInfo(); + BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid = 0, QString buf = QString()); + + static BufferInfo fakeStatusBuffer(NetworkId networkId); + + inline bool isValid() const { return _bufferId != 0; } + inline const BufferId& bufferId() const { return _bufferId; } + inline void setBufferId(BufferId id) { _bufferId = id; } + inline const NetworkId& networkId() const { return _netid; } + inline const Type& type() const { return _type; } + inline const uint& groupId() const { return _groupId; } + void setGroupId(uint gid) { _groupId = gid; } + + QString bufferName() const; + bool acceptsRegularMessages() const; + + inline bool operator==(const BufferInfo& other) const { return _bufferId == other._bufferId; } private: - uint _id; - uint _netid; - uint _gid; - QString _networkName; // WILL BE REMOVED - QString _bufferName; - - friend uint qHash(const BufferInfo &); - friend QDataStream &operator<<(QDataStream &out, const BufferInfo &bufferInfo); - friend QDataStream &operator>>(QDataStream &in, BufferInfo &bufferInfo); -}; + BufferId _bufferId; + NetworkId _netid; + Type _type{InvalidBuffer}; + uint _groupId{0}; + QString _bufferName; -QDataStream &operator<<(QDataStream &out, const BufferInfo &bufferInfo); -QDataStream &operator>>(QDataStream &in, BufferInfo &bufferInfo); -QDebug operator<<(QDebug dbg, const BufferInfo &b); + friend uint qHash(const BufferInfo&); + friend QDataStream& operator<<(QDataStream& out, const BufferInfo& bufferInfo); + friend QDataStream& operator>>(QDataStream& in, BufferInfo& bufferInfo); +}; -Q_DECLARE_METATYPE(BufferInfo); +QDataStream& operator<<(QDataStream& out, const BufferInfo& bufferInfo); +QDataStream& operator>>(QDataStream& in, BufferInfo& bufferInfo); +QDebug operator<<(QDebug dbg, const BufferInfo& b); -uint qHash(const BufferInfo &); +Q_DECLARE_METATYPE(BufferInfo) +Q_DECLARE_OPERATORS_FOR_FLAGS(BufferInfo::ActivityLevel) -#endif +uint qHash(const BufferInfo&);