bool LayoutPropertySheet::reset(int index) { int left, top, right, bottom; m_layout->getContentsMargins(&left, &top, &right, &bottom); const LayoutPropertyType type = layoutPropertyType(propertyName(index)); bool rc = true; switch (type) { case LayoutPropertyLeftMargin: m_layout->setContentsMargins(-1, top, right, bottom); break; case LayoutPropertyTopMargin: m_layout->setContentsMargins(left, -1, right, bottom); break; case LayoutPropertyRightMargin: m_layout->setContentsMargins(left, top, -1, bottom); break; case LayoutPropertyBottomMargin: m_layout->setContentsMargins(left, top, right, -1); break; default: rc = QDesignerPropertySheet::reset(index); break; } return rc; }
QVariant LayoutPropertySheet::property(int index) const { const LayoutPropertyType type = layoutPropertyType(propertyName(index)); if (const QLayoutWidget *lw = qobject_cast<QLayoutWidget *>(m_layout->parent())) { switch (type) { case LayoutPropertyLeftMargin: return lw->layoutLeftMargin(); case LayoutPropertyTopMargin: return lw->layoutTopMargin(); case LayoutPropertyRightMargin: return lw->layoutRightMargin(); case LayoutPropertyBottomMargin: return lw->layoutBottomMargin(); default: break; } } switch (type) { case LayoutPropertyLeftMargin: case LayoutPropertyTopMargin: case LayoutPropertyRightMargin: case LayoutPropertyBottomMargin: return getLayoutMargin(m_layout, type); case LayoutPropertyHorizontalSpacing: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return grid->horizontalSpacing(); if (const QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) return form->horizontalSpacing(); break; case LayoutPropertyVerticalSpacing: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return grid->verticalSpacing(); if (const QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) return form->verticalSpacing(); case LayoutPropertyBoxStretch: if (const QBoxLayout *box = qobject_cast<QBoxLayout *>(m_layout)) return QVariant(QByteArray(QFormBuilderExtra::boxLayoutStretch(box).toUtf8())); break; case LayoutPropertyGridRowStretch: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return QVariant(QByteArray(QFormBuilderExtra::gridLayoutRowStretch(grid).toUtf8())); break; case LayoutPropertyGridColumnStretch: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return QVariant(QByteArray(QFormBuilderExtra::gridLayoutColumnStretch(grid).toUtf8())); break; case LayoutPropertyGridRowMinimumHeight: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return QVariant(QByteArray(QFormBuilderExtra::gridLayoutRowMinimumHeight(grid).toUtf8())); break; case LayoutPropertyGridColumnMinimumWidth: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return QVariant(QByteArray(QFormBuilderExtra::gridLayoutColumnMinimumWidth(grid).toUtf8())); break; default: break; } return QDesignerPropertySheet::property(index); }
bool LayoutPropertySheet::reset(int index) { int left, top, right, bottom; m_layout->getContentsMargins(&left, &top, &right, &bottom); const LayoutPropertyType type = layoutPropertyType(propertyName(index)); bool rc = true; switch (type) { case LayoutPropertyLeftMargin: m_layout->setContentsMargins(-1, top, right, bottom); break; case LayoutPropertyTopMargin: m_layout->setContentsMargins(left, -1, right, bottom); break; case LayoutPropertyRightMargin: m_layout->setContentsMargins(left, top, -1, bottom); break; case LayoutPropertyBottomMargin: m_layout->setContentsMargins(left, top, right, -1); break; case LayoutPropertyBoxStretch: if (QBoxLayout *box = qobject_cast<QBoxLayout *>(m_layout)) QFormBuilderExtra::clearBoxLayoutStretch(box); break; case LayoutPropertyGridRowStretch: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) QFormBuilderExtra::clearGridLayoutRowStretch(grid); break; case LayoutPropertyGridColumnStretch: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) QFormBuilderExtra::clearGridLayoutColumnStretch(grid); break; case LayoutPropertyGridRowMinimumHeight: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) QFormBuilderExtra::clearGridLayoutRowMinimumHeight(grid); break; case LayoutPropertyGridColumnMinimumWidth: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(grid); break; default: rc = QDesignerPropertySheet::reset(index); break; } return rc; }
void LayoutPropertySheet::setChanged(int index, bool changed) { const LayoutPropertyType type = layoutPropertyType(propertyName(index)); switch (type) { case LayoutPropertySpacing: if (LayoutProperties::visibleProperties(m_layout) & LayoutProperties::HorizSpacingProperty) { setChanged(indexOf(QLatin1String(horizontalSpacing)), changed); setChanged(indexOf(QLatin1String(verticalSpacing)), changed); } break; case LayoutPropertyMargin: setChanged(indexOf(QLatin1String(leftMargin)), changed); setChanged(indexOf(QLatin1String(topMargin)), changed); setChanged(indexOf(QLatin1String(rightMargin)), changed); setChanged(indexOf(QLatin1String(bottomMargin)), changed); break; default: break; } QDesignerPropertySheet::setChanged(index, changed); }
QVariant LayoutPropertySheet::property(int index) const { const LayoutPropertyType type = layoutPropertyType(propertyName(index)); if (const QLayoutWidget *lw = qobject_cast<QLayoutWidget *>(m_layout->parent())) { switch (type) { case LayoutPropertyLeftMargin: return lw->layoutLeftMargin(); case LayoutPropertyTopMargin: return lw->layoutTopMargin(); case LayoutPropertyRightMargin: return lw->layoutRightMargin(); case LayoutPropertyBottomMargin: return lw->layoutBottomMargin(); default: break; } } switch (type) { case LayoutPropertyLeftMargin: case LayoutPropertyTopMargin: case LayoutPropertyRightMargin: case LayoutPropertyBottomMargin: return getLayoutMargin(m_layout, type); case LayoutPropertyHorizontalSpacing: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return grid->horizontalSpacing(); if (const QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) return form->horizontalSpacing(); break; case LayoutPropertyVerticalSpacing: if (const QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) return grid->verticalSpacing(); if (const QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) return form->verticalSpacing(); default: break; } return QDesignerPropertySheet::property(index); }
void LayoutPropertySheet::setProperty(int index, const QVariant &value) { const LayoutPropertyType type = layoutPropertyType(propertyName(index)); if (QLayoutWidget *lw = qobject_cast<QLayoutWidget *>(m_layout->parent())) { switch (type) { case LayoutPropertyLeftMargin: lw->setLayoutLeftMargin(value.toInt()); return; case LayoutPropertyTopMargin: lw->setLayoutTopMargin(value.toInt()); return; case LayoutPropertyRightMargin: lw->setLayoutRightMargin(value.toInt()); return; case LayoutPropertyBottomMargin: lw->setLayoutBottomMargin(value.toInt()); return; case LayoutPropertyMargin: { const int v = value.toInt(); lw->setLayoutLeftMargin(v); lw->setLayoutTopMargin(v); lw->setLayoutRightMargin(v); lw->setLayoutBottomMargin(v); } return; default: break; } } switch (type) { case LayoutPropertyLeftMargin: case LayoutPropertyTopMargin: case LayoutPropertyRightMargin: case LayoutPropertyBottomMargin: setLayoutMargin(m_layout, type, value.toInt()); return; case LayoutPropertyHorizontalSpacing: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { grid->setHorizontalSpacing(value.toInt()); return; } if (QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) { form->setHorizontalSpacing(value.toInt()); return; } break; case LayoutPropertyVerticalSpacing: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { grid->setVerticalSpacing(value.toInt()); return; } if (QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) { form->setVerticalSpacing(value.toInt()); return; } break; case LayoutPropertyBoxStretch: // TODO: Remove the regexp check once a proper editor for integer // lists is in place? if (QBoxLayout *box = qobject_cast<QBoxLayout *>(m_layout)) { const QString stretch = value.toString(); if (isIntegerList(stretch)) QFormBuilderExtra::setBoxLayoutStretch(value.toString(), box); } break; case LayoutPropertyGridRowStretch: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { const QString stretch = value.toString(); if (isIntegerList(stretch)) QFormBuilderExtra::setGridLayoutRowStretch(stretch, grid); } break; case LayoutPropertyGridColumnStretch: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { const QString stretch = value.toString(); if (isIntegerList(stretch)) QFormBuilderExtra::setGridLayoutColumnStretch(value.toString(), grid); } break; case LayoutPropertyGridRowMinimumHeight: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { const QString minSize = value.toString(); if (isIntegerList(minSize)) QFormBuilderExtra::setGridLayoutRowMinimumHeight(minSize, grid); } break; case LayoutPropertyGridColumnMinimumWidth: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { const QString minSize = value.toString(); if (isIntegerList(minSize)) QFormBuilderExtra::setGridLayoutColumnMinimumWidth(minSize, grid); } break; default: break; } QDesignerPropertySheet::setProperty(index, value); }
void LayoutPropertySheet::setProperty(int index, const QVariant &value) { const LayoutPropertyType type = layoutPropertyType(propertyName(index)); if (QLayoutWidget *lw = qobject_cast<QLayoutWidget *>(m_layout->parent())) { switch (type) { case LayoutPropertyLeftMargin: lw->setLayoutLeftMargin(value.toInt()); return; case LayoutPropertyTopMargin: lw->setLayoutTopMargin(value.toInt()); return; case LayoutPropertyRightMargin: lw->setLayoutRightMargin(value.toInt()); return; case LayoutPropertyBottomMargin: lw->setLayoutBottomMargin(value.toInt()); return; case LayoutPropertyMargin: { const int v = value.toInt(); lw->setLayoutLeftMargin(v); lw->setLayoutTopMargin(v); lw->setLayoutRightMargin(v); lw->setLayoutBottomMargin(v); } return; default: break; } } switch (type) { case LayoutPropertyLeftMargin: case LayoutPropertyTopMargin: case LayoutPropertyRightMargin: case LayoutPropertyBottomMargin: setLayoutMargin(m_layout, type, value.toInt()); return; case LayoutPropertyHorizontalSpacing: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { grid->setHorizontalSpacing(value.toInt()); return; } if (QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) { form->setHorizontalSpacing(value.toInt()); return; } break; case LayoutPropertyVerticalSpacing: if (QGridLayout *grid = qobject_cast<QGridLayout *>(m_layout)) { grid->setVerticalSpacing(value.toInt()); return; } if (QFormLayout *form = qobject_cast<QFormLayout *>(m_layout)) { form->setVerticalSpacing(value.toInt()); return; } break; default: break; } QDesignerPropertySheet::setProperty(index, value); }