예제 #1
0
void tst_QGraphicsLayout::moveAndResizeWidgetInWidget()
{
    QFETCH(bool, instantInvalidatePropagation);

    QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidatePropagation);
    QGraphicsScene scene;

    QGraphicsWidget *widget = new QGraphicsWidget;
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(widget);
    layout->setContentsMargins(0,0,0,0);
    WidgetToTestResizeEvents *innerWidget = new WidgetToTestResizeEvents;
    QGraphicsLinearLayout *innerLayout = new QGraphicsLinearLayout(innerWidget);
    innerLayout->setContentsMargins(0,0,0,0);
    QCOMPARE(widget->maximumSize(), QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
    layout->addItem(innerWidget);
    widget->setMinimumSize(1,1);
    widget->setPreferredSize(1000,1000);
    widget->setMaximumSize(2000,2000);
    widget->resize(widget->preferredSize());
    innerWidget->setMinimumSize(1,1);
    qApp->processEvents();
    innerWidget->resizeEventCalled = false;

    QCOMPARE(widget->size(), QSizeF(1000, 1000));
    QCOMPARE(layout->geometry().size(), QSizeF(1000, 1000));
    QCOMPARE(innerWidget->size(), QSizeF(1000, 1000));

    innerLayout->invalidate();
    widget->setMaximumHeight(500);
    widget->setX(1);
    qApp->processEvents();
    QCOMPARE(widget->size(), QSizeF(1000, 500));
    QCOMPARE(innerWidget->size(), QSizeF(1000, 500));
    QVERIFY(innerWidget->resizeEventCalled);
}
void 
ThemeWidget::textChanged ()
{
    if (!m_List->filtering()->editor()->isOnDisplay()) {
        m_List->filtering()->editor()->show();
        m_List->filtering()->editor()->setFocus();
    }

    QGraphicsLinearLayout *mainLayout = dynamic_cast<QGraphicsLinearLayout *>(layout ());
    if (mainLayout)
    {
      if (m_LiveFilterEditor->text ().isEmpty () == true)
      {
          /*
           * We already have a better solution for this in the soundsettings
           * applet...
           */
          mainLayout->removeItem (m_LiveFilterEditor);
          m_LiveFilterEditor->setPos (QPointF (0.,-200.));
      }
      else
      {
          mainLayout->insertItem (0, m_LiveFilterEditor);
      }  
      mainLayout->invalidate ();
    }

    m_CellCreator->highlightByText (m_LiveFilterEditor->text());
    // Seems that the sort() method simply will not sort when the
    // ThemeListModel::SearchRole is used.
    m_Proxy->sort(Qt::DisplayRole);
    
    /*
     * As the search string changes the current theme might appear in the list
     * (if the current theme was filtered before). In this case we need to
     * select this item in the list, because the selection is lost when the
     * selected item is filtered out.
     */
    selectCurrentTheme ();
    m_ThemeListModel->refresh();

    update ();
}
예제 #3
0
void Pt_MLayout::heightForWidthPerformance()
{
    QFETCH(bool, qtOnly);
    QFETCH(bool, hfw);
    QFETCH(bool, nested);

    QGraphicsLinearLayout *outerlayout = NULL;
    if(nested) {
       outerlayout = new QGraphicsLinearLayout(m_form);
       for(int i = 0; i < 5; i++) {
           QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
           outerlayout->addItem(layout);
           outerlayout = layout;
       }
    }

    QGraphicsLinearLayout *qlayout = NULL;
    MLayout *layout = NULL;
    MLinearLayoutPolicy *policy = NULL;
    if(qtOnly) {
        qlayout = new QGraphicsLinearLayout(Qt::Vertical);
        if (nested)
            outerlayout->addItem(qlayout);
        else
            m_form->setLayout(qlayout);
    } else {
        layout = new MLayout;
        policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
        if (nested)
            outerlayout->addItem(layout);
        else
            m_form->setLayout(layout);
    }

    for(int i = 0; i < 1; i++) {
        MySquareWidget *widget = new MySquareWidget;
        QSizePolicy sizepolicy = widget->sizePolicy();
        sizepolicy.setHeightForWidth(hfw);
        widget->setSizePolicy(sizepolicy);
        if (qtOnly)
            qlayout->addItem(widget);
        else
            policy->addItem(widget);
    }

    while (MTheme::hasPendingRequests()) {
        usleep(10);
        QCoreApplication::processEvents();
    }

    QBENCHMARK {
        if (qtOnly) {
            qlayout->invalidate();
            QCoreApplication::processEvents();
            (void)qlayout->preferredSize();
        } else {
            layout->invalidate();
            QCoreApplication::processEvents();
            (void)layout->preferredSize();
        }
    }
}