コード例 #1
0
/*!
    Sets the background color. This method can be used to override the
    default background color set by the current theme. Because of the effect,
    the implementation "smoke and mirrors" but it works.

    \param color The new background color.
*/
void NmAttachmentListItem::setBackgroundColor(const QColor color)
{
    NM_FUNCTION;

    if (!color.isValid()) {
        // Invalid color!
        return;
    }

    mBackgroundColor = color;

    // The effect color is the opposite color of the background color.
    QColor effectColor(qAbs(color.red() - 255),
                       qAbs(color.green() - 255),
                       qAbs(color.blue() - 255));
    
    QPalette palette = QApplication::palette();
    QBrush brush(effectColor);
    palette.setBrush(QPalette::Window, effectColor);
    setPalette(palette);
    setAutoFillBackground(true);

    if (mBackground) {
        // Set the background color for the background item.
        brush.setColor(mBackgroundColor);
        palette.setBrush(QPalette::Window, brush);
        mBackground->setPalette(palette);
        mBackground->setAutoFillBackground(true);
        mBackground->frameDrawer().setFrameType(HbFrameDrawer::OnePiece);
    }

    repolish();
}
コード例 #2
0
/*!
    Set the download progress bar value (0 - 100 %). If the given value is 0,
    the progress bar is hidden.

    \param value The progress bar value.
*/
void NmAttachmentListItem::setProgressBarValue(const int value)
{
    NM_FUNCTION;
    
    // First check if the value is 0 or below -> hide progressbar.
    if (0 >= value) {
        removeProgressBar();
        return;
    }

    if (!mProgressBar) {
        mProgressBar = new HbProgressBar(this); 
        mProgressBar->setObjectName("attachmentlistitem_progress");
        mProgressBar->setRange(PROGRESSBAR_MIN,PROGRESSBAR_MAX);
        HbStyle::setItemName(mProgressBar, "progressbar");
        repolish();
    }

    mProgressBar->setProgressValue(value);
    
    // Start hiding the count down.
    if (PROGRESSBAR_MAX <= value){
        hideProgressBar();
    }
}
コード例 #3
0
void BubbleHeadingWidget::setLineCount(int count)
{
    mLineCount = count;
    if (isVisible()) {
        repolish();
    }
}
コード例 #4
0
/*!
    Sets the orientation of scrollbar.

    \sa HbScrollBar::orientation()
*/
void HbScrollBar::setOrientation( Qt::Orientation orientation )
{
    Q_D(HbScrollBar);
    if(d->mOrientation != orientation) {
        d->mOrientation = orientation;
        repolish();
    }
}
コード例 #5
0
/*!
    Hides and deletes the download progress bar.
*/
void NmAttachmentListItem::removeProgressBar()
{
    NM_FUNCTION;
    
    if (mProgressBar) {
        HbStyle::setItemName(mProgressBar, "");
        mProgressBar->deleteLater();
        mProgressBar = 0;
        repolish();
    }
}
コード例 #6
0
/*!
    Sets the value of interactive property. If this value is set
    to true scrollbar is interactive, the user can change the scroll position by
    dragging the thumb or pressing the groove. Dragging the thumb emits valueChanged
    signal and pressing the groove emits valueChangeRequested which means
    that the widget using scrollbars should handle the value change (for example
    by animating to the given target value).

    The default behavior is non interactive,
    which means that the scrollbar is just indicative.

    \sa HbScrollBar::isInteractive()
*/
void HbScrollBar::setInteractive( bool enabled )
{
    Q_D( HbScrollBar );
    if( d->mInteractive != enabled){
        d->mInteractive = enabled;
        if(d->handleItem) {
            repolish();
            updatePrimitives();
        }
    }
}
コード例 #7
0
/*!
    \reimp
*/
bool HbAbstractViewItem::event(QEvent *e)
{
    if (e) {
        switch (e->type()) {
            case QEvent::GraphicsSceneResize: {
                Q_D(HbAbstractViewItem );
                if (d->mBackgroundItem || d->mFrame || d->mFocusItem) {
                    HbStyleOptionAbstractViewItem styleOption;
                    initStyleOption(&styleOption);
                    if (d->mFocusItem) {
                        style()->updatePrimitive(d->mFocusItem, HbStyle::P_ItemViewItem_focus, &styleOption);
                    }

                    if (d->mFrame) {
                        style()->updatePrimitive(d->mFrame, HbStyle::P_ItemViewItem_frame, &styleOption);
                    }

                    if (d->mBackgroundItem) {
                        style()->updatePrimitive(d->mBackgroundItem, HbStyle::P_ItemViewItem_background, &styleOption);
                    }
                }
                break;
            }
            case QEvent::LayoutDirectionChange: {
                repolish();
                break;
            }
            default: {
                if (e->type() == HbAbstractViewItemShared::ViewItemDeferredDeleteEvent) {
                    // cannot handle ViewItemDeferredDeleteEvent in the case statement!
                    Q_D(HbAbstractViewItem);
                    delete d->mFocusItem;
                    d->mFocusItem = 0;
               }
                break;
            }
        }

        return HbWidget::event(e);
    }

    return false;
}
コード例 #8
0
/*!
 Sets the data for EventViewer items
 To set textitem data use Qt::DisplayRole
 To set iconitem data use Qt::DecorationRole
 \param itemData string list of itemdata
 \param role qt role of text and icon item
 */
