qt.cfg: Add Q_DECLARE_TR_FUNCTIONS() and others (#1677)

Add unknownMacro Q_DECLARE_TR_FUNCTIONS found via daca@home.
Add function QCoreApplication::translate() and macro
QT_DECLARE_DEPRECATED_TR_FUNCTIONS() the unknownMacro depends on.
Reference:
https://doc.qt.io/qt-5/qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS
https://doc.qt.io/qt-5/qcoreapplication.html#translate
This commit is contained in:
Sebastian 2019-02-26 13:39:37 +01:00 committed by GitHub
parent bf85767829
commit 61f911d39a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 0 deletions

View File

@ -1247,6 +1247,27 @@
<strz/> <strz/>
</arg> </arg>
</function> </function>
<!-- QString QCoreApplication::translate(const char *context, const char *sourceText, const char *disambiguation = nullptr, int n = -1) //static -->
<function name="QCoreApplication::translate">
<noreturn>false</noreturn>
<returnValue type="QString"/>
<use-retval/>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
<strz/>
<not-bool/>
</arg>
<arg nr="3" default="NULL">
<not-bool/>
</arg>
<arg nr="4" default="-1">
</arg>
</function>
<container id="qtContainer" opLessAllowed="false"> <container id="qtContainer" opLessAllowed="false">
<type templateParameter="0"/> <type templateParameter="0"/>
<size> <size>
@ -1310,8 +1331,10 @@
<define name="Q_CLASSINFO(Name, Value)" value=""/> <define name="Q_CLASSINFO(Name, Value)" value=""/>
<define name="Q_DECL_EXPORT" value=""/> <define name="Q_DECL_EXPORT" value=""/>
<define name="Q_DECL_IMPORT" value=""/> <define name="Q_DECL_IMPORT" value=""/>
<define name="QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context)" value="static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) { return QCoreApplication::translate(#context, sourceText, disambiguation, n); }"/>
<define name="Q_DECLARE_FLAGS(x,y)" value=""/> <define name="Q_DECLARE_FLAGS(x,y)" value=""/>
<define name="Q_DECLARE_PRIVATE(Class)" value="inline Class##Private* d_func() { return reinterpret_cast&lt;Class##Private*&gt;(qGetPtrHelper(d_ptr)); } inline const Class##Private d_func() const { return reinterpret_cast&lt;const Class##Private *&gt;(qGetPtrHelper(d_ptr)); } friend class Class##Private;"/> <define name="Q_DECLARE_PRIVATE(Class)" value="inline Class##Private* d_func() { return reinterpret_cast&lt;Class##Private*&gt;(qGetPtrHelper(d_ptr)); } inline const Class##Private d_func() const { return reinterpret_cast&lt;const Class##Private *&gt;(qGetPtrHelper(d_ptr)); } friend class Class##Private;"/>
<define name="Q_DECLARE_TR_FUNCTIONS(context)" value="public: static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) private:"/>
<define name="Q_DISABLE_COPY(C)" value="C(C&amp;);C&amp; operator=(const C&amp;);"/> <define name="Q_DISABLE_COPY(C)" value="C(C&amp;);C&amp; operator=(const C&amp;);"/>
<define name="Q_ENUM(X)" value=""/> <define name="Q_ENUM(X)" value=""/>
<define name="Q_ENUMS(X)" value=""/> <define name="Q_ENUMS(X)" value=""/>

View File

@ -12,6 +12,7 @@
#include <QtPlugin> #include <QtPlugin>
#include <QFile> #include <QFile>
#include <cstdio> #include <cstdio>
#include <QCoreApplication>
void QString1(QString s) void QString1(QString s)
@ -39,6 +40,31 @@ public:
~MacroTest1(); ~MacroTest1();
}; };
class MacroTest2 {
Q_DECLARE_TR_FUNCTIONS(MacroTest2)
public:
MacroTest2();
~MacroTest2();
};
void MacroTest2_test()
{
// TODO: remove suppression when #9002 is fixed
// cppcheck-suppress checkLibraryFunction
QString str = MacroTest2::tr("hello");
QByteArray ba = str.toLatin1();
printf(ba.data());
#ifndef QT_NO_DEPRECATED
// TODO: remove suppression when #9002 is fixed
// cppcheck-suppress checkLibraryFunction
str = MacroTest2::trUtf8("test2");
ba = str.toLatin1();
printf(ba.data());
#endif
}
void validCode(int * pIntPtr) void validCode(int * pIntPtr)
{ {
if (QFile::exists("test")) { if (QFile::exists("test")) {