Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
ChatScene Class Reference

#include </tmp/quassel/src/qtui/chatscene.h>

Collaboration diagram for ChatScene:

Public Types

enum  CutoffMode { CutoffLeft, CutoffRight }
enum  ItemType {
  ChatLineType = QGraphicsItem::UserType + 1, ChatItemType, TimestampChatItemType, SenderChatItemType,
  ContentsChatItemType, SearchHighlightType, WebPreviewType, ColumnHandleType,
  MarkerLineType
}
enum  ClickMode {
  NoClick, DragStartClick, SingleClick, DoubleClick,
  TripleClick
}

Public Slots

void updateForViewport (qreal width, qreal height)
void setWidth (qreal width)
void layout (int start, int end, qreal width)
void resetColumnWidths ()
void setMarkerLineVisible (bool visible=true)
void setMarkerLine (MsgId msgId=MsgId())
void jumpToMarkerLine (bool requestBacklog)
void setSelectingItem (ChatItem *item)
ChatItemselectingItem () const
void startGlobalSelection (ChatItem *item, const QPointF &itemPos)
void clearGlobalSelection ()
void clearSelection ()
void selectionToClipboard (QClipboard::Mode=QClipboard::Clipboard)
void stringToClipboard (const QString &str, QClipboard::Mode=QClipboard::Clipboard)
void webSearchOnSelection ()
void requestBacklog ()

Signals

void lastLineChanged (QGraphicsItem *item, qreal offset)
void layoutChanged ()
void mouseMoveWhileSelecting (const QPointF &scenePos)

Public Member Functions

 ChatScene (QAbstractItemModel *model, const QString &idString, qreal width, ChatView *parent)
virtual ~ChatScene ()
QAbstractItemModel * model () const
MessageFilterfilter () const
QString idString () const
int rowByScenePos (qreal y) const
int rowByScenePos (const QPointF &pos) const
ChatLineModel::ColumnType columnByScenePos (qreal x) const
ChatLineModel::ColumnType columnByScenePos (const QPointF &pos) const
ChatViewchatView () const
ChatItemchatItemAt (const QPointF &pos) const
ChatLinechatLine (int row) const
ChatLinechatLine (const QModelIndex &index) const
ChatLinechatLine (MsgId msgId, bool matchExact=true, bool ignoreDayChange=true) const
 Find the ChatLine belonging to a MsgId.
ChatLinelastLine () const
MarkerLineItemmarkerLine () const
bool isSingleBufferScene () const
BufferId singleBufferId () const
bool containsBuffer (const BufferId &id) const
ColumnHandleItemfirstColumnHandle () const
ColumnHandleItemsecondColumnHandle () const
CutoffMode senderCutoffMode () const
void setSenderCutoffMode (CutoffMode mode)
QString selection () const
 Convert current selection to human-readable string.
bool hasSelection () const
bool hasGlobalSelection () const
bool isPosOverSelection (const QPointF &) const
bool isGloballySelecting () const
void initiateDrag (QWidget *source)
bool isScrollingAllowed () const

Protected Slots

void rowsInserted (const QModelIndex &, int, int)
void rowsAboutToBeRemoved (const QModelIndex &, int, int)
void dataChanged (const QModelIndex &, const QModelIndex &)

Protected Member Functions

virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *contextMenuEvent)
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)
virtual void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent)
virtual void handleClick (Qt::MouseButton button, const QPointF &scenePos)

Private Slots

void firstHandlePositionChanged (qreal xpos)
void secondHandlePositionChanged (qreal xpos)
void showWebPreviewChanged ()
void rowsRemoved ()
void clickTimeout ()

Private Member Functions

void setHandleXLimits ()
void updateSelection (const QPointF &pos)
void updateSceneRect (qreal width)
void updateSceneRect ()
void updateSceneRect (const QRectF &rect)

Private Attributes

