Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerSectionScene.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | 57 | | |||
58 | void KReportDesignerSectionScene::drawBackground(QPainter* painter, const QRectF & clip) | 58 | void KReportDesignerSectionScene::drawBackground(QPainter* painter, const QRectF & clip) | ||
59 | { | 59 | { | ||
60 | //Draw the default background colour | 60 | //Draw the default background colour | ||
61 | QGraphicsScene::drawBackground(painter, clip); | 61 | QGraphicsScene::drawBackground(painter, clip); | ||
62 | painter->setRenderHint(QPainter::Antialiasing, false); | 62 | painter->setRenderHint(QPainter::Antialiasing, false); | ||
63 | 63 | | |||
64 | if (m_rd->propertySet()->property("grid-visible").value().toBool()) { | 64 | if (m_rd->propertySet()->property("grid-visible").value().toBool()) { | ||
65 | if (m_unit.type() != m_rd->pageUnit().type()) { | | |||
66 | m_unit = m_rd->pageUnit(); | 65 | m_unit = m_rd->pageUnit(); | ||
67 | if (m_unit.type() == KReportUnit::Type::Cicero || | 66 | if (m_unit.type() == KReportUnit::Type::Cicero || | ||
68 | m_unit.type() == KReportUnit::Type::Pica || | 67 | m_unit.type() == KReportUnit::Type::Pica || | ||
69 | m_unit.type() == KReportUnit::Type::Millimeter) { | 68 | m_unit.type() == KReportUnit::Type::Millimeter) { | ||
70 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | 69 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | ||
71 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | 70 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | ||
72 | } else if (m_unit.type() == KReportUnit::Type::Point) { | 71 | } else if (m_unit.type() == KReportUnit::Type::Point) { | ||
73 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiX; | 72 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiX; | ||
74 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiY; | 73 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiY; | ||
75 | } else { | 74 | } else { | ||
76 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiX; | 75 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiX; | ||
77 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiY; | 76 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiY; | ||
78 | } | 77 | } | ||
79 | 78 | | |||
80 | } | | |||
81 | int minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | 79 | int minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | ||
82 | m_pixelIncrementX = (m_majorX / minorSteps); | 80 | m_pixelIncrementX = (m_majorX / minorSteps); | ||
83 | m_pixelIncrementY = (m_majorY / minorSteps); | 81 | m_pixelIncrementY = (m_majorY / minorSteps); | ||
84 | 82 | | |||
85 | QPen pen = painter->pen(); | 83 | QPen pen = painter->pen(); | ||
86 | painter->setPen(Qt::lightGray); | 84 | painter->setPen(Qt::lightGray); | ||
87 | 85 | | |||
88 | //kreportDebug() << "dpix" << KReportPrivate::dpiX() << "dpiy" << KReportPrivate::dpiY() << "mayorx:" << majorx << "majory" << majory << "pix:" << pixel_incrementx << "piy:" << pixel_incrementy; | 86 | //kreportDebug() << "dpix" << KReportPrivate::dpiX() << "dpiy" << KReportPrivate::dpiY() << "mayorx:" << majorx << "majory" << majory << "pix:" << pixel_incrementx << "piy:" << pixel_incrementy; | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
147 | QPointF KReportDesignerSectionScene::gridPoint(const QPointF& p) | 145 | QPointF KReportDesignerSectionScene::gridPoint(const QPointF& p) | ||
148 | { | 146 | { | ||
149 | if (!m_rd->propertySet()->property("grid-snap").value().toBool()) { | 147 | if (!m_rd->propertySet()->property("grid-snap").value().toBool()) { | ||
150 | return p; | 148 | return p; | ||
151 | } | 149 | } | ||
152 | 150 | | |||
153 | if (m_unit.type() != m_rd->pageUnit().type()) { | 151 | if (m_unit.type() != m_rd->pageUnit().type()) { | ||
154 | m_unit = m_rd->pageUnit(); | 152 | m_unit = m_rd->pageUnit(); | ||
155 | //! @todo Again? Copy&Paste error? | | |||
156 | if (m_unit.type() != m_rd->pageUnit().type()) { | | |||
157 | m_unit = m_rd->pageUnit(); | | |||
158 | if (m_unit.type() == KReportUnit::Type::Cicero || | 153 | if (m_unit.type() == KReportUnit::Type::Cicero || | ||
159 | m_unit.type() == KReportUnit::Type::Pica || | 154 | m_unit.type() == KReportUnit::Type::Pica || | ||
160 | m_unit.type() == KReportUnit::Type::Millimeter) { | 155 | m_unit.type() == KReportUnit::Type::Millimeter) { | ||
161 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | 156 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | ||
162 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | 157 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | ||
163 | } else if (m_unit.type() == KReportUnit::Type::Point) { | 158 | } else if (m_unit.type() == KReportUnit::Type::Point) { | ||
164 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiX; | 159 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiX; | ||
165 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiY; | 160 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(100)) * m_dpiY; | ||
166 | } else { | 161 | } else { | ||
167 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiX; | 162 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiX; | ||
168 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiY; | 163 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(1)) * m_dpiY; | ||
169 | } | 164 | } | ||
170 | | ||||
171 | } | | |||
172 | } | 165 | } | ||
173 | int minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | 166 | int minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | ||
174 | m_pixelIncrementX = (m_majorX / minorSteps); | 167 | m_pixelIncrementX = (m_majorX / minorSteps); | ||
175 | m_pixelIncrementY = (m_majorY / minorSteps); | 168 | m_pixelIncrementY = (m_majorY / minorSteps); | ||
176 | 169 | | |||
177 | return QPointF(qRound((p.x() / m_pixelIncrementX)) * m_pixelIncrementX, qRound((p.y() / m_pixelIncrementY)) * m_pixelIncrementY); | 170 | return QPointF(qRound((p.x() / m_pixelIncrementX)) * m_pixelIncrementX, qRound((p.y() / m_pixelIncrementY)) * m_pixelIncrementY); | ||
178 | } | 171 | } | ||
179 | 172 | | |||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |