| Home · All Classes · Main Classes · Deprecated |
MBubbleItem is a speech bubble like widget for conversation views. More...


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.
Definition at line 41 of file corelib/widgets/mbubbleitem.h.
The type determines if the message is incoming or outgoing, and the widget may be styled differently based on this.
Definition at line 82 of file corelib/widgets/mbubbleitem.h.
{
Incoming,
Outgoing
};
| MBubbleItem::MBubbleItem | ( | QGraphicsItem * | parent = 0 |
) | [explicit] |
Constructs a MBubbleItem instance. The optional parent argument is passed to MWidgetController's constructor.
Definition at line 132 of file mbubbleitem.cpp.
: MWidgetController(new MBubbleItemPrivate, new MBubbleItemModel, parent) { Q_D(MBubbleItem); d->init(); }
| MBubbleItem::~MBubbleItem | ( | ) | [virtual] |
| 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.
Definition at line 249 of file mbubbleitem.cpp.
{
QStack<QGraphicsWidget*> stack = model()->informationWidgets();
stack.push(widget);
model()->setInformationWidgets(stack);
}

| MImageWidget * MBubbleItem::avatar | ( | ) | const |
Returns the image widget used for the avatar.
Definition at line 152 of file mbubbleitem.cpp.
{
return model()->avatar();
}

| 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.
Definition at line 239 of file mbubbleitem.cpp.
{
return model()->centralWidget();
}

| QString MBubbleItem::commentsString | ( | ) |
Returns the string for the number of comments received for the bubble.
| QStack< QGraphicsWidget * > MBubbleItem::informationWidgets | ( | ) |
Returns the stack of informational widgets attached to the bubble.
Definition at line 244 of file mbubbleitem.cpp.
{
return model()->informationWidgets();
}

| 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.
| MBubbleItem::MessageType MBubbleItem::messageType | ( | ) | const |
Returns the type of the message.
Definition at line 211 of file mbubbleitem.cpp.
{
return static_cast<MBubbleItem::MessageType>(model()->messageType());
}

| 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 parent item of the widget in graphics hierarchy is set to NULL, so the widget will not be displayed. The ownership is transfered to caller.
Definition at line 256 of file mbubbleitem.cpp.
{
widget->setParentItem(0);
QStack<QGraphicsWidget*> stack = model()->informationWidgets();
int index = stack.indexOf(widget);
if (index >= 0) {
stack.remove(index);
model()->setInformationWidgets(stack);
}
}

| QString MBubbleItem::senderName | ( | ) |
Returns the name of the message sender.
| 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.
Definition at line 157 of file mbubbleitem.cpp.
{
MImageWidget *oldAvatar = model()->avatar();
if(oldAvatar == avatar)
return;
model()->setAvatar(avatar);
if(oldAvatar && oldAvatar->parent() == this)
delete oldAvatar;
}

| 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 it's QGraphicsItem::parent() set to this bubble widget.
Definition at line 168 of file mbubbleitem.cpp.
{
model()->beginTransaction();
if (!model()->avatar()) {
model()->setAvatar(new MImageWidget);
model()->avatar()->setParent(this);
}
model()->avatar()->setPixmap(avatar);
model()->commitTransaction();
}

| 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);
Definition at line 228 of file mbubbleitem.cpp.
{
QGraphicsWidget *oldCentralWidget = model()->centralWidget();
if(oldCentralWidget == centralWidget)
return;
model()->setCentralWidget(centralWidget);
if(oldCentralWidget && oldCentralWidget->parent() == this)
delete oldCentralWidget;
}

| 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.
Definition at line 277 of file mbubbleitem.cpp.
{
Q_D(MBubbleItem);
if(!comments.isEmpty()) {
if (!d->commentsLabel)
d->createCommentsInfo();
Q_ASSERT(d->commentsLabel);
Q_ASSERT(d->commentsIcon);
d->commentsLabel->setText(comments);
} else if (d->commentsLabel) {
Q_ASSERT(d->commentsIcon);
d->destroyCommentsInfo();
Q_ASSERT(!d->commentsLabel);
Q_ASSERT(!d->commentsIcon);
}
model()->setCommentsString(comments);
}

| void MBubbleItem::setMessage | ( | const QString & | message | ) | [slot] |
Sets the body of the message to message.
This must be html escaped.
Definition at line 206 of file mbubbleitem.cpp.
{
model()->setMessage(message);
}

| void MBubbleItem::setMessageType | ( | MessageType | messageType | ) | [slot] |
Sets type of the message (incoming or outgoing) to messageType.
Definition at line 216 of file mbubbleitem.cpp.
{
Q_D(MBubbleItem);
model()->beginTransaction();
model()->setMessageType(messageType);
d->refreshStyles();
model()->commitTransaction();
}

| 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!"));
Definition at line 186 of file mbubbleitem.cpp.
{
model()->setSenderName(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.
Definition at line 307 of file mbubbleitem.cpp.
{
Q_D(MBubbleItem);
if(!thumbsUp.isEmpty()) {
if (!d->thumbsUpLabel) {
Q_ASSERT(!d->thumbsUpIcon);
d->createThumbsUpInfo();
Q_ASSERT(d->thumbsUpLabel);
Q_ASSERT(d->thumbsUpIcon);
}
d->thumbsUpLabel->setText(thumbsUp);
} else if (d->thumbsUpLabel != NULL) {
Q_ASSERT(d->thumbsUpIcon);
d->destroyThumbsUpInfo();
}
model()->setThumbsUpString(thumbsUp);
}

| void MBubbleItem::setTimeStamp | ( | const QString & | timeStamp | ) | [slot] |
Sets the time stamp string of the message to timeStamp.
This must be html escaped.
Definition at line 196 of file mbubbleitem.cpp.
{
model()->setTimeStamp(timeStamp);
}

| QString MBubbleItem::thumbsUpString | ( | ) |
Returns the string for the number of thumbs-up received for the bubble.
| QString MBubbleItem::timeStamp | ( | ) |
Returns the time stamp string displayed as part of the bubble.
MBubbleItem::commentsString [read, write] |
The number of comments received, displayed as part of the bubble.
Definition at line 70 of file corelib/widgets/mbubbleitem.h.
MBubbleItem::message [read, write] |
The main body of the message.
Definition at line 64 of file corelib/widgets/mbubbleitem.h.
MBubbleItem::senderName [read, write] |
Name of the message sender.
Definition at line 52 of file corelib/widgets/mbubbleitem.h.
MBubbleItem::thumbsUpString [read, write] |
The number of thumbs up received, displayed as part of the bubble.
Definition at line 76 of file corelib/widgets/mbubbleitem.h.
MBubbleItem::timeStamp [read, write] |
Time the message was sent, displayed as part of the bubble.
Definition at line 58 of file corelib/widgets/mbubbleitem.h.
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:14:24 (PDT) Doxygen 1.7.1 |
MeeGo Touch |