Beispiel #1
0
void HGLayout::setAlignment(QGraphicsLayoutItem* item, Qt::Alignment align)
{
    QGraphicsLayout* ll = layout();
    if (!ll)  return ;

    HEnums::HLayoutType type = layoutType() ;
    if (type == HEnums::kHBox || type == HEnums::kVBox) {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(ll);
        l->setAlignment(item, align);
    }
    else if(type == HEnums::kGrid) {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(ll);
        l->setAlignment(item,align);
    }
}
QGraphicsLayout *
RightArrowItem::createLayout()
{
    QGraphicsGridLayout *layout;
    MWidget             *spacer;
    MLabel              *titleLabel;
    MLabel              *subTitleLabel = 0;
    MImageWidget        *iconWidget    = 0;
    MImageWidget        *drillIconWidget;
    Qt::Alignment        textAlignment = getTextAlignment ();
    
    layout = new QGraphicsGridLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);

    titleLabel = titleLabelWidget ();
    titleLabel->setWordWrap (true);

    drillIconWidget = new MImageWidget ("icon-m-common-drilldown-arrow-inverse");
    drillIconWidget->setStyleName ("CommonDrillDownIcon");

    titleLabel->setStyleName(m_TitleStyleName);

    switch (itemStyle()) {
        case TitleWithSubtitle:
            SYS_DEBUG ("TitleWithSubtitle");
            /*
             * The title label.
             */
            layout->addItem (titleLabel, 0, 0);
            layout->setAlignment(titleLabel, 
                    Qt::AlignLeft | Qt::AlignVCenter);
            /*
             * The sub-title label.
             */
            subTitleLabel = subtitleLabelWidget ();
            subTitleLabel->setStyleName("CommonSubTitleInverted");
            layout->addItem (subTitleLabel, 1, 0);
            layout->setAlignment (subTitleLabel, 
                    Qt::AlignLeft | Qt::AlignVCenter);

            spacer = new MWidget;
            layout->addItem (spacer, 2, 0);

            /*
             * The drill down icon.
             */
            layout->addItem(drillIconWidget, 0, 1, 3, 1);
            layout->setAlignment (drillIconWidget, Qt::AlignVCenter | Qt::AlignRight);
            break;

        case IconWithTitleAndSubtitle:
            SYS_DEBUG ("IconWithTitleAndSubtitle");
            /*
             * The left side icon.
             */
            iconWidget = imageWidget();
            layout->addItem (iconWidget, 0, 0, 2, 1);
            layout->setAlignment (iconWidget, Qt::AlignVCenter | Qt::AlignRight);
            /*
             * The title label.
             */
            layout->addItem (titleLabel, 0, 1);
            layout->setAlignment (titleLabel, 
                    Qt::AlignLeft | Qt::AlignVCenter);
            /*
             * The sub-title label.
             */
            subTitleLabel = subtitleLabelWidget ();
            subTitleLabel->setStyleName("CommonSubTitleInverted");
            layout->addItem (subTitleLabel, 1, 1, 
                    Qt::AlignLeft | Qt::AlignVCenter);
            /*
             * The drill down icon.
             */
            layout->addItem(drillIconWidget, 0, 2, 2, 1);
            layout->setAlignment (drillIconWidget, 
                    Qt::AlignVCenter | Qt::AlignRight);
            break;

        case IconWithTitle:
            SYS_DEBUG ("IconWithTitle");

            /*
             * The left side icon.
             */
            iconWidget = imageWidget();
            layout->addItem (iconWidget, 0, 0);
            layout->setAlignment (iconWidget, 
                    Qt::AlignVCenter | Qt::AlignRight);
            /*
             * The title label.
             */
            titleLabel->setAlignment (textAlignment | Qt::AlignVCenter);
            layout->addItem (titleLabel, 0, 1);
            layout->setAlignment (titleLabel, 
                    Qt::AlignLeft | Qt::AlignVCenter);
            /*
             * The drill down icon.
             */
            layout->addItem(drillIconWidget, 0, 2);
            layout->setAlignment (drillIconWidget, Qt::AlignVCenter | Qt::AlignRight);
            break;

        default:
            SYS_WARNING ("itemStyle not supported.");
    }

    setStyleName ("CommonPanelInverted");
    return layout;
}