void AgendaEventViewerItem::setEventViewerItemData(const QStringList &itemData,
                                                   int role)
{
	OstTraceFunctionEntry0( AGENDAEVENTVIEWERITEM_SETEVENTVIEWERITEMDATA_ENTRY );
	if (!itemData.isEmpty()) {

		if (role == Qt::DisplayRole) {
			for (int index=0; index < itemData.count(); index++)
				setTextItemData(index, itemData.at(index));
			
		} else {
			if (role == Qt::DecorationRole) {
			for (int index=0; index < itemData.count(); index++)
				setIconItemData(index, itemData.at(index));
			
		}
	}
	repolish();
	OstTraceFunctionExit0( AGENDAEVENTVIEWERITEM_SETEVENTVIEWERITEMDATA_EXIT );
	}
}
コード例 #9
0
void BubbleHeadingWidget::updatePrimitives()
{
    if (mHeader!=0) {
        BubbleUtils::setIndicators(mHeader->callState(),
                                   mHeader->callFlags(),
                                   *mIndicator1,
                                   *mIndicator2);

        // update text lines
        int cliLine = 0;

        if (mLineCount==3) {
            BubbleUtils::setCallHeaderTexts3Lines(
                *mHeader, *mText1, *mText2, *mText3, cliLine,
                mCallTimerTextLine );
        } else if (mLineCount==2) {
            BubbleUtils::setCallHeaderTexts2Lines(
                *mHeader, *mText1, *mText2, cliLine,
                mCallTimerTextLine );
        } else {
            // todo: 1-line
            BubbleUtils::setCallHeaderTexts2Lines(
                *mHeader, *mText1, *mText2, cliLine,
                mCallTimerTextLine );
        }

        // update font
        if (cliLine==2) {
            mText1->setFontSpec(*mTextFont);
            mText2->setFontSpec(*mCliFont);
            mText3->setFontSpec(*mTextFont);
        } else {
            mText1->setFontSpec(*mCliFont);
            mText2->setFontSpec(*mTextFont);
            mText3->setFontSpec(*mTextFont);
        }
    }

    repolish();
}
コード例 #10
0
/*!
    Updates child graphics items to represent current state and content. 

    \note It is a good habit to reuse child items as much as possible as this improves
    performance, especially when item recycling is used. 

    Most of the HbAbstractViewItem derived classes inside Hb library are optimised for performance.
    Layout files are loaded only if child items are created or deleted. Loading layout
    files is triggered by calling HbWidget::repolish(). 
    Classes deriving from HbAbstractViewItem outside Hb, should either always call explicitly
    repolish() or if they are also optimised for performance only when child items are created or deleted
    in the custom view item.

    Here is an example of custom view item that reuses its child items. The custom view item does not
    create or delete child items.

    \snippet{ultimatecodesnippet/customlistviewitem.cpp,2}

    \sa HbWidget::polish()
*/
void HbAbstractViewItem::updateChildItems()
{
    HB_SDD(HbAbstractViewItem);

    int itemType = d->modelItemType();
    if (itemType != d->mModelItemType) {
        d->mModelItemType = itemType;
        d->mItemsChanged = true;
        d->themingPending = true;
    }

    /* Summary of background and frame handling:
         d->mBackground is read from Qt::BackgroundRole of model
         d->mBackgroundItem is created from d-mBackground (Qt::BackgroundRole), if this is HbIcon or QBrush.

         If d->mBackgroundItem does not exist, d->mFrame is created from d-mBackground (Qt::BackgroundRole), 
         if this is HbFrameBackground otherwise it either is created from sd->mDefaultFrame, 
         not created at all or from system default.
    */
 
    // background
    QVariant currentBackground = d->mIndex.data(Qt::BackgroundRole);
    if (currentBackground != d->mBackground) {
        d->mBackground = currentBackground;
        if (currentBackground.canConvert<HbIcon>() 
            || currentBackground.canConvert<QBrush>()) {
            if (!d->mBackgroundItem) {  
                d->mItemsChanged = true;
                d->mBackgroundItem = style()->createPrimitive(HbStyle::P_ItemViewItem_background, this);
                delete d->mFrame;
                d->mFrame = 0;
            }
        } else if (currentBackground.canConvert<HbFrameBackground>()) {
            if (!d->mFrame) {
                d->mItemsChanged = true;
                d->mFrame = style()->createPrimitive(HbStyle::P_ItemViewItem_frame, this);
                delete d->mBackgroundItem;
                d->mBackgroundItem = 0;
            }
        } else if (d->mBackgroundItem) {
            d->mItemsChanged = true;
            delete d->mBackgroundItem;
            d->mBackgroundItem = 0;
        }
    }

    // frame
    if (!d->mBackgroundItem) {
        if (    d->mModelItemType == Hb::ParentItem
            ||  d->mModelItemType == Hb::SeparatorItem
            ||  (   d->mModelItemType == Hb::StandardItem
                &&  (   d->mBackground.canConvert<HbFrameBackground>()
                    ||  sd->mDefaultFrame.frameGraphicsName().length() > 0    
                    ||  sd->mDefaultFrame.isNull()))) { 
            if (!d->mFrame) {
                d->mItemsChanged = true;
                d->mFrame = style()->createPrimitive(HbStyle::P_ItemViewItem_frame, this);
            }
        } else if (d->mFrame) {
            d->mItemsChanged = true;
            delete d->mFrame;
            d->mFrame = 0;
        }
    } 

    GraphicsItemFlags itemFlags = flags();
    Qt::ItemFlags indexFlags = d->mIndex.flags();

    if ((indexFlags & Qt::ItemIsEnabled) && sd->mItemView && sd->mItemView->isEnabled()) {
        if (!(itemFlags & QGraphicsItem::ItemIsFocusable)) {
            itemFlags |= QGraphicsItem::ItemIsFocusable;
            setFocusPolicy(sd->mPrototype->focusPolicy());
            setProperty("state", "normal");
            grabGesture(Qt::TapGesture);
        }
    } else {
        if (itemFlags & QGraphicsItem::ItemIsFocusable) {
            itemFlags &= ~QGraphicsItem::ItemIsFocusable;
            setFocusPolicy(Qt::NoFocus);
            setProperty("state", "disabled");
            ungrabGesture(Qt::TapGesture);
        }
    }

    // selection
    HbAbstractItemView::SelectionMode selectionMode = HbAbstractItemView::NoSelection;
    if (sd->mItemView) {
        selectionMode = sd->mItemView->selectionMode();
    }

    bool previousSelectable = itemFlags & QGraphicsItem::ItemIsSelectable;
    bool itemSelectable = false;

    if (indexFlags & Qt::ItemIsSelectable 
        && selectionMode != HbAbstractItemView::NoSelection
        && indexFlags & Qt::ItemIsEnabled) {
        itemFlags |= QGraphicsItem::ItemIsSelectable;
        itemSelectable = true;
    } else {
        itemFlags &= ~QGraphicsItem::ItemIsSelectable;
    }

    if (previousSelectable != itemSelectable) {
        if (itemSelectable) {
            if (!d->mSelectionItem) {
                d->mItemsChanged = true;
                d->mSelectionItem = style()->createPrimitive(HbStyle::P_ItemViewItem_selection, this);
            }
        } else {
            d->mItemsChanged = true;
            delete d->mSelectionItem;
            d->mSelectionItem = 0;
        }
    }

    setFlags(itemFlags);

    // multiselection area
    if (    itemSelectable 
        &&  selectionMode == HbAbstractItemView::MultiSelection) {
        if (!d->mMultiSelectionTouchArea) {
            d->mItemsChanged = true;
            d->mMultiSelectionTouchArea = style()->createPrimitive(HbStyle::P_ItemViewItem_touchmultiselection, this);
        }
    } else if (d->mMultiSelectionTouchArea) {
        d->mItemsChanged = true;
        delete d->mMultiSelectionTouchArea;
        d->mMultiSelectionTouchArea = 0;
    }

    // items visibility or items content has really changed
    updatePrimitives();
    if (!d->mContentChangedSupported
        || d->mItemsChanged) {
        updateGeometry();   // ensures that sizehint is calculated again in case items have been created or deleted
        d->mRepolishRequested = true;
        // handle QEvent::Polish & QEvent::LayoutRequest event itself in ::sizeHint() as our performance is slightly better
        // (saving a layoutrequest and going event loop through twice)
        if (sd->mItemView && sd->mItemView->isScrolling()) {
            d->mHandlingRepolishSynchronously = true;
        }
        repolish();
        d->mHandlingRepolishSynchronously = false;
    }
    d->mItemsChanged = false;
}