PacketModel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PACKETMODEL_H
00024 #define PACKETMODEL_H
00025
00026 #include "Gnutella/Namespace.h"
00027 #include "Gnutella/Packets/Namespace.h"
00028
00029 enum Packets {ping=0x00, pong=0x02, query=0x04, queryHit=0x08, queryRoutingReset=0x10, queryRoutingPatch=0x20,
00030 incomming=0x40, outgoing=0x80};
00031 Q_DECLARE_FLAGS(PacketFlags, Packets)
00032 Q_DECLARE_OPERATORS_FOR_FLAGS(PacketFlags)
00033
00034 #define MAX_ITEMS_TO_HOLD 50
00035
00036 using Gnutella::LocalPeer;
00037 using Gnutella::Packets::Packet;
00038
00039 class PacketModel : public QAbstractTableModel
00040 {
00041 Q_OBJECT
00042
00043 public:
00044 enum Direction
00045 {
00046 Incomming,
00047 Outgoing
00048 };
00049
00050 PacketModel();
00051 ~PacketModel();
00052
00053 int rowCount (const QModelIndex &parent = QModelIndex()) const;
00054 int columnCount (const QModelIndex &parent = QModelIndex()) const;
00055 QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
00056 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00057
00058 bool insertPacket (const Packet *packet, Direction direction);
00059 void setFlags (PacketFlags &falgs);
00060
00061 private:
00062
00063
00064
00065
00066
00067
00068
00069
00070 struct PacketInfo
00071 {
00072
00073 QString timestamp;
00074 QString packetName;
00075 uchar packetTtl;
00076 uchar packetHops;
00077 QString packetDescriptorId;
00078 QString packetRawPayload;
00079 Direction direction;
00080
00081 PacketInfo() : timestamp(), packetName(), packetTtl (0), packetHops (0),
00082 packetDescriptorId(), packetRawPayload(),
00083 direction (Incomming)
00084 {}
00085 };
00086
00087 typedef QList <PacketInfo *> PacketList;
00088 PacketList packetList;
00089
00090 QIcon inIcon;
00091 QIcon outIcon;
00092
00093
00094 public:
00095 PacketFlags packetFlags;
00096 QMap<QString, int> flagValues;
00097 };
00098
00099 #endif // _PACKETMODEL_H