ChatView_chatView
QString _idString
QAbstractItemModel * _model
QList< ChatLine * > _lines
BufferId _singleBufferId
QRectF _sceneRect
int _firstLineRow
qreal _viewportHeight
MarkerLineItem_markerLine
bool _markerLineVisible
bool _markerLineValid
bool _markerLineJumpPending
ColumnHandleItem_firstColHandle
ColumnHandleItem_secondColHandle
qreal _firstColHandlePos
qreal _secondColHandlePos
int _defaultFirstColHandlePos
int _defaultSecondColHandlePos
CutoffMode _cutoffMode
ChatItem_selectingItem
int _selectionStartCol
int _selectionMinCol
int _selectionStart
int _selectionEnd
int _firstSelectionRow
bool _isSelecting
QTimer _clickTimer
ClickMode _clickMode
QPointF _clickPos
bool _clickHandled
bool _leftButtonPressed
bool _showWebPreview

Static Private Attributes

static const int _webSearchSelectionTextMaxVisible = 24

Detailed Description

Definition at line 45 of file chatscene.h.

Member Enumeration Documentation

enum CutoffMode
Enumerator:
CutoffLeft 
CutoffRight 

Definition at line 50 of file chatscene.h.

enum ItemType
Enumerator:
ChatLineType 
ChatItemType 
TimestampChatItemType 
SenderChatItemType 
ContentsChatItemType 
SearchHighlightType 
WebPreviewType 
ColumnHandleType 
MarkerLineType 

Definition at line 55 of file chatscene.h.

enum ClickMode
Enumerator:
NoClick 
DragStartClick 
SingleClick 
DoubleClick 
TripleClick 

Definition at line 67 of file chatscene.h.

Constructor & Destructor Documentation

~ChatScene ( )
virtual

Definition at line 140 of file chatscene.cpp.

Member Function Documentation

MessageFilter* filter ( ) const
inline

Definition at line 79 of file chatscene.h.

References _model.

Referenced by ChatScene(), containsBuffer(), contextMenuEvent(), ChatView::invalidateFilter(), and requestBacklog().

QString idString ( ) const
inline

Definition at line 80 of file chatscene.h.

References _idString.

int rowByScenePos ( qreal  y) const

Definition at line 1113 of file chatscene.cpp.

References ChatLine::row().

Referenced by updateSelection().

int rowByScenePos ( const QPointF &  pos) const
inline

Definition at line 83 of file chatscene.h.

References rowByScenePos().

Referenced by rowByScenePos().

ChatLineModel::ColumnType columnByScenePos ( const QPointF &  pos) const
inline

Definition at line 85 of file chatscene.h.

References columnByScenePos().

Referenced by columnByScenePos().

ChatView * chatView ( ) const

Definition at line 145 of file chatscene.cpp.

References _chatView.

Referenced by ChatItem::chatView(), ChatLine::chatView(), contextMenuEvent(), and ChatLine::sceneEvent().

ChatItem * chatItemAt ( const QPointF &  pos) const
ChatLine* chatLine ( int  row) const
inline
ChatLine* chatLine ( const QModelIndex &  index) const
inline

Definition at line 90 of file chatscene.h.

References _lines.

ChatLine * chatLine ( MsgId  msgId,
bool  matchExact = true,
bool  ignoreDayChange = true 
) const

Find the ChatLine belonging to a MsgId.

Searches for the ChatLine belonging to a MsgId. If there are more than one ChatLine with the same msgId, the first one is returned. Note that this method performs a binary search, hence it has as complexity of O(log n). If matchExact is false, and we don't have an exact match for the given msgId, we return the visible line right above the requested one.

Parameters
msgIdThe message ID to look for
matchExactWhether we find only exact matches
ignoreDayChangeWhether we ignore day change messages
Returns
The ChatLine corresponding to the given MsgId

Definition at line 174 of file chatscene.cpp.

References _lines.

ChatLine* lastLine ( ) const
inline

Definition at line 105 of file chatscene.h.

References _lines.

Referenced by updateSceneRect().

MarkerLineItem* markerLine ( ) const
inline
bool isSingleBufferScene ( ) const
inline

Definition at line 109 of file chatscene.h.

References _singleBufferId, and SignedId::isValid().

Referenced by jumpToMarkerLine(), and setMarkerLine().

BufferId singleBufferId ( ) const
inline
bool containsBuffer ( const BufferId id) const

Definition at line 244 of file chatscene.cpp.

References MessageFilter::containsBuffer(), filter(), and model().

