summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/snippets/code/src_corelib_global_qglobal.cpp24
-rw-r--r--projects.pro8
-rw-r--r--src/corelib/global/qglobal.cpp34
-rw-r--r--src/corelib/global/qglobal.h11
-rw-r--r--src/corelib/io/qprocess.cpp45
-rw-r--r--src/corelib/io/qprocess.h4
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/gui/text/qtextodfwriter.cpp2
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp5
-rw-r--r--src/sql/kernel/qsqldriver.cpp4
-rw-r--r--src/sql/kernel/qsqlfield.cpp3
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.cpp10
-rw-r--r--src/sql/models/qsqltablemodel.cpp64
-rw-r--r--src/sql/models/qsqltablemodel_p.h4
-rw-r--r--tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp54
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp7
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp6
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp6
-rw-r--r--translations/translations.pri80
-rw-r--r--translations/translations.pro82
20 files changed, 326 insertions, 129 deletions
diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
index 0b54cef..c79a714 100644
--- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp
+++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
@@ -531,3 +531,27 @@ class MyClass : public QObject
//! [47]
CApaApplication *myApplicationFactory();
//! [47]
+
+//! [qlikely]
+ // the condition inside the "if" will be successful most of the times
+ for (int i = 1; i <= 365; i++) {
+ if (Q_LIKELY(isWorkingDay(i))) {
+ ...
+ }
+ ...
+ }
+//! [qlikely]
+
+//! [qunlikely]
+bool readConfiguration(const QFile &file)
+{
+ // We expect to be asked to read an existing file
+ if (Q_UNLIKELY(!file.exists())) {
+ qWarning() << "File not found";
+ return false;
+ }
+
+ ...
+ return true;
+}
+//! [qunlikely]
diff --git a/projects.pro b/projects.pro
index 2e31e9a..408c8e5 100644
--- a/projects.pro
+++ b/projects.pro
@@ -45,12 +45,8 @@ for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) {
} else:isEqual(PROJECT, docs) {
contains(QT_BUILD_PARTS, tools):include(doc/doc.pri)
} else:isEqual(PROJECT, translations) {
- contains(QT_BUILD_PARTS, tools) {
- include(translations/translations.pri) # ts targets
- } else {
- !wince*:SUBDIRS += tools/linguist/lrelease
- }
- SUBDIRS += translations # qm build step
+ !contains(QT_BUILD_PARTS, tools):!wince*:SUBDIRS += tools/linguist/lrelease
+ SUBDIRS += translations
} else:isEqual(PROJECT, qmake) {
# SUBDIRS += qmake
} else {
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index bcaed41..97b4407 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2870,6 +2870,40 @@ int qrand()
*/
/*!
+ \macro Q_LIKELY(expr)
+ \relates <QtGlobal>
+ \since 4.8
+
+ \brief Hints the compiler that the enclosed condition is likely to evaluate
+ to \c true.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qlikely
+
+ \sa Q_UNLIKELY()
+*/
+
+/*!
+ \macro Q_UNLIKELY(expr)
+ \relates <QtGlobal>
+ \since 4.8
+
+ \brief Hints the compiler that the enclosed condition is likely to evaluate
+ to \c false.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunlikely
+
+ \sa Q_LIKELY()
+*/
+
+/*!
\macro QT_POINTER_SIZE
\relates <QtGlobal>
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index d3b3e14..7c5c354 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -497,6 +497,10 @@ namespace QT_NAMESPACE {}
# define Q_TYPEOF(expr) __typeof__(expr)
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# endif
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
+# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
+# endif
/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
# define Q_WRONG_SB_CTYPE_MACROS
@@ -801,6 +805,13 @@ namespace QT_NAMESPACE {}
# undef Q_NO_PACKED_REFERENCE
#endif
+#ifndef Q_LIKELY
+# define Q_LIKELY(x) (x)
+#endif
+#ifndef Q_UNLIKELY
+# define Q_UNLIKELY(x) (x)
+#endif
+
#ifndef Q_CONSTRUCTOR_FUNCTION
# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
static const int AFUNC ## __init_variable__ = AFUNC();
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index e11cef9..db41a55 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -221,6 +221,24 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
return env;
}
+QStringList QProcessEnvironmentPrivate::keys() const
+{
+ QStringList result;
+ QHash<Unit, Unit>::ConstIterator it = hash.constBegin(),
+ end = hash.constEnd();
+ for ( ; it != end; ++it)
+ result << nameToString(it.key());
+ return result;
+}
+
+void QProcessEnvironmentPrivate::insert(const Hash &h)
+{
+ QHash<Unit, Unit>::ConstIterator it = h.constBegin(),
+ end = h.constEnd();
+ for ( ; it != end; ++it)
+ hash.insert(it.key(), it.value());
+}
+
/*!
Creates a new QProcessEnvironment object. This constructor creates an
empty environment. If set on a QProcess, this will cause the current
@@ -396,6 +414,33 @@ QStringList QProcessEnvironment::toStringList() const
return d ? d->toList() : QStringList();
}
+/*!
+ \since 4.8
+
+ Returns a list containing all the variable names in this QProcessEnvironment
+ object.
+*/
+QStringList QProcessEnvironment::keys() const
+{
+ return d ? d->keys() : QStringList();
+}
+
+/*!
+ \overload
+ \since 4.8
+
+ Inserts the contents of \a e in this QProcessEnvironment object. Variables in
+ this object that also exist in \a e will be overwritten.
+*/
+void QProcessEnvironment::insert(const QProcessEnvironment &e)
+{
+ if (!e.d)
+ return;
+
+ // d detaches from null
+ d->insert(e.d->hash);
+}
+
void QProcessPrivate::Channel::clear()
{
switch (type) {
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index baa67f7..664992f 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -87,6 +87,10 @@ public:
QStringList toStringList() const;
+ QStringList keys() const;
+
+ void insert(const QProcessEnvironment &e);
+
static QProcessEnvironment systemEnvironment();
private:
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index be4f2a0..7bfcb31 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -94,6 +94,8 @@ public:
static QProcessEnvironment fromList(const QStringList &list);
QStringList toList() const;
+ QStringList keys() const;
+ void insert(const Hash &hash);
};
class QProcessPrivate : public QIODevicePrivate
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index c2e47f3..c5ea0cf 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -124,6 +124,7 @@ public:
manifestWriter.writeNamespace(manifestNS, QString::fromLatin1("manifest"));
manifestWriter.writeStartDocument();
manifestWriter.writeStartElement(manifestNS, QString::fromLatin1("manifest"));
+ manifestWriter.writeAttribute(manifestNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
addFile(QString::fromLatin1("/"), QString::fromLatin1("application/vnd.oasis.opendocument.text"));
addFile(QString::fromLatin1("content.xml"), QString::fromLatin1("text/xml"));
}
@@ -786,6 +787,7 @@ bool QTextOdfWriter::writeAll()
writer.writeNamespace(svgNS, QString::fromLatin1("svg"));
writer.writeStartDocument();
writer.writeStartElement(officeNS, QString::fromLatin1("document-content"));
+ writer.writeAttribute(officeNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
// add fragments. (for character formats)
QTextDocumentPrivate::FragmentIterator fragIt = m_document->docHandle()->begin();
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 81410a4..16fd9bb 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -78,6 +78,11 @@ static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const
code = QNetworkReply::ProxyAuthenticationRequiredError;
break;
+ case 418: // I'm a teapot
+ code = QNetworkReply::ProtocolInvalidOperationError;
+ break;
+
+
default:
if (httpStatusCode > 500) {
// some kind of server error
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index c8a16c8..bbec21d 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -496,7 +496,7 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
s.append(QLatin1String("UPDATE ")).append(tableName).append(
QLatin1String(" SET "));
for (i = 0; i < rec.count(); ++i) {
- if (!rec.isGenerated(i) || !rec.value(i).isValid())
+ if (!rec.isGenerated(i))
continue;
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1Char('='));
if (preparedStatement)
@@ -517,7 +517,7 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
s.append(QLatin1String("INSERT INTO ")).append(tableName).append(QLatin1String(" ("));
QString vals;
for (i = 0; i < rec.count(); ++i) {
- if (!rec.isGenerated(i) || !rec.value(i).isValid())
+ if (!rec.isGenerated(i))
continue;
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
if (preparedStatement)
diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp
index a1ab9e3..b7e58b7 100644
--- a/src/sql/kernel/qsqlfield.cpp
+++ b/src/sql/kernel/qsqlfield.cpp
@@ -162,6 +162,7 @@ public:
QSqlField::QSqlField(const QString& fieldName, QVariant::Type type)
{
d = new QSqlFieldPrivate(fieldName, type);
+ val = QVariant(type);
}
/*!
@@ -389,6 +390,8 @@ void QSqlField::setType(QVariant::Type type)
{
detach();
d->type = type;
+ if (!val.isValid())
+ val = QVariant(type);
}
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp
index a261586..63633e6 100644
--- a/src/sql/models/qsqlrelationaltablemodel.cpp
+++ b/src/sql/models/qsqlrelationaltablemodel.cpp
@@ -275,6 +275,7 @@ int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const
void QSqlRelationalTableModelPrivate::clearEditBuffer()
{
editBuffer = baseRec;
+ clearGenerated(editBuffer);
}
/*!
@@ -410,13 +411,14 @@ QVariant QSqlRelationalTableModel::data(const QModelIndex &index, int role) cons
case OnFieldChange:
break;
case OnRowChange:
- if (index.row() == d->editIndex || index.row() == d->insertIndex) {
+ if ((index.row() == d->editIndex || index.row() == d->insertIndex)
+ && d->editBuffer.isGenerated(index.column()))
v = d->editBuffer.value(index.column());
- }
break;
case OnManualSubmit:
const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
- v = row.rec.value(index.column());
+ if (row.op != QSqlTableModelPrivate::None && row.rec.isGenerated(index.column()))
+ v = row.rec.value(index.column());
break;
}
if (v.isValid())
@@ -678,8 +680,10 @@ void QSqlRelationalTableModelPrivate::translateFieldNames(int row, QSqlRecord &v
int realCol = q->indexInQuery(q->createIndex(row, i)).column();
if (realCol != -1 && relations.value(realCol).isValid()) {
QVariant v = values.value(i);
+ bool gen = values.isGenerated(i);
values.replace(i, baseRec.field(realCol));
values.setValue(i, v);
+ values.setGenerated(i, gen);
}
}
}
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index bf7c0aa..99b516a 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -138,6 +138,7 @@ void QSqlTableModelPrivate::revertInsertedRow()
void QSqlTableModelPrivate::clearEditBuffer()
{
editBuffer = rec;
+ clearGenerated(editBuffer);
}
void QSqlTableModelPrivate::clearCache()
@@ -145,6 +146,18 @@ void QSqlTableModelPrivate::clearCache()
cache.clear();
}
+void QSqlTableModelPrivate::clearGenerated(QSqlRecord &rec)
+{
+ for (int i = rec.count() - 1; i >= 0; i--)
+ rec.setGenerated(i, false);
+}
+
+void QSqlTableModelPrivate::setGeneratedValue(QSqlRecord &rec, int c, QVariant v)
+{
+ rec.setValue(c, v);
+ rec.setGenerated(c, true);
+}
+
void QSqlTableModelPrivate::revertCachedRow(int row)
{
Q_Q(QSqlTableModel);
@@ -201,7 +214,7 @@ bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,
}
int i;
for (i = 0; i < rec.count(); ++i) {
- if (rec.isGenerated(i) && rec.value(i).type() != QVariant::Invalid)
+ if (rec.isGenerated(i))
editQuery.addBindValue(rec.value(i));
}
for (i = 0; i < whereValues.count(); ++i) {
@@ -435,26 +448,22 @@ QVariant QSqlTableModel::data(const QModelIndex &index, int role) const
case OnFieldChange:
case OnRowChange:
if (index.row() == d->insertIndex) {
- QVariant val;
if (item.column() < 0 || item.column() >= d->rec.count())
- return val;
- val = d->editBuffer.value(index.column());
- if (val.type() == QVariant::Invalid)
- val = QVariant(d->rec.field(item.column()).type());
- return val;
+ return QVariant();
+ return d->editBuffer.value(index.column());
}
if (d->editIndex == item.row()) {
- QVariant var = d->editBuffer.value(item.column());
- if (var.isValid())
- return var;
+ if (d->editBuffer.isGenerated(item.column()))
+ return d->editBuffer.value(item.column());
+ }
+ break;
+ case OnManualSubmit:
+ if (d->cache.contains(index.row())) {
+ const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
+ if (row.rec.isGenerated(item.column()) || row.op == QSqlTableModelPrivate::Insert)
+ return row.rec.value(item.column());
}
break;
- case OnManualSubmit: {
- const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
- const QVariant var = row.rec.value(item.column());
- if (var.isValid() || row.op == QSqlTableModelPrivate::Insert)
- return var;
- break; }
}
// We need to handle row mapping here, but not column mapping
@@ -503,13 +512,13 @@ bool QSqlTableModel::isDirty(const QModelIndex &index) const
case OnFieldChange:
return false;
case OnRowChange:
- return index.row() == d->editIndex && d->editBuffer.value(index.column()).isValid();
+ return index.row() == d->editIndex && d->editBuffer.isGenerated(index.column());
case OnManualSubmit: {
const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row());
return row.op == QSqlTableModelPrivate::Insert
|| row.op == QSqlTableModelPrivate::Delete
|| (row.op == QSqlTableModelPrivate::Update
- && row.rec.value(index.column()).isValid());
+ && row.rec.isGenerated(index.column()));
}
}
return false;
@@ -538,11 +547,11 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
switch (d->strategy) {
case OnFieldChange: {
if (index.row() == d->insertIndex) {
- d->editBuffer.setValue(index.column(), value);
+ QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
return true;
}
d->clearEditBuffer();
- d->editBuffer.setValue(index.column(), value);
+ QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
isOk = updateRowInTable(index.row(), d->editBuffer);
if (isOk)
select();
@@ -550,7 +559,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
break; }
case OnRowChange:
if (index.row() == d->insertIndex) {
- d->editBuffer.setValue(index.column(), value);
+ QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
return true;
}
if (d->editIndex != index.row()) {
@@ -558,7 +567,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
submit();
d->clearEditBuffer();
}
- d->editBuffer.setValue(index.column(), value);
+ QSqlTableModelPrivate::setGeneratedValue(d->editBuffer, index.column(), value);
d->editIndex = index.row();
emit dataChanged(index, index);
break;
@@ -567,9 +576,10 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
if (row.op == QSqlTableModelPrivate::None) {
row.op = QSqlTableModelPrivate::Update;
row.rec = d->rec;
+ QSqlTableModelPrivate::clearGenerated(row.rec);
row.primaryValues = d->primaryValues(indexInQuery(index).row());
}
- row.rec.setValue(index.column(), value);
+ QSqlTableModelPrivate::setGeneratedValue(row.rec, index.column(), value);
emit dataChanged(index, index);
break; }
}
@@ -1330,6 +1340,7 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
if (mrow.op == QSqlTableModelPrivate::None) {
mrow.op = QSqlTableModelPrivate::Update;
mrow.rec = d->rec;
+ QSqlTableModelPrivate::clearGenerated(mrow.rec);
mrow.primaryValues = d->primaryValues(indexInQuery(createIndex(row, 0)).row());
}
QString fieldName;
@@ -1338,10 +1349,11 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
if (d->db.driver()->isIdentifierEscaped(fieldName, QSqlDriver::FieldName))
fieldName = d->db.driver()->stripDelimiters(fieldName, QSqlDriver::FieldName);
int idx = mrow.rec.indexOf(fieldName);
- if (idx == -1)
+ if (idx == -1) {
isOk = false;
- else
- mrow.rec.setValue(idx, record.value(i));
+ } else {
+ QSqlTableModelPrivate::setGeneratedValue(mrow.rec, idx, record.value(i));
+ }
}
if (isOk)
diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h
index f4f3811..322c23b 100644
--- a/src/sql/models/qsqltablemodel_p.h
+++ b/src/sql/models/qsqltablemodel_p.h
@@ -72,6 +72,8 @@ public:
QSqlRecord primaryValues(int index);
virtual void clearEditBuffer();
virtual void clearCache();
+ static void clearGenerated(QSqlRecord &rec);
+ static void setGeneratedValue(QSqlRecord &rec, int c, QVariant v);
QSqlRecord record(const QVector<QVariant> &values) const;
bool exec(const QString &stmt, bool prepStatement,
@@ -100,7 +102,7 @@ public:
struct ModifiedRow
{
- ModifiedRow(Op o = None, const QSqlRecord &r = QSqlRecord()): op(o), rec(r) {}
+ ModifiedRow(Op o = None, const QSqlRecord &r = QSqlRecord()): op(o), rec(r) { clearGenerated(rec);}
ModifiedRow(const ModifiedRow &other): op(other.op), rec(other.rec), primaryValues(other.primaryValues) {}
Op op;
QSqlRecord rec;
diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
index ea06295..1c26343 100644
--- a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
+++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -56,6 +56,8 @@ private slots:
void insert();
void emptyNull();
void toStringList();
+ void keys();
+ void insertEnv();
void caseSensitivity();
void systemEnvironment();
@@ -154,6 +156,58 @@ void tst_QProcessEnvironment::toStringList()
QVERIFY(result.contains("HELLO=World"));
}
+void tst_QProcessEnvironment::keys()
+{
+ QProcessEnvironment e;
+ QVERIFY(e.isEmpty());
+ QVERIFY(e.keys().isEmpty());
+
+ e.insert("FOO", "bar");
+ QStringList result = e.keys();
+ QCOMPARE(result.length(), 1);
+ QCOMPARE(result.at(0), QString("FOO"));
+
+ e.clear();
+ e.insert("BAZ", "");
+ result = e.keys();
+ QCOMPARE(result.at(0), QString("BAZ"));
+
+ e.insert("FOO", "bar");
+ e.insert("A", "bc");
+ e.insert("HELLO", "World");
+ result = e.keys();
+ QCOMPARE(result.length(), 4);
+
+ // order is not specified, so use contains()
+ QVERIFY(result.contains("FOO"));
+ QVERIFY(result.contains("BAZ"));
+ QVERIFY(result.contains("A"));
+ QVERIFY(result.contains("HELLO"));
+}
+
+void tst_QProcessEnvironment::insertEnv()
+{
+ QProcessEnvironment e;
+ e.insert("FOO", "bar");
+ e.insert("A", "bc");
+ e.insert("Hello", "World");
+
+ QProcessEnvironment e2;
+ e2.insert("FOO2", "bar2");
+ e2.insert("A2", "bc2");
+ e2.insert("Hello", "Another World");
+
+ e.insert(e2);
+ QStringList keys = e.keys();
+ QCOMPARE(keys.length(), 5);
+
+ QCOMPARE(e.value("FOO"), QString("bar"));
+ QCOMPARE(e.value("A"), QString("bc"));
+ QCOMPARE(e.value("Hello"), QString("Another World"));
+ QCOMPARE(e.value("FOO2"), QString("bar2"));
+ QCOMPARE(e.value("A2"), QString("bc2"));
+}
+
void tst_QProcessEnvironment::caseSensitivity()
{
QProcessEnvironment e;
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 288b29c..be2087d 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -928,13 +928,12 @@ void tst_QSqlQuery::record()
QSqlQuery q( db );
QVERIFY( q.record().isEmpty() );
QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) );
- QSqlRecord rec = q.record();
QCOMPARE( q.record().fieldName( 0 ).toLower(), QString( "id" ) );
QCOMPARE( q.record().fieldName( 1 ).toLower(), QString( "t_varchar" ) );
QCOMPARE( q.record().fieldName( 2 ).toLower(), QString( "t_char" ) );
- QVERIFY( !q.record().value( 0 ).isValid() );
- QVERIFY( !q.record().value( 1 ).isValid() );
- QVERIFY( !q.record().value( 2 ).isValid() );
+ QCOMPARE(q.record().value(0), QVariant(q.record().field(0).type()));
+ QCOMPARE(q.record().value(1), QVariant(q.record().field(1).type()));
+ QCOMPARE(q.record().value(2), QVariant(q.record().field(2).type()));
QVERIFY( q.next() );
QVERIFY( q.next() );
diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
index e876764..9507e54 100644
--- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -428,9 +428,9 @@ void tst_QSqlQueryModel::record()
QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id"));
QCOMPARE(rec.fieldName(1), isToUpper ? QString("NAME") : QString("name"));
QCOMPARE(rec.fieldName(2), isToUpper ? QString("TITLE") : QString("title"));
- QCOMPARE(rec.value(0), QVariant());
- QCOMPARE(rec.value(1), QVariant());
- QCOMPARE(rec.value(2), QVariant());
+ QCOMPARE(rec.value(0), QVariant(rec.field(0).type()));
+ QCOMPARE(rec.value(1), QVariant(rec.field(1).type()));
+ QCOMPARE(rec.value(2), QVariant(rec.field(2).type()));
rec = model.record(0);
QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id"));
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index bf68375..b91d025 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -569,9 +569,9 @@ void tst_QSqlTableModel::insertMultiRecords()
QVERIFY(model.insertRow(2));
- QCOMPARE(model.data(model.index(2, 0)), QVariant());
- QCOMPARE(model.data(model.index(2, 1)), QVariant());
- QCOMPARE(model.data(model.index(2, 2)), QVariant());
+ QCOMPARE(model.data(model.index(2, 0)), QVariant(model.record().field(0).type()));
+ QCOMPARE(model.data(model.index(2, 1)), QVariant(model.record().field(1).type()));
+ QCOMPARE(model.data(model.index(2, 2)), QVariant(model.record().field(2).type()));
QVERIFY(model.insertRow(3));
QVERIFY(model.insertRow(0));
diff --git a/translations/translations.pri b/translations/translations.pri
deleted file mode 100644
index 1576bd5..0000000
--- a/translations/translations.pri
+++ /dev/null
@@ -1,80 +0,0 @@
-qtPrepareTool(LCONVERT, lconvert)
-qtPrepareTool(LUPDATE, lupdate)
-LUPDATE += -locations relative -no-ui-lines
-
-TS_TARGETS =
-
-# meta target name, target name, lupdate base options, files
-defineTest(addTsTarget) {
- cv = $${2}.commands
- $$cv = cd $$QT_SOURCE_TREE/src && $$LUPDATE $$3 -ts $$4
- export($$cv)
- dv = $${1}.depends
- $$dv += $$2
- export($$dv)
- TS_TARGETS += $$1 $$2
- export(TS_TARGETS)
-}
-
-# target basename, lupdate base options
-defineTest(addTsTargets) {
- files = $$files($$PWD/$${1}_??.ts) $$files($$PWD/$${1}_??_??.ts)
- for(file, files) {
- lang = $$replace(file, .*_((.._)?..)\\.ts$, \\1)
- addTsTarget(ts-$$lang, ts-$$1-$$lang, $$2, $$file)
- }
- addTsTarget(ts-untranslated, ts-$$1-untranslated, $$2, $$PWD/$${1}_untranslated.ts)
- addTsTarget(ts-all, ts-$$1-all, $$2, $$PWD/$${1}_untranslated.ts $$files)
-}
-
-addTsTargets(qt, -I../include -I../include/Qt \
- 3rdparty/phonon \
- 3rdparty/webkit \
- activeqt \
- corelib \
- declarative \
- gui \
- multimedia \
- network \
- opengl \
- plugins \
- qt3support \
- script \
- scripttools \
- sql \
- svg \
- xml \
- xmlpatterns \
-)
-addTsTargets(designer, ../tools/designer/designer.pro)
-addTsTargets(linguist, ../tools/linguist/linguist.pro)
-addTsTargets(assistant, ../tools/assistant/tools/tools.pro)
-addTsTargets(qt_help, ../tools/assistant/lib/lib.pro)
-addTsTargets(qtconfig, ../tools/qtconfig/qtconfig.pro)
-addTsTargets(qvfb, ../tools/qvfb/qvfb.pro)
-
-check-ts.commands = (cd $$PWD && perl check-ts.pl)
-check-ts.depends = ts-all
-
-isEqual(QMAKE_DIR_SEP, /) {
- commit-ts.commands = \
- cd $$PWD/..; \
- for f in `git diff-files --name-only translations/*_??.ts`; do \
- $$LCONVERT -locations none -i \$\$f -o \$\$f; \
- done; \
- git add translations/*_??.ts && git commit
-} else {
- wd = $$replace(PWD, /, \\)\\..
- commit-ts.commands = \
- cd $$wd && \
- for /f usebackq %%f in (`git diff-files --name-only translations/*_??.ts`) do \
- $$LCONVERT -locations none -i %%f -o %%f $$escape_expand(\\n\\t) \
- cd $$wd && git add translations/*_??.ts && git commit
-}
-
-ts.commands = \
- @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \
- echo \"Use \'ts-<target>-<lang>\' or \'ts-<lang>\' instead. To add a language,\" && \
- echo \"use \'untranslated\' for <lang>, rename the files and re-run \'qmake\'.\"
-
-QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts commit-ts check-ts
diff --git a/translations/translations.pro b/translations/translations.pro
index 14c1177..311b032 100644
--- a/translations/translations.pro
+++ b/translations/translations.pro
@@ -1,8 +1,86 @@
TRANSLATIONS = $$files(*.ts)
qtPrepareTool(LRELEASE, lrelease)
+qtPrepareTool(LCONVERT, lconvert)
+qtPrepareTool(LUPDATE, lupdate)
+LUPDATE += -locations relative -no-ui-lines
-contains(TEMPLATE_PREFIX, vc):vcproj = 1
+TS_TARGETS =
+
+# meta target name, target name, lupdate base options, files
+defineTest(addTsTarget) {
+ cv = $${2}.commands
+ $$cv = cd $$QT_SOURCE_TREE/src && $$LUPDATE $$3 -ts $$4
+ export($$cv)
+ dv = $${1}.depends
+ $$dv += $$2
+ export($$dv)
+ TS_TARGETS += $$1 $$2
+ export(TS_TARGETS)
+}
+
+# target basename, lupdate base options
+defineTest(addTsTargets) {
+ files = $$files($$PWD/$${1}_??.ts) $$files($$PWD/$${1}_??_??.ts)
+ for(file, files) {
+ lang = $$replace(file, .*_((.._)?..)\\.ts$, \\1)
+ addTsTarget(ts-$$lang, ts-$$1-$$lang, $$2, $$file)
+ }
+ addTsTarget(ts-untranslated, ts-$$1-untranslated, $$2, $$PWD/$${1}_untranslated.ts)
+ addTsTarget(ts-all, ts-$$1-all, $$2, $$PWD/$${1}_untranslated.ts $$files)
+}
+
+addTsTargets(qt, -I../include -I../include/Qt \
+ 3rdparty/phonon \
+ 3rdparty/webkit \
+ activeqt \
+ corelib \
+ declarative \
+ gui \
+ multimedia \
+ network \
+ opengl \
+ plugins \
+ qt3support \
+ script \
+ scripttools \
+ sql \
+ svg \
+ xml \
+ xmlpatterns \
+)
+addTsTargets(designer, ../tools/designer/designer.pro)
+addTsTargets(linguist, ../tools/linguist/linguist.pro)
+addTsTargets(assistant, ../tools/assistant/tools/tools.pro)
+addTsTargets(qt_help, ../tools/assistant/lib/lib.pro)
+addTsTargets(qtconfig, ../tools/qtconfig/qtconfig.pro)
+addTsTargets(qvfb, ../tools/qvfb/qvfb.pro)
+
+check-ts.commands = (cd $$PWD && perl check-ts.pl)
+check-ts.depends = ts-all
+
+isEqual(QMAKE_DIR_SEP, /) {
+ commit-ts.commands = \
+ cd $$PWD/..; \
+ for f in `git diff-files --name-only translations/*_??.ts`; do \
+ $$LCONVERT -locations none -i \$\$f -o \$\$f; \
+ done; \
+ git add translations/*_??.ts && git commit
+} else {
+ wd = $$replace(PWD, /, \\)\\..
+ commit-ts.commands = \
+ cd $$wd && \
+ for /f usebackq %%f in (`git diff-files --name-only translations/*_??.ts`) do \
+ $$LCONVERT -locations none -i %%f -o %%f $$escape_expand(\\n\\t) \
+ cd $$wd && git add translations/*_??.ts && git commit
+}
+
+ts.commands = \
+ @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \
+ echo \"Use \'ts-<target>-<lang>\' or \'ts-<lang>\' instead. To add a language,\" && \
+ echo \"use \'untranslated\' for <lang>, rename the files and re-run \'qmake\'.\"
+
+QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts commit-ts check-ts
TEMPLATE = app
TARGET = qm_phony_target
@@ -11,6 +89,8 @@ CONFIG += no_icon
QT =
LIBS =
+contains(TEMPLATE_PREFIX, vc):vcproj = 1
+
updateqm.input = TRANSLATIONS
updateqm.output = ${QMAKE_FILE_BASE}.qm
isEmpty(vcproj):updateqm.variable_out = PRE_TARGETDEPS