~ubuntu-branches/ubuntu/jaunty/quassel/jaunty-backports

« back to all changes in this revision

Viewing changes to src/client/messagemodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-11-17 15:22:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081117152246-3lwlpnr4r08910kv
Tags: 0.3.1-0ubuntu1
* New upstream release (LP: #271403)
* Drop all patches originated from upstream (quassel_*)
* Compile with non-builtin quassel icons
  + Introduce new quassel-data package
  + quassel and quassel-client depend on quassel-data
  + Don't manually enforce icon installation for desktop files in debian/rules
  + Add quassel_01_fix_iconloader.patch
* Drop perl build dependency, I have no clue why it was added in the first
  place. Neither changelog nor Bazaar knows, and since quassel compiles just
  fine without it, removing it should be save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    TimestampRole,
45
45
    FormatRole,
46
46
    ColumnTypeRole,
 
47
    RedirectedToRole,
47
48
    UserRole
48
49
  };
49
50
 
55
56
 
56
57
  inline QModelIndex index(int row, int column, const QModelIndex &/*parent*/ = QModelIndex()) const { return createIndex(row, column); }
57
58
  inline QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
58
 
  inline int rowCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return _messageList.count(); }
 
59
  inline int rowCount(const QModelIndex &parent = QModelIndex()) const { return parent.isValid() ? 0 : _messageList.count(); }
59
60
  inline int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 3; }
60
61
 
61
62
  virtual QVariant data(const QModelIndex &index, int role) const;
68
69
 
69
70
  void clear();
70
71
 
 
72
public slots:
 
73
  void requestBacklog(BufferId bufferId);
 
74
  void messagesReceived(BufferId bufferId, int count);
 
75
 
71
76
protected:
72
77
  virtual MessageModelItem *createMessageModelItem(const Message &) = 0;
 
78
  virtual void customEvent(QEvent *event);
 
79
 
 
80
private slots:
 
81
  void changeOfDay();
73
82
 
74
83
private:
 
84
  void insertMessageGroup(const QList<Message> &);
 
85
  int insertMessagesGracefully(const QList<Message> &); // inserts as many contiguous msgs as possible. returns numer of inserted msgs.
 
86
  int indexForId(MsgId);
 
87
 
75
88
  QList<MessageModelItem *> _messageList;
76
 
 
77
 
  int indexForId(MsgId);
 
89
  QList<Message> _messageBuffer;
 
90
  QTimer _dayChangeTimer;
 
91
  QDateTime _nextDayChange;
 
92
  QHash<BufferId, int> _messagesWaiting;
78
93
};
79
94
 
 
95
// **************************************************
 
96
//  MessageModelItem
 
97
// **************************************************
80
98
class MessageModelItem {
81
99
public:
82
100
  //! Creates a MessageModelItem from a Message object.
88
106
  inline virtual ~MessageModelItem() {}
89
107
 
90
108
  virtual QVariant data(int column, int role) const;
91
 
  virtual bool setData(int column, const QVariant &value, int role) = 0;
 
109
  virtual bool setData(int column, const QVariant &value, int role);
92
110
 
93
111
  inline const QDateTime &timeStamp() const { return _timestamp; }
94
112
  inline MsgId msgId() const { return _msgId; }
96
114
  inline Message::Type msgType() const { return _type; }
97
115
  inline Message::Flags msgFlags() const { return _flags; }
98
116
  
 
117
  // For sorting
 
118
  bool operator<(const MessageModelItem &) const;
 
119
  bool operator==(const MessageModelItem &) const;
 
120
  bool operator>(const MessageModelItem &) const;
 
121
  static bool lessThan(const MessageModelItem *m1, const MessageModelItem *m2);
 
122
 
99
123
private:
100
124
  QDateTime _timestamp;
101
125
  MsgId _msgId;
102
126
  BufferId _bufferId;
 
127
  BufferId _redirectedTo;
103
128
  Message::Type _type;
104
129
  Message::Flags _flags;
105
130
};
106
131
 
 
132
QDebug operator<<(QDebug dbg, const MessageModelItem &msgItem);
 
133
 
107
134
#endif