ColumnHandleItem * firstColumnHandle ( ) const

Definition at line 151 of file chatscene.cpp.

References _firstColHandle.

Referenced by firstHandlePositionChanged(), rowsInserted(), and secondHandlePositionChanged().

ColumnHandleItem * secondColumnHandle ( ) const
CutoffMode senderCutoffMode ( ) const
inline

Definition at line 116 of file chatscene.h.

References _cutoffMode.

void setSenderCutoffMode ( CutoffMode  mode)
inline

Definition at line 117 of file chatscene.h.

References _cutoffMode.

Referenced by ChatMonitorView::ChatMonitorView().

bool hasSelection ( ) const
bool hasGlobalSelection ( ) const

Definition at line 1045 of file chatscene.cpp.

References _selectionStart.

Referenced by clearGlobalSelection(), hasSelection(), isPosOverSelection(), and selection().

bool isGloballySelecting ( ) const

Definition at line 1051 of file chatscene.cpp.

References _isSelecting.

Referenced by mouseReleaseEvent().

void initiateDrag ( QWidget *  source)

Definition at line 969 of file chatscene.cpp.

References selection().

Referenced by mouseMoveEvent().

bool isScrollingAllowed ( ) const

Definition at line 793 of file chatscene.cpp.

References _isSelecting.

void updateForViewport ( qreal  width,
qreal  height 
)
slot

Definition at line 574 of file chatscene.cpp.

References _viewportHeight, and setWidth().

Referenced by ChatView::resizeEvent().

void setWidth ( qreal  width)
slot
void layout ( int  start,
int  end,
qreal  width 
)
slot
void resetColumnWidths ( )
slot
void setMarkerLineVisible ( bool  visible = true)
slot
void setSelectingItem ( ChatItem item)
slot
ChatItem* selectingItem ( ) const
inlineslot

Definition at line 141 of file chatscene.h.

References _selectingItem.

Referenced by clearSelection(), hasSelection(), and selection().

void startGlobalSelection ( ChatItem item,
const QPointF &  itemPos 
)
slot
void clearGlobalSelection ( )
slot

Definition at line 1057 of file chatscene.cpp.

References _isSelecting, _lines, _selectionEnd, _selectionStart, and hasGlobalSelection().

Referenced by clearSelection().

void clearSelection ( )
slot
void selectionToClipboard ( QClipboard::Mode  mode = QClipboard::Clipboard)
slot
void stringToClipboard ( const QString &  str,
QClipboard::Mode  mode = QClipboard::Clipboard 
)
slot

Definition at line 991 of file chatscene.cpp.

Referenced by ContentsChatItem::copyLinkToClipboard(), and selectionToClipboard().

void webSearchOnSelection ( )
slot
void requestBacklog ( )
slot
void lastLineChanged ( QGraphicsItem *  item,
qreal  offset 
)
signal

Referenced by rowsInserted().

void layoutChanged ( )
signal
void mouseMoveWhileSelecting ( const QPointF &  scenePos)
signal

Referenced by mouseMoveEvent().

void mouseMoveEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual
void mousePressEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual
void mouseReleaseEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual
void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual

Definition at line 915 of file chatscene.cpp.

References mousePressEvent().

void handleClick ( Qt::MouseButton  button,
const QPointF &  scenePos 
)
protectedvirtual
void rowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void dataChanged ( const QModelIndex &  tl,
const QModelIndex &  br 
)
protectedslot

Definition at line 568 of file chatscene.cpp.

References _sceneRect, and layout().

Referenced by ChatScene().

void firstHandlePositionChanged ( qreal  xpos)
privateslot
void showWebPreviewChanged ( )
privateslot

Definition at line 1305 of file chatscene.cpp.

References _showWebPreview, and ChatViewSettings::showWebPreview().

Referenced by ChatScene().

void rowsRemoved ( )
privateslot

Definition at line 561 of file chatscene.cpp.

References setMarkerLine().

Referenced by ChatScene().

void clickTimeout ( )
privateslot

Definition at line 947 of file chatscene.cpp.

References _clickMode, _clickPos, _leftButtonPressed, handleClick(), and SingleClick.

Referenced by ChatScene().

void updateSceneRect ( qreal  width)
private
void updateSceneRect ( )
inlineprivate
void updateSceneRect ( const QRectF &  rect)
private

Definition at line 1165 of file chatscene.cpp.

References _sceneRect.

Member Data Documentation

ChatView* _chatView
private

Definition at line 191 of file chatscene.h.

Referenced by chatView().

QString _idString
private

Definition at line 192 of file chatscene.h.

Referenced by idString().

QAbstractItemModel* _model
private

Definition at line 193 of file chatscene.h.

Referenced by filter(), and model().

BufferId _singleBufferId
private

Definition at line 195 of file chatscene.h.

Referenced by ChatScene(), isSingleBufferScene(), and singleBufferId().

QRectF _sceneRect
private
int _firstLineRow
private

Definition at line 200 of file chatscene.h.

Referenced by rowsAboutToBeRemoved(), rowsInserted(), and updateSceneRect().

qreal _viewportHeight
private

Definition at line 204 of file chatscene.h.

Referenced by updateForViewport().

MarkerLineItem* _markerLine
private

Definition at line 206 of file chatscene.h.

Referenced by ChatScene(), and markerLine().

bool _markerLineVisible
private

Definition at line 207 of file chatscene.h.

Referenced by setMarkerLine(), and setMarkerLineVisible().

bool _markerLineValid
private

Definition at line 207 of file chatscene.h.

Referenced by jumpToMarkerLine(), rowsInserted(), setMarkerLine(), and setMarkerLineVisible().

bool _markerLineJumpPending
private

Definition at line 207 of file chatscene.h.

Referenced by jumpToMarkerLine(), and setMarkerLine().

ColumnHandleItem* _firstColHandle
private

Definition at line 209 of file chatscene.h.

Referenced by ChatScene(), firstColumnHandle(), resetColumnWidths(), and setHandleXLimits().

ColumnHandleItem * _secondColHandle
private

Definition at line 209 of file chatscene.h.

Referenced by ChatScene(), resetColumnWidths(), secondColumnHandle(), and setHandleXLimits().

qreal _firstColHandlePos
private

Definition at line 210 of file chatscene.h.

Referenced by ChatScene(), contextMenuEvent(), and firstHandlePositionChanged().

qreal _secondColHandlePos
private

Definition at line 210 of file chatscene.h.

Referenced by ChatScene(), contextMenuEvent(), and secondHandlePositionChanged().

int _defaultFirstColHandlePos
private

Definition at line 211 of file chatscene.h.

Referenced by ChatScene(), contextMenuEvent(), and resetColumnWidths().

int _defaultSecondColHandlePos
private

Definition at line 211 of file chatscene.h.

Referenced by ChatScene(), contextMenuEvent(), and resetColumnWidths().

CutoffMode _cutoffMode
private

Definition at line 212 of file chatscene.h.

Referenced by senderCutoffMode(), and setSenderCutoffMode().

ChatItem* _selectingItem
private
int _selectionStartCol
private

Definition at line 215 of file chatscene.h.

Referenced by startGlobalSelection(), and updateSelection().

int _selectionMinCol
private

Definition at line 215 of file chatscene.h.

Referenced by isPosOverSelection(), selection(), startGlobalSelection(), and updateSelection().

int _firstSelectionRow
private
QTimer _clickTimer
private

Definition at line 221 of file chatscene.h.

Referenced by ChatScene(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

ClickMode _clickMode
private
QPointF _clickPos
private

Definition at line 223 of file chatscene.h.

Referenced by clickTimeout(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

bool _clickHandled
private

Definition at line 224 of file chatscene.h.

Referenced by handleClick(), mouseMoveEvent(), and mousePressEvent().

bool _leftButtonPressed
private

Definition at line 225 of file chatscene.h.

Referenced by clickTimeout(), mousePressEvent(), and mouseReleaseEvent().

bool _showWebPreview
private

Definition at line 227 of file chatscene.h.

Referenced by ChatScene(), and showWebPreviewChanged().

const int _webSearchSelectionTextMaxVisible = 24
staticprivate

Definition at line 229 of file chatscene.h.

Referenced by contextMenuEvent().


The documentation for this class was generated from the following files: