phoneuis/bubblemanager2/bubblecore/src/bubblecontainerwidget.cpp
changeset 30 ebdbd102c78a
parent 21 92ab7f8d0eab
child 51 f39ed5e045e0
equal deleted inserted replaced
27:2f8f8080a020 30:ebdbd102c78a
    18 #include <QtGui>
    18 #include <QtGui>
    19 #include <hbstyle.h>
    19 #include <hbstyle.h>
    20 #include <hbframeitem.h>
    20 #include <hbframeitem.h>
    21 #include <hbframedrawer.h>
    21 #include <hbframedrawer.h>
    22 #include "bubblecontainerwidget.h"
    22 #include "bubblecontainerwidget.h"
    23 #include "bubbleprimitives.h"
       
    24 #include "bubblestyleoption.h"
       
    25 
    23 
    26 BubbleContainerWidget::BubbleContainerWidget(
    24 BubbleContainerWidget::BubbleContainerWidget(QGraphicsItem* item)
    27     const QString& stylePluginName, QGraphicsItem* item)
    25     : HbWidget(item), mBackground(0)
    28     : HbWidget(item), mStylePluginName(stylePluginName),
       
    29       mBackground(0)
       
    30 {
    26 {
    31     setPluginBaseId(style()->registerPlugin(mStylePluginName));
       
    32     Q_ASSERT(pluginBaseId()!=-1);
       
    33 
       
    34     createPrimitives();
    27     createPrimitives();
    35     updatePrimitives();
    28     updatePrimitives();
       
    29     Q_ASSERT(mBackground);
    36 }
    30 }
    37 
    31 
    38 BubbleContainerWidget::~BubbleContainerWidget()
    32 BubbleContainerWidget::~BubbleContainerWidget()
    39 {
    33 {
    40     style()->unregisterPlugin(mStylePluginName);
       
    41 }
    34 }
    42 
    35 
    43 void BubbleContainerWidget::createPrimitives()
    36 void BubbleContainerWidget::createPrimitives()
    44 {
    37 {
    45     QGraphicsItem *background = style()->createPrimitive(
    38     delete mBackground;
    46         (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame), this);
    39     mBackground = new HbFrameItem(this);
    47     style()->setItemName(mBackground, "background");
    40     style()->setItemName(mBackground, "background");
    48 
    41     mBackground->setZValue(-1.0);
    49     delete mBackground;
    42     mBackground->setVisible(false); // background in drawn in paint()
    50     mBackground =
       
    51         qgraphicsitem_cast<HbFrameItem*>(background);
       
    52 }
    43 }
    53 
    44 
    54 void BubbleContainerWidget::updatePrimitives()
    45 void BubbleContainerWidget::updatePrimitives()
    55 {
    46 {
    56     if (mBackground) {
    47     mBackground->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
    57         BubbleStyleOption option;
    48     mBackground->frameDrawer().setFrameGraphicsName("qtg_fr_list_normal");
    58         style()->updatePrimitive(
       
    59             mBackground, (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame),
       
    60             &option);
       
    61         mBackground->setVisible(false); // background in drawn in paint()
       
    62     }
       
    63 }
    49 }
    64 
    50 
    65 void BubbleContainerWidget::mousePressEvent(
    51 void BubbleContainerWidget::mousePressEvent(
    66     QGraphicsSceneMouseEvent * event)
    52     QGraphicsSceneMouseEvent * event)
    67 {
    53 {
    87         mPressed = false;
    73         mPressed = false;
    88     }
    74     }
    89 }
    75 }
    90 
    76 
    91 void BubbleContainerWidget::mouseReleaseEvent(
    77 void BubbleContainerWidget::mouseReleaseEvent(
    92     QGraphicsSceneMouseEvent * event)
    78     QGraphicsSceneMouseEvent *event)
    93 {
    79 {
    94     if (event->button() != Qt::LeftButton) {
    80     if (event->button() != Qt::LeftButton) {
    95         event->ignore();
    81         event->ignore();
    96         return;
    82         return;
    97     }
    83     }
   109     QWidget *widget)
    95     QWidget *widget)
   110 {
    96 {
   111     Q_UNUSED(widget)
    97     Q_UNUSED(widget)
   112     Q_UNUSED(option)
    98     Q_UNUSED(option)
   113 
    99 
   114     if (mBackground) {
   100     mBackground->frameDrawer().paint(painter,boundingRect());
   115         mBackground->frameDrawer().paint(painter,boundingRect());
       
   116     }
       
   117 }
   101 }
   118 
   102 
       
   103 void BubbleContainerWidget::showEvent(QShowEvent *event)
       
   104 {
       
   105     Q_UNUSED(event)
       
   106     mPressed = false;
       
   107 }
       
   108