~ubuntu-branches/debian/experimental/quassel/experimental

« back to all changes in this revision

Viewing changes to src/qtui/chatitem.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Mueller
  • Date: 2009-10-05 23:13:06 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091005231306-ngiajv5r0gbxjfoq
Tags: 0.5.0~rc2-1
* New upstream release (rc2)
* Make puiparts happy (closes: #538182)
* manageusers.py added (closes: #549296)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "chatlinemodel.h"
29
29
#include "chatscene.h"
 
30
#include "clickable.h"
30
31
#include "uistyle.h"
31
32
#include "qtui.h"
32
33
 
48
49
 
49
50
  void initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode, Qt::Alignment = Qt::AlignLeft) const;
50
51
  virtual inline void initLayout(QTextLayout *layout) const {
51
 
    initLayoutHelper(layout, QTextOption::WrapAnywhere);
 
52
    initLayoutHelper(layout, QTextOption::NoWrap);
52
53
    doLayout(layout);
53
54
  }
54
55
  virtual void doLayout(QTextLayout *) const;
 
56
  virtual UiStyle::FormatList formatList() const;
55
57
 
56
58
  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
57
59
  enum { Type = ChatScene::ChatItemType };
83
85
  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
84
86
  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
85
87
 
86
 
  virtual QTextLayout::FormatRange selectionFormat() const;
87
 
  virtual inline QVector<QTextLayout::FormatRange> additionalFormats() const { return QVector<QTextLayout::FormatRange>(); }
 
88
  void paintBackground(QPainter *);
 
89
  QVector<QTextLayout::FormatRange> selectionFormats() const;
 
90
  virtual QVector<QTextLayout::FormatRange> additionalFormats() const;
 
91
  void overlayFormat(UiStyle::FormatList &fmtList, int start, int end, quint32 overlayFmt) const;
88
92
 
89
93
  inline qint16 selectionStart() const { return _selectionStart; }
90
94
  inline void setSelectionStart(qint16 start) { _selectionStart = start; }
171
175
  virtual inline int type() const { return Type; }
172
176
 
173
177
  inline ChatLineModel::ColumnType column() const { return ChatLineModel::ContentsColumn; }
174
 
  inline QFontMetricsF *fontMetrics() const { return _fontMetrics; }
 
178
  QFontMetricsF *fontMetrics() const;
175
179
 
176
180
protected:
177
181
  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
185
189
  virtual QVector<QTextLayout::FormatRange> additionalFormats() const;
186
190
 
187
191
  virtual inline void initLayout(QTextLayout *layout) const {
188
 
    initLayoutHelper(layout, QTextOption::WrapAnywhere);
 
192
    initLayoutHelper(layout, QTextOption::WrapAtWordBoundaryOrAnywhere);
189
193
    doLayout(layout);
190
194
  }
191
195
  virtual void doLayout(QTextLayout *layout) const;
 
196
  virtual UiStyle::FormatList formatList() const;
192
197
 
193
198
private:
194
 
  struct Clickable;
195
199
  class ActionProxy;
196
200
  class WrapColumnFinder;
197
201
 
198
202
  ContentsChatItemPrivate *_data;
199
203
  ContentsChatItemPrivate *privateData() const;
200
204
 
201
 
  QList<Clickable> findClickables() const;
202
205
  Clickable clickableAt(const QPointF &pos) const;
203
206
 
204
207
  void endHoverMode();
215
218
  static ActionProxy _actionProxy;
216
219
};
217
220
 
218
 
struct ContentsChatItem::Clickable {
219
 
  // Don't change these enums without also changing the regexps in analyze()!
220
 
  enum Type {
221
 
    Invalid = -1,
222
 
    Url = 0,
223
 
    Channel = 1,
224
 
    Nick = 2
225
 
  };
226
 
 
227
 
  Type type;
228
 
  quint16 start;
229
 
  quint16 length;
230
 
 
231
 
  inline Clickable() : type(Invalid) {};
232
 
  inline Clickable(Type type_, quint16 start_, quint16 length_) : type(type_), start(start_), length(length_) {};
233
 
  inline bool isValid() const { return type != Invalid; }
234
 
};
235
 
 
236
221
struct ContentsChatItemPrivate {
237
222
  ContentsChatItem *contentsItem;
238
 
  QList<ContentsChatItem::Clickable> clickables;
239
 
  ContentsChatItem::Clickable currentClickable;
240
 
  ContentsChatItem::Clickable activeClickable;
 
223
  ClickableList clickables;
 
224
  Clickable currentClickable;
 
225
  Clickable activeClickable;
241
226
 
242
 
  ContentsChatItemPrivate(const QList<ContentsChatItem::Clickable> &c, ContentsChatItem *parent) : contentsItem(parent), clickables(c) {}
 
227
  ContentsChatItemPrivate(const ClickableList &c, ContentsChatItem *parent) : contentsItem(parent), clickables(c) {}
243
228
};
244
229
 
245
230
class ContentsChatItem::WrapColumnFinder {
247
232
  WrapColumnFinder(const ChatItem *parent);
248
233
  ~WrapColumnFinder();
249
234
 
250
 
  qint16 nextWrapColumn();
 
235
  qint16 nextWrapColumn(qreal width);
251
236
 
252
237
private:
253
238
  const ChatItem *item;