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...

Inheritance diagram for MBubbleItem:
Inheritance graph
[legend]
Collaboration diagram for MBubbleItem:
Collaboration graph
[legend]

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.

Definition at line 41 of file corelib/widgets/mbubbleitem.h.


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 

Definition at line 82 of file corelib/widgets/mbubbleitem.h.

                     {
        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.

Definition at line 132 of file mbubbleitem.cpp.

    : MWidgetController(new MBubbleItemPrivate, new MBubbleItemModel, parent)
{
    Q_D(MBubbleItem);
    
    d->init();
}

MBubbleItem::~MBubbleItem (  )  [virtual]

Destroys the item.

Definition at line 148 of file mbubbleitem.cpp.

{
}


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();

Definition at line 249 of file mbubbleitem.cpp.

{
    QStack<QGraphicsWidget*> stack = model()->informationWidgets();
    stack.push(widget);
    model()->setInformationWidgets(stack);
}

Here is the call graph for this function:

MImageWidget * MBubbleItem::avatar (  )  const

Returns the image widget used for the avatar.

See also:
setAvatar()

Definition at line 152 of file mbubbleitem.cpp.

{
    return model()->avatar();
}

Here is the call graph for this function:

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()

Definition at line 239 of file mbubbleitem.cpp.

{
    return model()->centralWidget();
}

Here is the call graph for this function:

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()

Definition at line 244 of file mbubbleitem.cpp.

{
    return model()->informationWidgets();
}

Here is the call graph for this function:

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()

Definition at line 211 of file mbubbleitem.cpp.

{
    return static_cast<MBubbleItem::MessageType>(model()->messageType());
}

Here is the call graph for this function:

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.

See also:
informationWidgets()
setCommentsString();
setThumbsUpString();
addInformationWidget();

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);
    }
}

Here is the call graph for this function:

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()

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;
}

Here is the call graph for this function:

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.

See also:
avatar()

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();
}

Here is the call graph for this function:

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()

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;
}

Here is the call graph for this function:

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()

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);
}

Here is the call graph for this function:

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

Sets the body of the message to message.

This must be html escaped.

See also:
message()

Definition at line 206 of file mbubbleitem.cpp.

{
    model()->setMessage(message);
}

Here is the call graph for this function:

void MBubbleItem::setMessageType ( MessageType  messageType  )  [slot]

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

See also:
messageType()

Definition at line 216 of file mbubbleitem.cpp.

{
    Q_D(MBubbleItem);

    model()->beginTransaction();
    model()->setMessageType(messageType);

    d->refreshStyles();

    model()->commitTransaction();
}

Here is the call graph for this function:

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()

Definition at line 186 of file mbubbleitem.cpp.

{
    model()->setSenderName(senderName);
}

Here is the call graph for this function:

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()

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);
}

Here is the call graph for this function:

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()

Definition at line 196 of file mbubbleitem.cpp.

{
    model()->setTimeStamp(timeStamp);
}

Here is the call graph for this function:

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.

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