Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerSectionScene.cpp
Show All 14 Lines | |||||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "KReportDesignerSectionScene.h" | 19 | #include "KReportDesignerSectionScene.h" | ||
20 | #include "KReportDesignerItemRectBase.h" | 20 | #include "KReportDesignerItemRectBase.h" | ||
21 | #include "KReportDesigner.h" | 21 | #include "KReportDesigner.h" | ||
22 | #include "KReportLabelSizeInfo.h" | 22 | #include "KReportLabelSizeInfo.h" | ||
23 | #include "KReportDpi.h" | 23 | #include "KReportUtils_p.h" | ||
24 | #include "kreport_debug.h" | 24 | #include "kreport_debug.h" | ||
25 | 25 | | |||
26 | #include <QPainter> | 26 | #include <QPainter> | ||
27 | #include <QApplication> | 27 | #include <QApplication> | ||
28 | #include <QGraphicsItem> | 28 | #include <QGraphicsItem> | ||
29 | #include <QGraphicsSceneMouseEvent> | 29 | #include <QGraphicsSceneMouseEvent> | ||
30 | 30 | | |||
31 | KReportDesignerSectionScene::KReportDesignerSectionScene(qreal w, qreal h, KReportDesigner *rd) | 31 | KReportDesignerSectionScene::KReportDesignerSectionScene(qreal w, qreal h, KReportDesigner *rd) | ||
32 | : QGraphicsScene(0, 0, w, h, rd) | 32 | : QGraphicsScene(0, 0, w, h, rd) | ||
33 | { | 33 | { | ||
34 | m_rd = rd; | 34 | m_rd = rd; | ||
35 | m_minorSteps = 0; | 35 | m_minorSteps = 0; | ||
36 | m_dpiX = KReportDpi::dpiX(); | 36 | m_dpiX = KReportPrivate::dpiX(); | ||
37 | m_dpiY = KReportDpi::dpiY(); | 37 | m_dpiY = KReportPrivate::dpiY(); | ||
38 | 38 | | |||
39 | if (m_unit.type() != m_rd->pageUnit().type()) { | 39 | if (m_unit.type() != m_rd->pageUnit().type()) { | ||
40 | m_unit = m_rd->pageUnit(); | 40 | m_unit = m_rd->pageUnit(); | ||
41 | if (m_unit.type() == KReportUnit::Cicero || | 41 | if (m_unit.type() == KReportUnit::Cicero || | ||
42 | m_unit.type() == KReportUnit::Pica || | 42 | m_unit.type() == KReportUnit::Pica || | ||
43 | m_unit.type() == KReportUnit::Millimeter) { | 43 | m_unit.type() == KReportUnit::Millimeter) { | ||
44 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | 44 | m_majorX = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiX; | ||
45 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | 45 | m_majorY = POINT_TO_INCH(m_unit.fromUserValue(10)) * m_dpiY; | ||
Show All 36 Lines | 66 | if (m_rd->propertySet()->property("grid-visible").value().toBool()) { | |||
82 | } | 82 | } | ||
83 | m_minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | 83 | m_minorSteps = m_rd->propertySet()->property("grid-divisions").value().toInt(); | ||
84 | m_pixelIncrementX = (m_majorX / m_minorSteps); | 84 | m_pixelIncrementX = (m_majorX / m_minorSteps); | ||
85 | m_pixelIncrementY = (m_majorY / m_minorSteps); | 85 | m_pixelIncrementY = (m_majorY / m_minorSteps); | ||
86 | 86 | | |||
87 | QPen pen = painter->pen(); | 87 | QPen pen = painter->pen(); | ||
88 | painter->setPen(Qt::lightGray); | 88 | painter->setPen(Qt::lightGray); | ||
89 | 89 | | |||
90 | //kreportDebug() << "dpix" << KReportDpi::dpiX() << "dpiy" << KReportDpi::dpiY() << "mayorx:" << majorx << "majory" << majory << "pix:" << pixel_incrementx << "piy:" << pixel_incrementy; | 90 | //kreportDebug() << "dpix" << KReportPrivate::dpiX() << "dpiy" << KReportPrivate::dpiY() << "mayorx:" << majorx << "majory" << majory << "pix:" << pixel_incrementx << "piy:" << pixel_incrementy; | ||
91 | 91 | | |||
92 | QVector<QLine> lines; | 92 | QVector<QLine> lines; | ||
93 | QVector<QPoint> points; | 93 | QVector<QPoint> points; | ||
94 | 94 | | |||
95 | if (m_pixelIncrementX > 2) { // do not bother painting points if increments are so small | 95 | if (m_pixelIncrementX > 2) { // do not bother painting points if increments are so small | ||
96 | int wpoints = qRound(sceneRect().width() / m_pixelIncrementX); | 96 | int wpoints = qRound(sceneRect().width() / m_pixelIncrementX); | ||
97 | int hpoints = qRound(sceneRect().height() / m_pixelIncrementY); | 97 | int hpoints = qRound(sceneRect().height() / m_pixelIncrementY); | ||
98 | for (int i = 0; i < wpoints; ++i) { | 98 | for (int i = 0; i < wpoints; ++i) { | ||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |