summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qprintengine_ps.cpp25
-rw-r--r--src/gui/widgets/qlineedit.cpp10
-rw-r--r--tests/auto/qlineedit/qlineedit.pro1
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp33
4 files changed, 56 insertions, 13 deletions
diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp
index ac94de3..28e9a7a 100644
--- a/src/gui/painting/qprintengine_ps.cpp
+++ b/src/gui/painting/qprintengine_ps.cpp
@@ -485,7 +485,6 @@ void QPSPrintEnginePrivate::emitHeader(bool finished)
QByteArray header;
QPdf::ByteStream s(&header);
- s << "%!PS-Adobe-1.0";
qreal scale = 72. / ((qreal) q->metric(QPaintDevice::PdmDpiY));
QRect pageRect = this->pageRect();
@@ -497,28 +496,32 @@ void QPSPrintEnginePrivate::emitHeader(bool finished)
int width = pageRect.width();
int height = pageRect.height();
if (finished && pageCount == 1 && copies == 1 &&
- ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps"))))
- ) {
+ ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps")))))
+ {
+ // According to the EPSF 3.0 spec it is required that the PS
+ // version is PS-Adobe-3.0
+ s << "%!PS-Adobe-3.0";
if (!boundingBox.isValid())
boundingBox.setRect(0, 0, width, height);
if (orientation == QPrinter::Landscape) {
if (!fullPage)
boundingBox.translate(-mleft, -mtop);
s << " EPSF-3.0\n%%BoundingBox: "
- << (int)(printer->height() - boundingBox.bottom())*scale // llx
- << (int)(printer->width() - boundingBox.right())*scale - 1 // lly
- << (int)(printer->height() - boundingBox.top())*scale + 1 // urx
- << (int)(printer->width() - boundingBox.left())*scale; // ury
+ << int((printer->height() - boundingBox.bottom())*scale) // llx
+ << int((printer->width() - boundingBox.right())*scale - 1) // lly
+ << int((printer->height() - boundingBox.top())*scale + 1) // urx
+ << int((printer->width() - boundingBox.left())*scale); // ury
} else {
if (!fullPage)
boundingBox.translate(mleft, -mtop);
s << " EPSF-3.0\n%%BoundingBox: "
- << (int)(boundingBox.left())*scale
- << (int)(printer->height() - boundingBox.bottom())*scale - 1
- << (int)(boundingBox.right())*scale + 1
- << (int)(printer->height() - boundingBox.top())*scale;
+ << int((boundingBox.left())*scale)
+ << int((printer->height() - boundingBox.bottom())*scale - 1)
+ << int((boundingBox.right())*scale + 1)
+ << int((printer->height() - boundingBox.top())*scale);
}
} else {
+ s << "%!PS-Adobe-1.0";
int w = width + (fullPage ? 0 : mleft + mright);
int h = height + (fullPage ? 0 : mtop + mbottom);
w = (int)(w*scale);
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 2d2df92..f041a36 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -738,8 +738,14 @@ bool QLineEdit::validateAndSet(const QString &newText, int newPos,
setText(oldText);
return false;
}
- setCursorPosition(newPos);
- setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag));
+ int selstart = qMin(newMarkAnchor, newMarkDrag);
+ int sellength = qAbs(newMarkAnchor - newMarkDrag);
+ if (selstart == newPos) {
+ selstart = qMax(newMarkAnchor, newMarkDrag);
+ sellength = -sellength;
+ }
+ //setSelection also set the position
+ setSelection(selstart, sellength);
return true;
}
#endif //QT3_SUPPORT
diff --git a/tests/auto/qlineedit/qlineedit.pro b/tests/auto/qlineedit/qlineedit.pro
index f00a2d8..1f862b4 100644
--- a/tests/auto/qlineedit/qlineedit.pro
+++ b/tests/auto/qlineedit/qlineedit.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+contains(QT_CONFIG,qt3support) QT += qt3support
SOURCES += tst_qlineedit.cpp
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index ca84b38..592c1cb 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -273,6 +273,11 @@ private slots:
void taskQTBUG_4679_selectToStartEndOfBlock();
void taskQTBUG_7395_readOnlyShortcut();
+#ifdef QT3_SUPPORT
+ void validateAndSet_data();
+ void validateAndSet();
+#endif
+
protected slots:
#ifdef QT3_SUPPORT
void lostFocus();
@@ -1488,6 +1493,34 @@ void tst_QLineEdit::lostFocus()
{
editingFinished();
}
+
+void tst_QLineEdit::validateAndSet_data()
+{
+ QTest::addColumn<QString>("newText");
+ QTest::addColumn<int>("newPos");
+ QTest::addColumn<int>("newMarkAnchor");
+ QTest::addColumn<int>("newMarkDrag");
+
+ QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5;
+ QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5;
+}
+
+void tst_QLineEdit::validateAndSet()
+{
+ QFETCH(QString, newText);
+ QFETCH(int, newPos);
+ QFETCH(int, newMarkAnchor);
+ QFETCH(int, newMarkDrag);
+
+ QLineEdit e;
+ e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag);
+ QCOMPARE(e.text(), newText);
+ QCOMPARE(e.cursorPosition(), newPos);
+ QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor));
+}
+
+
+
#endif
void tst_QLineEdit::editingFinished()
{