Home · All Classes · Main Classes · Deprecated
Public Types | Public Slots | Signals | Public Member Functions | Properties

MBubbleItem Class Reference

MBubbleItem is a speech bubble like widget for conversation views. More...

Inherits MWidgetController.

List of all members.

Public Types

enum  MessageType { Incoming, Outgoing }

Public Slots

void setAvatar (MImageWidget *avatar)
void setAvatar (const QPixmap &pixmap)
void setSenderName (const QString &name)
void setTimeStamp (const QString &timeStamp)
void setMessage (const QString &message)
void setMessageType (MessageType messageType)
void setCentralWidget (QGraphicsWidget *centralWidget)
void addInformationWidget (QGraphicsWidget *widget)
void removeInformationWidget (QGraphicsWidget *widget)
void setCommentsString (const QString &comments)
void setThumbsUpString (const QString &thumbsUp)

Signals

void linkActivated (const QString &url)
void bubbleClicked ()

Public Member Functions

 MBubbleItem (QGraphicsItem *parent=0)
virtual ~MBubbleItem ()
MImageWidgetavatar () const
QString senderName ()
QString timeStamp ()
QString message ()
MessageType messageType () const
QGraphicsWidgetcentralWidget ()
QStack< QGraphicsWidget * > informationWidgets ()
QString commentsString ()
QString thumbsUpString ()

Properties

QString senderName
QString timeStamp
QString message
QString commentsString
QString thumbsUpString

Detailed Description

MBubbleItem is a speech bubble like widget for conversation views.

MBubbleItem, MListItem and MContentItem can usually be used for the same type of purposes, however the MBubbleItem API is message-centric and therefore better suited for messaging applications. When several bubble items are put into a layout the visual impression is that of a back and forth conversation.

The speech bubble supports avatar images, separate styling for incoming and outgoing messages, as well as an area for application specific widgets.


Member Enumeration Documentation

The type determines if the message is incoming or outgoing, and the widget may be styled differently based on this.

Enumerator:
Incoming 
Outgoing 

Constructor & Destructor Documentation

MBubbleItem::MBubbleItem ( QGraphicsItem parent = 0  )  [explicit]

Constructs a MBubbleItem instance. The optional parent argument is passed to MWidgetController's constructor.

MBubbleItem::~MBubbleItem (  )  [virtual]

Destroys the item.


Member Function Documentation

void MBubbleItem::addInformationWidget ( QGraphicsWidget widget  )  [slot]

Adds the widget to the informational widgets stack.

Informational widgets are displayed as part of the message bubble main body. There are two pre-defined information widgets for the bubble: number of comments and thumbs up received.

The ownership of the widget is transfered to the item. If the widget must not be deleted by the item the caller must invoke removeInformationWidget() to remove the widget from the graphics hierarchy.

See also:
informationWidgets();
setCommentsString();
setThumbsUpString();
removeInformationWidget();
MImageWidget * MBubbleItem::avatar (  )  const

Returns the image widget used for the avatar.

See also:
setAvatar()
void MBubbleItem::bubbleClicked (  )  [signal]

This signal is emitted if the bubble that contains the message is clicked.

QGraphicsWidget * MBubbleItem::centralWidget (  ) 

Returns the central widget.

For performance reasons, the central widget is not created by default. If the central widget has not been previously set the function returns 0.

See also:
setCentralWidget()
QString MBubbleItem::commentsString (  ) 

Returns the string for the number of comments received for the bubble.

See also:
setCommentsString();
QStack< QGraphicsWidget * > MBubbleItem::informationWidgets (  ) 

Returns the stack of informational widgets attached to the bubble.

See also:
addInformationWidget()
setCommentsString()
setThumbsUpString()
void MBubbleItem::linkActivated ( const QString url  )  [signal]

This signal is emitted if a link pointing to url in the message is clicked.

Links can be created using HTML notation, see the MLabel documentation for further information.

QString MBubbleItem::message (  ) 

Returns the body of the message.

See also:
setMessage()
MBubbleItem::MessageType MBubbleItem::messageType (  )  const

Returns the type of the message.

See also:
setMessageType()
void MBubbleItem::removeInformationWidget ( QGraphicsWidget widget  )  [slot]

Removes the widget from the informational widgets stack.

Informational widgets are displayed as part of the message bubble main body. There are two pre-defined information widgets for the bubble: number of comments and thumbs up received.

The removed widget is removed from the scene hierarchy and the ownership is transfered to caller.

See also:
informationWidgets()
setCommentsString();
setThumbsUpString();
addInformationWidget();
QString MBubbleItem::senderName (  ) 

Returns the name of the message sender.

See also:
setSenderName()
void MBubbleItem::setAvatar ( MImageWidget avatar  )  [slot]

Replaces the current avatar image widget attached to the bubble with avatar.

Any previous avatar is deleted if its QGraphicsItem::parent() is set to this bubble widget, otherwise it is left untouched.

The avatar will always be deleted when the bubble is deleted.

See also:
avatar()
void MBubbleItem::setAvatar ( const QPixmap pixmap  )  [slot]

Sets the avatar image to display the pixmap.

If there is an existing avatar() widget, this will set the pixmap for that avatar. Otherwise a new MImageWidget will be created and its QGraphicsItem::parent() set to this bubble widget.

See also:
avatar()
void MBubbleItem::setCentralWidget ( QGraphicsWidget centralWidget  )  [slot]

Sets the centralWidget.

The central widget is the attachment point for application specific content inside the bubble item.

Example:

      MBubbleItem *bubble = new MBubbleItem();
      MWidget *container = new MWidget();
      MImageWidget *image1 = new MImageWidget("foo");
      MImageWidget *image2 = new MImageWidget("bar");
      QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, container);
      layout->addItem(image1);
      layout->addItem(image2);

      bubble->setCentralWidget(container);
See also:
centralWidget()
void MBubbleItem::setCommentsString ( const QString comments  )  [slot]

Sets the string for number of comments received for the bubble item to comments.

This is a convenience method that creates widgets on the informationWidgets() stack for showing the number of comments attached to the bubble item. An example of a string could "+3", but it is up to the application to determine how the string is formatted.

See also:
commentsString()
void MBubbleItem::setMessage ( const QString message  )  [slot]

Sets the body of the message to message.

This must be html escaped.

See also:
message()
void MBubbleItem::setMessageType ( MessageType  messageType  )  [slot]

Sets type of the message (incoming or outgoing) to messageType.

See also:
messageType()
void MBubbleItem::setSenderName ( const QString name  )  [slot]

Sets the name of the message sender to name.

This must be html escaped. E.g.

          bubble->setSenderName(Qt::escape("I <3 everyone!"));
See also:
senderName()
void MBubbleItem::setThumbsUpString ( const QString thumbsUp  )  [slot]

Sets the string for number of thumbs up received for the bubble item to thumbsUp.

This is a convenience method that creates widgets on the informationWidgets() stack for showing the number of "thumbs up" attached to the bubble item. An example of a string could "+3", but it is up to the application to determine how the string is formatted.

See also:
thumbsUpString()
void MBubbleItem::setTimeStamp ( const QString timeStamp  )  [slot]

Sets the time stamp string of the message to timeStamp.

This must be html escaped.

See also:
timeStamp()
QString MBubbleItem::thumbsUpString (  ) 

Returns the string for the number of thumbs-up received for the bubble.

See also:
setThumbsUpString()
QString MBubbleItem::timeStamp (  ) 

Returns the time stamp string displayed as part of the bubble.

See also:
setSenderName()

Property Documentation

MBubbleItem::commentsString [read, write]

The number of comments received, displayed as part of the bubble.

MBubbleItem::message [read, write]

The main body of the message.

MBubbleItem::senderName [read, write]

Name of the message sender.

MBubbleItem::thumbsUpString [read, write]

The number of thumbs up received, displayed as part of the bubble.

MBubbleItem::timeStamp [read, write]

Time the message was sent, displayed as part of the bubble.


Copyright © 2010 Nokia Corporation
MeeGo Touch