summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:36:53 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-10 13:36:53 (GMT)
commit7b15c669c336a1d76e3ac001fadde38a294e3e80 (patch)
tree2b8e9631019d1bc9af37d9a93bb93ce0eb16381a
parent47bc34f413d9a0c6efac6ca3eead95eed7da2e40 (diff)
parent86048e1a09fce11f557d0e8b117229a754ee9098 (diff)
downloadQt-7b15c669c336a1d76e3ac001fadde38a294e3e80.zip
Qt-7b15c669c336a1d76e3ac001fadde38a294e3e80.tar.gz
Qt-7b15c669c336a1d76e3ac001fadde38a294e3e80.tar.bz2
Merge branch 'tools-team/4.6' (early part) into 4.6
Conflicts: src/corelib/tools/qscopedpointer.h
-rw-r--r--src/corelib/io/qsettings_p.h1
-rw-r--r--src/corelib/tools/qscopedpointer.h64
-rw-r--r--src/corelib/tools/qscopedpointer_p.h131
-rw-r--r--src/corelib/tools/tools.pri3
-rw-r--r--src/gui/kernel/qwidget.cpp9
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h2
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalue_p.h2
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalueproperty_p.h2
-rw-r--r--src/scripttools/debugging/qscriptscriptdata_p.h2
-rw-r--r--src/scripttools/debugging/qscriptvalueproperty_p.h2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp17
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before22
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result25
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result8
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result12
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp5
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result6
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp1
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp120
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h9
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp5
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp21
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h1
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp2
-rw-r--r--tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp19
-rw-r--r--tools/linguist/lconvert/main.cpp4
-rw-r--r--tools/linguist/linguist/messagemodel.cpp21
-rw-r--r--tools/linguist/lrelease/main.cpp2
-rw-r--r--tools/linguist/lupdate/cpp.cpp26
-rw-r--r--tools/linguist/lupdate/merge.cpp85
-rw-r--r--tools/linguist/lupdate/qscript.cpp2
-rw-r--r--tools/linguist/shared/qm.cpp12
-rw-r--r--tools/linguist/shared/translator.cpp189
-rw-r--r--tools/linguist/shared/translator.h14
-rw-r--r--tools/linguist/shared/translatormessage.cpp34
-rw-r--r--tools/linguist/shared/translatormessage.h31
40 files changed, 593 insertions, 350 deletions
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index bcd8744..5ad72e4 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -62,6 +62,7 @@
#ifndef QT_NO_QOBJECT
#include "private/qobject_p.h"
#endif
+#include "private/qscopedpointer_p.h"
#ifdef Q_OS_WIN
#include "QtCore/qt_windows.h"
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index b433723..c40b3cf 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -209,70 +209,6 @@ private:
Q_DISABLE_COPY(QScopedArrayPointer)
};
-/* Internal helper class - exposes the data through data_ptr (legacy from QShared).
- Required for some internal Qt classes, do not use otherwise. */
-template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
-class QCustomScopedPointer : public QScopedPointer<T, Cleanup>
-{
-public:
- explicit inline QCustomScopedPointer(T *p = 0)
- : QScopedPointer<T, Cleanup>(p)
- {
- }
-
- inline T *&data_ptr()
- {
- return this->d;
- }
-
-private:
- Q_DISABLE_COPY(QCustomScopedPointer)
-};
-
-/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */
-template <typename T>
-class QScopedPointerSharedDeleter
-{
-public:
- static inline void cleanup(T *d)
- {
- if (d && !d->ref.deref())
- delete d;
- }
-};
-
-/* Internal.
- This class is basically a scoped pointer pointing to a ref-counted object
- */
-template <typename T>
-class QScopedSharedPointer : public QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >
-{
-public:
- explicit inline QScopedSharedPointer(T *p = 0)
- : QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >(p)
- {
- }
-
- inline void detach()
- {
- qAtomicDetach(this->d);
- }
-
- inline void assign(T *other)
- {
- if (this->d == other)
- return;
- if (other)
- other->ref.ref();
- T *oldD = this->d;
- this->d = other;
- QScopedPointerSharedDeleter<T>::cleanup(oldD);
- }
-
-private:
- Q_DISABLE_COPY(QScopedSharedPointer)
-};
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
new file mode 100644
index 0000000..b1636d5
--- /dev/null
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QSCOPEDPOINTER_P_H
+#define QSCOPEDPOINTER_P_H
+
+#include "QtCore/qscopedpointer.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+QT_MODULE(Core)
+
+
+/* Internal helper class - exposes the data through data_ptr (legacy from QShared).
+ Required for some internal Qt classes, do not use otherwise. */
+template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
+class QCustomScopedPointer : public QScopedPointer<T, Cleanup>
+{
+public:
+ explicit inline QCustomScopedPointer(T *p = 0)
+ : QScopedPointer<T, Cleanup>(p)
+ {
+ }
+
+ inline T *&data_ptr()
+ {
+ return this->d;
+ }
+
+private:
+ Q_DISABLE_COPY(QCustomScopedPointer)
+};
+
+/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */
+template <typename T>
+class QScopedPointerSharedDeleter
+{
+public:
+ static inline void cleanup(T *d)
+ {
+ if (d && !d->ref.deref())
+ delete d;
+ }
+};
+
+/* Internal.
+ This class is basically a scoped pointer pointing to a ref-counted object
+ */
+template <typename T>
+class QScopedSharedPointer : public QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >
+{
+public:
+ explicit inline QScopedSharedPointer(T *p = 0)
+ : QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >(p)
+ {
+ }
+
+ inline void detach()
+ {
+ qAtomicDetach(this->d);
+ }
+
+ inline void assign(T *other)
+ {
+ if (this->d == other)
+ return;
+ if (other)
+ other->ref.ref();
+ T *oldD = this->d;
+ this->d = other;
+ QScopedPointerSharedDeleter<T>::cleanup(oldD);
+ }
+
+private:
+ Q_DISABLE_COPY(QScopedSharedPointer)
+};
+
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 007b763..3406e41 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -44,7 +44,8 @@ HEADERS += \
tools/qunicodetables_p.h \
tools/qvarlengtharray.h \
tools/qvector.h \
- tools/qscopedpointer.h
+ tools/qscopedpointer.h \
+ tools/qscopedpointer_p.h
SOURCES += \
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index e764774..c776c36 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -11781,10 +11781,6 @@ void QWidget::ungrabGesture(Qt::GestureType gesture)
}
-QT_END_NAMESPACE
-
-#include "moc_qwidget.cpp"
-
/*!
\typedef WId
\relates QWidget
@@ -12101,3 +12097,8 @@ void QWidgetPrivate::_q_delayedDestroy(WId winId)
delete winId;
}
#endif
+
+QT_END_NAMESPACE
+
+#include "moc_qwidget.cpp"
+
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
index 4a9447a..2513a8c 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/private/qscopedpointer_p.h>
#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
diff --git a/src/scripttools/debugging/qscriptdebuggervalue_p.h b/src/scripttools/debugging/qscriptdebuggervalue_p.h
index 2f1da1e..452f7ea 100644
--- a/src/scripttools/debugging/qscriptdebuggervalue_p.h
+++ b/src/scripttools/debugging/qscriptdebuggervalue_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/private/qscopedpointer_p.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
index 2ec6124..b130307 100644
--- a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
+++ b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qlist.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/private/qscopedpointer_p.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_NAMESPACE
diff --git a/src/scripttools/debugging/qscriptscriptdata_p.h b/src/scripttools/debugging/qscriptscriptdata_p.h
index 5006c19..f42ffa5 100644
--- a/src/scripttools/debugging/qscriptscriptdata_p.h
+++ b/src/scripttools/debugging/qscriptscriptdata_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/private/qscopedpointer_p.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qmap.h>
diff --git a/src/scripttools/debugging/qscriptvalueproperty_p.h b/src/scripttools/debugging/qscriptvalueproperty_p.h
index 61b239d..ca290a1 100644
--- a/src/scripttools/debugging/qscriptvalueproperty_p.h
+++ b/src/scripttools/debugging/qscriptvalueproperty_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qlist.h>
-#include <QtCore/qscopedpointer.h>
+#include <QtCore/private/qscopedpointer_p.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
index 53eba32..5bd7a0a 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp
@@ -63,5 +63,20 @@ void FindDialog::reset()
{
tr("%n item(s)", "merge from singular to plural form", 4);
tr("%n item(s)", "merge from a finished singular form to an unfinished plural form", 4);
-}
+
+
+ //% "Hello"
+ qtTrId("xx_hello");
+
+ //% "New world"
+ qtTrId("xx_world");
+
+
+ //= new_id
+ tr("this is just some text");
+
+
+ //: A message without source string
+ qtTrId("qtn_virtual");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
index d06252c..379cce4 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before
@@ -1,6 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="zh_CN">
<context>
+ <name></name>
+ <message id="xx_hello">
+ <location filename="finddialog.cpp" line="70"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message id="xx_world">
+ <location filename="finddialog.cpp" line="73"/>
+ <source>World</source>
+ <translation>Welt</translation>
+ </message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="79"/>
+ <extracomment>A message without source string</extracomment>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source></source>
@@ -44,5 +61,10 @@
<numerusform></numerusform>
</translation>
</message>
+ <message>
+ <location filename="finddialog.cpp" line="59"/>
+ <source>this is just some text</source>
+ <translation type="unfinished">Unfertige Uebersetzung</translation>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
index be4e02e..de43266 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result
@@ -2,6 +2,26 @@
<!DOCTYPE TS>
<TS version="2.0" language="zh_CN">
<context>
+ <name></name>
+ <message id="xx_hello">
+ <location filename="finddialog.cpp" line="70"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message id="xx_world">
+ <location filename="finddialog.cpp" line="73"/>
+ <source>New world</source>
+ <oldsource>World</oldsource>
+ <translation type="unfinished">Welt</translation>
+ </message>
+ <message id="qtn_virtual">
+ <location filename="finddialog.cpp" line="81"/>
+ <source></source>
+ <extracomment>A message without source string</extracomment>
+ <translation></translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source></source>
@@ -45,5 +65,10 @@
<numerusform></numerusform>
</translation>
</message>
+ <message id="new_id">
+ <location filename="finddialog.cpp" line="77"/>
+ <source>this is just some text</source>
+ <translation type="unfinished">Unfertige Uebersetzung</translation>
+ </message>
</context>
</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
index e1464a2..9abb367 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp
@@ -148,4 +148,7 @@ void FindDialog::doFind(bool forward)
bool FindDialog::hasFindExpression() const
{
// statusMessage(tr( "Should be obsolete" ));
+
+ //% "This is some random text"
+ qtTrId("keep_id")
}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
index 834f512..feab169 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before
@@ -1,6 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="153"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <location filename="finddialog.cpp" line="155"/>
+ <source>Should be obsolete, too</source>
+ <translation type="unfinished">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
index b328e90..ee3d0f6 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result
@@ -2,6 +2,14 @@
<!DOCTYPE TS>
<TS version="2.0">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="153"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
index 7b28c75..cc3af48 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp
@@ -150,6 +150,9 @@ void FindDialog::doFind(bool forward)
bool FindDialog::hasFindExpression() const
{
+ //% "This is some random text"
+ qtTrId("keep_id")
+
return !findExpr.isEmpty();
}
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
index 1fa0fd3..2bc6049 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before
@@ -1,6 +1,19 @@
<?xml version="1.0"?>
<!DOCTYPE TS><TS version="1.1">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="154"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <location filename="finddialog.cpp" line="155"/>
+ <source>Should be obsolete, too</source>
+ <translation type="unfinished">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<location filename="finddialog.cpp" line="85"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
index cfd11b1..f442cbc 100644
--- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result
@@ -2,6 +2,18 @@
<!DOCTYPE TS>
<TS version="2.0">
<context>
+ <name></name>
+ <message id="keep_id">
+ <location filename="finddialog.cpp" line="154"/>
+ <source>This is some random text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="obsolete_id">
+ <source>Should be obsolete, too</source>
+ <translation type="obsolete">SHOULD BE OBSOLETE AS WELL</translation>
+ </message>
+</context>
+<context>
<name>FindDialog</name>
<message>
<source>Enter the text you are looking for.</source>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index e243e66..386d9b7 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -247,3 +247,8 @@ class YetAnotherTest : QObject {
tr("nothing");
}
};
+
+
+
+//: This is a message without a source string
+QString test = qtTrId("yet_another_id");
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index 26e5a65..6d50c21 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -18,6 +18,12 @@ backslashed \ stuff.</source>
</translation>
<extra-some>thing</extra-some>
</message>
+ <message id="yet_another_id">
+ <location filename="main.cpp" line="254"/>
+ <source></source>
+ <extracomment>This is a message without a source string</extracomment>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>Dialog2</name>
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 9cccd82..511a56e 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -621,6 +621,7 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine)
: treeModel(new BookmarkModel(0, 1, this))
, listModel(new BookmarkModel(0, 1, this))
+ , renameItem(0)
, helpEngine(_helpEngine)
{
folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 62b4736..67d803d 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -666,34 +666,16 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
quoteTabTitle(viewer->documentTitle())));
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
- }
+ QFont font;
+ getBrowserFontFor(viewer, &font);
- QWebView *view = qobject_cast<QWebView*> (viewer);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (viewer) {
- viewer->setFont(font);
- }
- viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
-#else
+#if defined(QT_NO_WEBKIT)
font.setPointSize((int)(font.pointSize() + zoom));
- viewer->setFont(font);
+ setBrowserFontFor(viewer, font);
viewer->setZoom((int)zoom);
+#else
+ setBrowserFontFor(viewer, font);
+ viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
#endif
connectSignals();
@@ -1011,41 +993,17 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf,
void CentralWidget::updateBrowserFont()
{
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
+ QFont font;
+ bool searchAttached = searchWidgetAttached();
+ if (searchAttached) {
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
-#endif
- QWidget *widget = 0;
- for (int i = 0; i < tabWidget->count(); ++i) {
- widget = tabWidget->widget(i);
-#if !defined(QT_NO_WEBKIT)
- QWebView *view = qobject_cast<QWebView*> (widget);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (widget) {
- if (!userFont)
- font = qApp->font();
- widget->setFont(font);
- }
-#else
- if (widget && widget->font() != font)
- widget->setFont(font);
-#endif
- }
+ int i = searchAttached ? 1 : 0;
+ getBrowserFontFor(tabWidget->widget(i), &font);
+ for (i; i < tabWidget->count(); ++i)
+ setBrowserFontFor(tabWidget->widget(i), font);
}
void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
@@ -1058,6 +1016,10 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
SLOT(setSourceFromSearch(QUrl)));
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
SLOT(setSourceFromSearchInNewTab(QUrl)));
+
+ QFont font;
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
void CentralWidget::activateSearchWidget(bool updateLastTabPage)
@@ -1079,7 +1041,7 @@ void CentralWidget::activateSearchWidget(bool updateLastTabPage)
void CentralWidget::removeSearchWidget()
{
- if (m_searchWidget && m_searchWidget->isAttached()) {
+ if (searchWidgetAttached()) {
tabWidget->removeTab(0);
m_searchWidget->setAttached(false);
}
@@ -1088,7 +1050,7 @@ void CentralWidget::removeSearchWidget()
int CentralWidget::availableHelpViewer() const
{
int count = tabWidget->count();
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
count--;
return count;
}
@@ -1096,7 +1058,7 @@ int CentralWidget::availableHelpViewer() const
bool CentralWidget::enableTabCloseAction() const
{
int minTabCount = 1;
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
minTabCount = 2;
return (tabWidget->count() > minTabCount);
@@ -1199,4 +1161,40 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const
return sourceList;
}
+void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font)
+{
+ const QLatin1String key("useBrowserFont");
+ if (!helpEngine->customValue(key, false).toBool()) {
+ *font = qApp->font(); // case for QTextBrowser and SearchWidget
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (viewer);
+ if (view) {
+ QWebSettings *settings = QWebSettings::globalSettings();
+ *font = QFont(settings->fontFamily(QWebSettings::StandardFont),
+ settings->fontSize(QWebSettings::DefaultFontSize));
+ }
+#endif
+ } else {
+ *font = qVariantValue<QFont>(helpEngine->customValue(
+ QLatin1String("browserFont")));
+ }
+}
+
+void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font)
+{
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (widget);
+ if (view) {
+ QWebSettings *settings = view->settings();
+ settings->setFontFamily(QWebSettings::StandardFont, font.family());
+ settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
+ } else if (widget && widget->font() != font) {
+ widget->setFont(font);
+ }
+#else
+ if (widget && widget->font() != font)
+ widget->setFont(font);
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 7ae8ee5..8c186f0 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -48,6 +48,8 @@
#include <QtGui/QWidget>
+#include "searchwidget.h"
+
QT_BEGIN_NAMESPACE
class QEvent;
@@ -65,7 +67,6 @@ class CentralWidget;
class PrintHelper;
class MainWindow;
-class SearchWidget;
class QHelpSearchEngine;
class FindWidget : public QWidget
@@ -123,6 +124,9 @@ public:
HelpViewer *currentHelpViewer() const;
void activateTab(bool onlyHelpViewer = false);
+ bool searchWidgetAttached() const {
+ return m_searchWidget && m_searchWidget->isAttached();
+ }
void createSearchWidget(QHelpSearchEngine *searchEngine);
void activateSearchWidget(bool updateLastTabPage = false);
void removeSearchWidget();
@@ -190,6 +194,9 @@ private:
void highlightSearchTerms();
void setLastShownPages();
+ void getBrowserFontFor(QWidget* viewer, QFont *font);
+ void setBrowserFontFor(QWidget *widget, const QFont &font);
+
private:
int lastTabPage;
QString collectionFile;
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index c888a5f..3547652 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -133,10 +133,9 @@ HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine,
{
}
-QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
- const QNetworkRequest &request, QIODevice *outgoingData)
+QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
+ const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
- const QString& scheme = request.url().scheme();
const QUrl& url = request.url();
QString mimeType = url.toString();
if (mimeType.endsWith(QLatin1String(".svg"))
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index de3f695..c56e7e4 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -227,16 +227,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
if (!m_cmdLine->currentFilter().isEmpty()) {
const QString &curFilter = m_cmdLine->currentFilter();
- m_helpEngine->setCurrentFilter(curFilter);
- if (m_filterCombo) {
- int idx = m_filterCombo->findText(curFilter);
- if (idx >= 0) {
- bool blocked = m_filterCombo->signalsBlocked();
- m_filterCombo->blockSignals(true);
- m_filterCombo->setCurrentIndex(idx);
- m_filterCombo->blockSignals(blocked);
- }
- }
+ if (m_helpEngine->customFilters().contains(curFilter))
+ m_helpEngine->setCurrentFilter(curFilter);
}
if (usesDefaultCollection())
@@ -664,6 +656,8 @@ void MainWindow::setupFilterToolbar()
SLOT(setupFilterCombo()));
connect(m_filterCombo, SIGNAL(activated(QString)), this,
SLOT(filterDocumentation(QString)));
+ connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)), this,
+ SLOT(currentFilterChanged(QString)));
setupFilterCombo();
}
@@ -1041,4 +1035,11 @@ QString MainWindow::defaultHelpCollectionFileName()
arg(QLatin1String(QT_VERSION_STR));
}
+void MainWindow::currentFilterChanged(const QString &filter)
+{
+ const int index = m_filterCombo->findText(filter);
+ Q_ASSERT(index != -1);
+ m_filterCombo->setCurrentIndex(index);
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 6b858e9..7559fe4 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -95,6 +95,7 @@ public slots:
void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();
+ void currentFilterChanged(const QString &filter);
private slots:
void insertLastPages();
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index be1c197..474a681 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -237,6 +237,8 @@ void RemoteControl::handleCommandString(const QString &cmdString)
else
m_mainWindow->expandTOC(depth);
} else if (cmd == QLatin1String("setcurrentfilter")) {
+ if (!m_helpEngine->customFilters().contains(arg))
+ return;
if (m_caching) {
clearCache();
m_currentFilter = arg;
diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
index 7ab7cb4..e36e828 100644
--- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
+++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
@@ -73,6 +73,7 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QToolButton>
#include <QtGui/QButtonGroup>
+#include <QtGui/QToolBar>
QT_BEGIN_NAMESPACE
@@ -724,20 +725,20 @@ SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *cor
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
- layout->addWidget(m_view);
+ layout->setSpacing(0);
- QHBoxLayout *layout2 = new QHBoxLayout;
- layout2->setMargin(3);
- layout->addLayout(layout2);
- layout2->addStretch();
+ QToolBar *toolBar = new QToolBar;
+ toolBar->setIconSize(QSize(22, 22));
+ m_add_button->setIcon(createIconSet(QLatin1String("plus.png")));
+ connect(m_add_button, SIGNAL(clicked()), this, SLOT(addConnection()));
+ toolBar->addWidget(m_add_button);
m_remove_button->setIcon(createIconSet(QLatin1String("minus.png")));
connect(m_remove_button, SIGNAL(clicked()), this, SLOT(removeConnection()));
- layout2->addWidget(m_remove_button);
+ toolBar->addWidget(m_remove_button);
- m_add_button->setIcon(createIconSet(QLatin1String("plus.png")));
- connect(m_add_button, SIGNAL(clicked()), this, SLOT(addConnection()));
- layout2->addWidget(m_add_button);
+ layout->addWidget(toolBar);
+ layout->addWidget(m_view);
connect(core->formWindowManager(),
SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp
index 6f5f86a..7807761 100644
--- a/tools/linguist/lconvert/main.cpp
+++ b/tools/linguist/lconvert/main.cpp
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
qWarning() << qPrintable(cd.error());
return 2;
}
- Translator::reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose);
+ tr.reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose);
for (int i = 1; i < inFiles.size(); ++i) {
Translator tr2;
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
qWarning() << qPrintable(cd.error());
return 2;
}
- Translator::reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose);
+ tr2.reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose);
for (int j = 0; j < tr2.messageCount(); ++j)
tr.replaceSorted(tr2.message(j));
}
diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp
index e6bb9af..024fd91 100644
--- a/tools/linguist/linguist/messagemodel.cpp
+++ b/tools/linguist/linguist/messagemodel.cpp
@@ -209,20 +209,29 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent
return false;
}
- QSet<TranslatorMessagePtr> dupes = tor.resolveDuplicates();
- if (!dupes.isEmpty()) {
+ Translator::Duplicates dupes = tor.resolveDuplicates();
+ if (!dupes.byId.isEmpty() || !dupes.byContents.isEmpty()) {
QString err = tr("<qt>Duplicate messages found in '%1':").arg(Qt::escape(fileName));
int numdups = 0;
- foreach (const TranslatorMessagePtr &msg, dupes) {
+ foreach (int i, dupes.byId) {
+ if (++numdups >= 5) {
+ err += tr("<p>[more duplicates omitted]");
+ goto doWarn;
+ }
+ err += tr("<p>* ID: %1").arg(Qt::escape(tor.message(i).id()));
+ }
+ foreach (int j, dupes.byContents) {
+ const TranslatorMessage &msg = tor.message(j);
if (++numdups >= 5) {
err += tr("<p>[more duplicates omitted]");
break;
}
err += tr("<p>* Context: %1<br>* Source: %2")
- .arg(Qt::escape(msg->context()), Qt::escape(msg->sourceText()));
- if (!msg->comment().isEmpty())
- err += tr("<br>* Comment: %3").arg(Qt::escape(msg->comment()));
+ .arg(Qt::escape(msg.context()), Qt::escape(msg.sourceText()));
+ if (!msg.comment().isEmpty())
+ err += tr("<br>* Comment: %3").arg(Qt::escape(msg.comment()));
}
+ doWarn:
QMessageBox::warning(parent, QObject::tr("Qt Linguist"), err);
}
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp
index ecaed27..742c2e6 100644
--- a/tools/linguist/lrelease/main.cpp
+++ b/tools/linguist/lrelease/main.cpp
@@ -105,7 +105,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo
static bool releaseTranslator(Translator &tor, const QString &qmFileName,
ConversionData &cd, bool removeIdentical)
{
- Translator::reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose());
+ tor.reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose());
if (cd.isVerbose())
printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName));
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index fb95a95..443abd0 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -1883,22 +1883,18 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
case Tok_trid:
if (!tor)
goto case_default;
- if (sourcetext.isEmpty()) {
- yyTok = getToken();
- } else {
- if (!msgid.isEmpty())
- qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n",
- qPrintable(yyFileName), yyLineNo);
- //utf8 = false; // Maybe use //%% or something like that
- line = yyLineNo;
- yyTok = getToken();
- if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) {
- bool plural = match(Tok_Comma);
- recordMessage(line, QString(), sourcetext, QString(), extracomment,
- msgid, extra, false, plural);
- }
- sourcetext.clear();
+ if (!msgid.isEmpty())
+ qWarning("%s:%d: //= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n",
+ qPrintable(yyFileName), yyLineNo);
+ //utf8 = false; // Maybe use //%% or something like that
+ line = yyLineNo;
+ yyTok = getToken();
+ if (match(Tok_LeftParen) && matchString(&msgid) && !msgid.isEmpty()) {
+ bool plural = match(Tok_Comma);
+ recordMessage(line, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, false, plural);
}
+ sourcetext.clear();
extracomment.clear();
msgid.clear();
extra.clear();
diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp
index b5f77cd..fa0dd3d 100644
--- a/tools/linguist/lupdate/merge.cpp
+++ b/tools/linguist/lupdate/merge.cpp
@@ -247,10 +247,8 @@ int applyNumberHeuristic(Translator &tor)
t = translated.find(zeroKey((*u).sourceText()));
if (t != translated.end() && !t.key().isEmpty()
&& t->sourceText() != u->sourceText()) {
- TranslatorMessage m = *u;
- m.setTranslation(translationAttempt(t->translation(), t->sourceText(),
- u->sourceText()));
- tor.replace(m);
+ u->setTranslation(translationAttempt(t->translation(), t->sourceText(),
+ u->sourceText()));
inserted++;
}
}
@@ -305,9 +303,7 @@ int applySameTextHeuristic(Translator &tor)
QString key = u->sourceText();
t = translated.find(key);
if (t != translated.end()) {
- TranslatorMessage m = *u;
- m.setTranslations(t->translations());
- tor.replace(m);
+ u->setTranslations(t->translations());
++inserted;
}
}
@@ -345,15 +341,17 @@ Translator merge(const Translator &tor, const Translator &virginTor,
foreach (TranslatorMessage m, tor.messages()) {
TranslatorMessage::Type newType = TranslatorMessage::Finished;
- if (m.sourceText().isEmpty()) {
+ if (m.sourceText().isEmpty() && m.id().isEmpty()) {
// context/file comment
TranslatorMessage mv = virginTor.find(m.context());
if (!mv.isNull())
m.setComment(mv.comment());
} else {
- TranslatorMessage mv = virginTor.find(m.context(), m.sourceText(), m.comment());
- if (mv.isNull()) {
+ TranslatorMessage mv;
+ int mvi = virginTor.find(m);
+ if (mvi < 0) {
if (!(options & HeuristicSimilarText)) {
+ makeObsolete:
newType = TranslatorMessage::Obsolete;
if (m.type() != TranslatorMessage::Obsolete)
obsoleted++;
@@ -362,10 +360,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
mv = virginTor.find(m.context(), m.comment(), m.allReferences());
if (mv.isNull()) {
// did not find it in the virgin, mark it as obsolete
- newType = TranslatorMessage::Obsolete;
- if (m.type() != TranslatorMessage::Obsolete)
- obsoleted++;
- m.clearReferences();
+ goto makeObsolete;
} else {
// Do not just accept it if its on the same line number,
// but different source text.
@@ -380,6 +375,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
++similarTextHeuristicCount;
neww++;
+ outdateSource:
m.setOldSourceText(m.sourceText());
m.setSourceText(mv.sourceText());
const QString &oldpluralsource = m.extra(QLatin1String("po-msgid_plural"));
@@ -387,38 +383,45 @@ Translator merge(const Translator &tor, const Translator &virginTor,
m.setExtra(QLatin1String("po-old_msgid_plural"), oldpluralsource);
m.unsetExtra(QLatin1String("po-msgid_plural"));
}
- m.setReferences(mv.allReferences()); // Update secondary references
- m.setPlural(mv.isPlural());
- m.setUtf8(mv.isUtf8());
- m.setExtraComment(mv.extraComment());
+ goto copyAttribs; // Update secondary references
} else {
// The virgin and vernacular sourceTexts are so
// different that we could not find it.
- newType = TranslatorMessage::Obsolete;
- if (m.type() != TranslatorMessage::Obsolete)
- obsoleted++;
- m.clearReferences();
+ goto makeObsolete;
}
}
}
} else {
- switch (m.type()) {
- case TranslatorMessage::Finished:
- default:
- if (m.isPlural() == mv.isPlural()) {
- newType = TranslatorMessage::Finished;
- } else {
- newType = TranslatorMessage::Unfinished;
- }
+ mv = virginTor.message(mvi);
+ if (!mv.id().isEmpty()
+ && (mv.context() != m.context()
+ || mv.sourceText() != m.sourceText()
+ || mv.comment() != m.comment())) {
known++;
- break;
- case TranslatorMessage::Unfinished:
newType = TranslatorMessage::Unfinished;
- known++;
- break;
- case TranslatorMessage::Obsolete:
- newType = TranslatorMessage::Unfinished;
- neww++;
+ m.setContext(mv.context());
+ m.setComment(mv.comment());
+ if (mv.sourceText() != m.sourceText())
+ goto outdateSource;
+ } else {
+ switch (m.type()) {
+ case TranslatorMessage::Finished:
+ default:
+ if (m.isPlural() == mv.isPlural()) {
+ newType = TranslatorMessage::Finished;
+ } else {
+ newType = TranslatorMessage::Unfinished;
+ }
+ known++;
+ break;
+ case TranslatorMessage::Unfinished:
+ newType = TranslatorMessage::Unfinished;
+ known++;
+ break;
+ case TranslatorMessage::Obsolete:
+ newType = TranslatorMessage::Unfinished;
+ neww++;
+ }
}
// Always get the filename and linenumber info from the
@@ -426,10 +429,12 @@ Translator merge(const Translator &tor, const Translator &virginTor,
// This should also enable us to read a file that does not
// have the <location> element.
// why not use operator=()? Because it overwrites e.g. userData.
+ copyAttribs:
m.setReferences(mv.allReferences());
m.setPlural(mv.isPlural());
m.setUtf8(mv.isUtf8());
m.setExtraComment(mv.extraComment());
+ m.setId(mv.id());
}
}
@@ -442,11 +447,11 @@ Translator merge(const Translator &tor, const Translator &virginTor,
vernacular translator.
*/
foreach (const TranslatorMessage &mv, virginTor.messages()) {
- if (mv.sourceText().isEmpty()) {
+ if (mv.sourceText().isEmpty() && mv.id().isEmpty()) {
if (tor.contains(mv.context()))
continue;
} else {
- if (tor.contains(mv.context(), mv.sourceText(), mv.comment()))
+ if (tor.find(mv) >= 0)
continue;
if (options & HeuristicSimilarText) {
TranslatorMessage m = tor.find(mv.context(), mv.comment(), mv.allReferences());
@@ -460,7 +465,7 @@ Translator merge(const Translator &tor, const Translator &virginTor,
outTor.append(mv);
else
outTor.appendSorted(mv);
- if (!mv.sourceText().isEmpty())
+ if (!mv.sourceText().isEmpty() || !mv.id().isEmpty())
++neww;
}
diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp
index 4600656..6c94588 100644
--- a/tools/linguist/lupdate/qscript.cpp
+++ b/tools/linguist/lupdate/qscript.cpp
@@ -776,7 +776,7 @@ static void recordMessage(
fileName, lineNo, QStringList(),
TranslatorMessage::Unfinished, plural);
msg.setExtraComment(extracomment.simplified());
- tor->replace(msg);
+ tor->extend(msg);
}
diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp
index 5965aac..99aedef 100644
--- a/tools/linguist/shared/qm.cpp
+++ b/tools/linguist/shared/qm.cpp
@@ -685,6 +685,16 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
+static bool containsStripped(const Translator &translator, const TranslatorMessage &msg)
+{
+ foreach (const TranslatorMessage &tmsg, translator.messages())
+ if (tmsg.sourceText() == msg.sourceText()
+ && tmsg.context() == msg.context()
+ && tmsg.comment().isEmpty())
+ return true;
+ return false;
+}
+
static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData &cd)
{
Releaser releaser;
@@ -741,7 +751,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData
bool forceComment =
msg.comment().isEmpty()
|| msg.context().isEmpty()
- || translator.contains(msg.context(), msg.sourceText(), QString());
+ || containsStripped(translator, msg);
releaser.insert(msg, tlns, forceComment);
}
}
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index cd670cc..bc27daf 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -80,18 +80,9 @@ QList<Translator::FileFormat> &Translator::registeredFileFormats()
return theFormats;
}
-void Translator::replace(const TranslatorMessage &msg)
-{
- int index = m_messages.indexOf(msg);
- if (index == -1)
- m_messages.append(msg);
- else
- m_messages[index] = msg;
-}
-
void Translator::replaceSorted(const TranslatorMessage &msg)
{
- int index = m_messages.indexOf(msg);
+ int index = find(msg);
if (index == -1)
appendSorted(msg);
else
@@ -100,7 +91,7 @@ void Translator::replaceSorted(const TranslatorMessage &msg)
void Translator::extend(const TranslatorMessage &msg)
{
- int index = m_messages.indexOf(msg);
+ int index = find(msg);
if (index == -1) {
m_messages.append(msg);
} else {
@@ -145,7 +136,7 @@ void Translator::appendSorted(const TranslatorMessage &msg)
int prevLine = 0;
int curIdx = 0;
foreach (const TranslatorMessage &mit, m_messages) {
- bool sameFile = mit.fileName() == msg.fileName();
+ bool sameFile = mit.fileName() == msg.fileName() && mit.context() == msg.context();
int curLine;
if (sameFile && (curLine = mit.lineNumber()) >= prevLine) {
if (msgLine >= prevLine && msgLine < curLine) {
@@ -311,19 +302,21 @@ bool Translator::release(QFile *iod, ConversionData &cd) const
return false;
}
-bool Translator::contains(const QString &context,
- const QString &sourceText, const QString &comment) const
-{
- return m_messages.contains(TranslatorMessage(context, sourceText, comment,
- QString(), QString(), 0));
-}
-
-TranslatorMessage Translator::find(const QString &context,
- const QString &sourceText, const QString &comment) const
+int Translator::find(const TranslatorMessage &msg) const
{
- TranslatorMessage needle(context, sourceText, comment, QString(), QString(), 0);
- int index = m_messages.indexOf(needle);
- return index == -1 ? TranslatorMessage() : m_messages.at(index);
+ for (int i = 0; i < m_messages.count(); ++i) {
+ const TranslatorMessage &tmsg = m_messages.at(i);
+ if (msg.id().isEmpty() || tmsg.id().isEmpty()) {
+ if (msg.context() == tmsg.context()
+ && msg.sourceText() == tmsg.sourceText()
+ && msg.comment() == tmsg.comment())
+ return i;
+ } else {
+ if (msg.id() == tmsg.id())
+ return i;
+ }
+ }
+ return -1;
}
TranslatorMessage Translator::find(const QString &context,
@@ -344,7 +337,7 @@ TranslatorMessage Translator::find(const QString &context,
bool Translator::contains(const QString &context) const
{
foreach (const TranslatorMessage &msg, m_messages)
- if (msg.context() == context && msg.sourceText().isEmpty())
+ if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty())
return true;
return false;
}
@@ -352,7 +345,7 @@ bool Translator::contains(const QString &context) const
TranslatorMessage Translator::find(const QString &context) const
{
foreach (const TranslatorMessage &msg, m_messages)
- if (msg.context() == context && msg.sourceText().isEmpty())
+ if (msg.context() == context && msg.sourceText().isEmpty() && msg.id().isEmpty())
return msg;
return TranslatorMessage();
}
@@ -435,49 +428,143 @@ void Translator::dropUiLines()
}
}
-QSet<TranslatorMessagePtr> Translator::resolveDuplicates()
+struct TranslatorMessageIdPtr {
+ explicit TranslatorMessageIdPtr(const TranslatorMessage &tm)
+ {
+ ptr = &tm;
+ }
+
+ inline const TranslatorMessage *operator->() const
+ {
+ return ptr;
+ }
+
+ const TranslatorMessage *ptr;
+};
+
+Q_DECLARE_TYPEINFO(TranslatorMessageIdPtr, Q_MOVABLE_TYPE);
+
+inline int qHash(TranslatorMessageIdPtr tmp)
+{
+ return qHash(tmp->id());
+}
+
+inline bool operator==(TranslatorMessageIdPtr tmp1, TranslatorMessageIdPtr tmp2)
+{
+ return tmp1->id() == tmp2->id();
+}
+
+struct TranslatorMessageContentPtr {
+ explicit TranslatorMessageContentPtr(const TranslatorMessage &tm)
+ {
+ ptr = &tm;
+ }
+
+ inline const TranslatorMessage *operator->() const
+ {
+ return ptr;
+ }
+
+ const TranslatorMessage *ptr;
+};
+
+Q_DECLARE_TYPEINFO(TranslatorMessageContentPtr, Q_MOVABLE_TYPE);
+
+inline int qHash(TranslatorMessageContentPtr tmp)
+{
+ int hash = qHash(tmp->context()) ^ qHash(tmp->sourceText());
+ if (!tmp->sourceText().isEmpty())
+ // Special treatment for context comments (empty source).
+ hash ^= qHash(tmp->comment());
+ return hash;
+}
+
+inline bool operator==(TranslatorMessageContentPtr tmp1, TranslatorMessageContentPtr tmp2)
+{
+ if (tmp1->context() != tmp2->context() || tmp1->sourceText() != tmp2->sourceText())
+ return false;
+ // Special treatment for context comments (empty source).
+ if (tmp1->sourceText().isEmpty())
+ return true;
+ return tmp1->comment() == tmp2->comment();
+}
+
+Translator::Duplicates Translator::resolveDuplicates()
{
- QSet<TranslatorMessagePtr> dups;
- QHash<TranslatorMessagePtr, int> refs;
+ Duplicates dups;
+ QHash<TranslatorMessageIdPtr, int> idRefs;
+ QHash<TranslatorMessageContentPtr, int> contentRefs;
for (int i = 0; i < m_messages.count();) {
const TranslatorMessage &msg = m_messages.at(i);
- QHash<TranslatorMessagePtr, int>::ConstIterator it = refs.constFind(msg);
- if (it != refs.constEnd()) {
- TranslatorMessage &omsg = m_messages[*it];
- if (omsg.isUtf8() != msg.isUtf8() && !omsg.isNonUtf8()) {
- // Dual-encoded message
- omsg.setUtf8(true);
- omsg.setNonUtf8(true);
- } else {
- // Duplicate
- dups.insert(omsg);
+ TranslatorMessage *omsg;
+ int oi;
+ QSet<int> *pDup;
+ if (!msg.id().isEmpty()) {
+ QHash<TranslatorMessageIdPtr, int>::ConstIterator it =
+ idRefs.constFind(TranslatorMessageIdPtr(msg));
+ if (it != idRefs.constEnd()) {
+ oi = *it;
+ omsg = &m_messages[oi];
+ pDup = &dups.byId;
+ goto gotDupe;
}
- if (!omsg.isTranslated() && msg.isTranslated())
- omsg.setTranslations(msg.translations());
- m_messages.removeAt(i);
+ }
+ {
+ QHash<TranslatorMessageContentPtr, int>::ConstIterator it =
+ contentRefs.constFind(TranslatorMessageContentPtr(msg));
+ if (it != contentRefs.constEnd()) {
+ oi = *it;
+ omsg = &m_messages[oi];
+ if (msg.id().isEmpty() || omsg->id().isEmpty()) {
+ if (!msg.id().isEmpty() && omsg->id().isEmpty()) {
+ omsg->setId(msg.id());
+ idRefs[TranslatorMessageIdPtr(*omsg)] = oi;
+ }
+ pDup = &dups.byContents;
+ goto gotDupe;
+ }
+ // This is really a content dupe, but with two distinct IDs.
+ }
+ }
+ if (!msg.id().isEmpty())
+ idRefs[TranslatorMessageIdPtr(msg)] = i;
+ contentRefs[TranslatorMessageContentPtr(msg)] = i;
+ ++i;
+ continue;
+ gotDupe:
+ if (omsg->isUtf8() != msg.isUtf8() && !omsg->isNonUtf8()) {
+ // Dual-encoded message
+ omsg->setUtf8(true);
+ omsg->setNonUtf8(true);
} else {
- refs[msg] = i;
- ++i;
+ // Duplicate
+ pDup->insert(oi);
}
+ if (!omsg->isTranslated() && msg.isTranslated())
+ omsg->setTranslations(msg.translations());
+ m_messages.removeAt(i);
}
return dups;
}
-void Translator::reportDuplicates(const QSet<TranslatorMessagePtr> &dupes,
+void Translator::reportDuplicates(const Duplicates &dupes,
const QString &fileName, bool verbose)
{
- if (!dupes.isEmpty()) {
+ if (!dupes.byId.isEmpty() || !dupes.byContents.isEmpty()) {
if (!verbose) {
qWarning("Warning: dropping duplicate messages in '%s'\n(try -verbose for more info).",
qPrintable(fileName));
} else {
qWarning("Warning: dropping duplicate messages in '%s':", qPrintable(fileName));
- foreach (const TranslatorMessagePtr &msg, dupes) {
+ foreach (int i, dupes.byId)
+ qWarning("\n* ID: %s", qPrintable(message(i).id()));
+ foreach (int j, dupes.byContents) {
+ const TranslatorMessage &msg = message(j);
qWarning("\n* Context: %s\n* Source: %s",
- qPrintable(msg->context()),
- qPrintable(msg->sourceText()));
- if (!msg->comment().isEmpty())
- qWarning("* Comment: %s", qPrintable(msg->comment()));
+ qPrintable(msg.context()),
+ qPrintable(msg.sourceText()));
+ if (!msg.comment().isEmpty())
+ qWarning("* Comment: %s", qPrintable(msg.comment()));
}
qWarning();
}
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index ef81d2a..eec704a 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -113,18 +113,13 @@ public:
bool save(const QString &filename, ConversionData &err, const QString &format /*= "auto"*/) const;
bool release(QFile *iod, ConversionData &cd) const;
- bool contains(const QString &context, const QString &sourceText,
- const QString &comment) const;
- TranslatorMessage find(const QString &context,
- const QString &sourceText, const QString &comment) const;
-
+ int find(const TranslatorMessage &msg) const;
TranslatorMessage find(const QString &context,
const QString &comment, const TranslatorMessage::References &refs) const;
bool contains(const QString &context) const;
TranslatorMessage find(const QString &context) const;
- void replace(const TranslatorMessage &msg);
void replaceSorted(const TranslatorMessage &msg);
void extend(const TranslatorMessage &msg); // Only for single-location messages
void append(const TranslatorMessage &msg);
@@ -138,9 +133,10 @@ public:
void dropTranslations();
void dropUiLines();
void makeFileNamesAbsolute(const QDir &originalPath);
- QSet<TranslatorMessagePtr> resolveDuplicates();
- static void reportDuplicates(const QSet<TranslatorMessagePtr> &dupes,
- const QString &fileName, bool verbose);
+
+ struct Duplicates { QSet<int> byId, byContents; };
+ Duplicates resolveDuplicates();
+ void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose);
void setCodecName(const QByteArray &name);
QByteArray codecName() const { return m_codecName; }
diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp
index db6f333..5151ebd 100644
--- a/tools/linguist/shared/translatormessage.cpp
+++ b/tools/linguist/shared/translatormessage.cpp
@@ -143,40 +143,6 @@ bool TranslatorMessage::needs8Bit() const
}
-bool TranslatorMessage::operator==(const TranslatorMessage& m) const
-{
- static QString msgIdPlural = QLatin1String("po-msgid_plural");
-
- // Special treatment for context comments (empty source).
- return (m_context == m.m_context)
- && m_sourcetext == m.m_sourcetext
- && m_extra[msgIdPlural] == m.m_extra[msgIdPlural]
- && m_id == m.m_id
- && (m_sourcetext.isEmpty() || m_comment == m.m_comment);
-}
-
-
-bool TranslatorMessage::operator<(const TranslatorMessage& m) const
-{
- if (m_context != m.m_context)
- return m_context < m.m_context;
- if (m_sourcetext != m.m_sourcetext)
- return m_sourcetext < m.m_sourcetext;
- if (m_comment != m.m_comment)
- return m_comment < m.m_comment;
- return m_id < m.m_id;
-}
-
-int qHash(const TranslatorMessage &msg)
-{
- return
- qHash(msg.context()) ^
- qHash(msg.sourceText()) ^
- qHash(msg.extra(QLatin1String("po-msgid_plural"))) ^
- qHash(msg.comment()) ^
- qHash(msg.id());
-}
-
bool TranslatorMessage::hasExtra(const QString &key) const
{
return m_extra.contains(key);
diff --git a/tools/linguist/shared/translatormessage.h b/tools/linguist/shared/translatormessage.h
index 675bba7..60b60c5 100644
--- a/tools/linguist/shared/translatormessage.h
+++ b/tools/linguist/shared/translatormessage.h
@@ -109,9 +109,6 @@ public:
return false;
}
- bool operator==(const TranslatorMessage& m) const;
- bool operator<(const TranslatorMessage& m) const;
-
QString fileName() const { return m_fileName; }
void setFileName(const QString &fileName) { m_fileName = fileName; }
int lineNumber() const { return m_lineNumber; }
@@ -177,34 +174,6 @@ private:
Q_DECLARE_TYPEINFO(TranslatorMessage, Q_MOVABLE_TYPE);
-int qHash(const TranslatorMessage &msg);
-
-struct TranslatorMessagePtr {
- TranslatorMessagePtr(const TranslatorMessage &tm)
- {
- ptr = &tm;
- }
-
- inline const TranslatorMessage *operator->() const
- {
- return ptr;
- }
-
- const TranslatorMessage *ptr;
-};
-
-Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE);
-
-inline int qHash(TranslatorMessagePtr tmp)
-{
- return qHash(*tmp.ptr);
-}
-
-inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2)
-{
- return *tmp1.ptr == *tmp2.ptr;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_TRANSLATION