bool OrderByHeightProvider::precedes( PageId const& lhs_page, bool const lhs_incomplete, PageId const& rhs_page, bool const rhs_incomplete) const { std::auto_ptr<Params> const lhs_params(m_ptrSettings->getPageParams(lhs_page)); std::auto_ptr<Params> const rhs_params(m_ptrSettings->getPageParams(rhs_page)); QSizeF lhs_size; if (lhs_params.get()) { Margins const margins(lhs_params->hardMarginsMM()); lhs_size = lhs_params->contentSizeMM(); lhs_size += QSizeF( margins.left() + margins.right(), margins.top() + margins.bottom() ); } QSizeF rhs_size; if (rhs_params.get()) { Margins const margins(rhs_params->hardMarginsMM()); rhs_size = rhs_params->contentSizeMM(); rhs_size += QSizeF( margins.left() + margins.right(), margins.top() + margins.bottom() ); } bool const lhs_valid = !lhs_incomplete && lhs_size.isValid(); bool const rhs_valid = !rhs_incomplete && rhs_size.isValid(); if (lhs_valid != rhs_valid) { // Invalid (unknown) sizes go to the back. return lhs_valid; } return lhs_size.height() < rhs_size.height(); }
void OptionsWidget::preUpdateUI( PageId const& page_id, Margins const& margins_mm, Alignment const& alignment) { m_pageId = page_id; m_marginsMM = margins_mm; m_alignment = alignment; typedef AlignmentByButton::value_type KeyVal; BOOST_FOREACH (KeyVal const& kv, m_alignmentByButton) { if (kv.second == m_alignment) { kv.first->setChecked(true); } } updateMarginsDisplay(); alignWithOthersCB->blockSignals(true); alignWithOthersCB->setChecked(!alignment.isNull()); alignWithOthersCB->blockSignals(false); enableDisableAlignmentButtons(); m_leftRightLinked = m_leftRightLinked && (margins_mm.left() == margins_mm.right()); m_topBottomLinked = m_topBottomLinked && (margins_mm.top() == margins_mm.bottom()); updateLinkDisplay(topBottomLink, m_topBottomLinked); updateLinkDisplay(leftRightLink, m_leftRightLinked); marginsGroup->setEnabled(false); alignmentGroup->setEnabled(false); }
void Page::setMargins(const Margins &margins, CuteReport::Unit unit) { if (!m_inited) { d->margins = margins; return; } Unit u = (unit == UnitNotDefined) ? d->unit : unit; QPointF p1 = convertUnit(QPointF(margins.left(), margins.top()), u, Millimeter, d->dpi); QPointF p2 = convertUnit(QPointF(margins.right(), margins.bottom()), u, Millimeter, d->dpi); Margins newMarginMM(p1.x(), p1.y(), p2.x(), p2.y()); if (d->margins == newMarginMM) return; d->margins = margins; if (d->margins.left() < 0) d->margins.setLeft(0); if (d->margins.top() < 0) d->margins.setTop(0); if (d->margins.right() < 0) d->margins.setRight(0); if (d->margins.bottom() < 0) d->margins.setBottom(0); afterGeometryChanged(); emit marginsChanged(this->margins(d->unit)); }