summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-04-01 08:45:34 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-04-01 08:45:34 (GMT)
commit603ee8b841385c04c5118650075134154aee29a7 (patch)
tree690a0b4abfa9a20551aab285cbb0fef49686c917 /tools
parentd5e6111c62bc4437243fb1d6389e3af180f623d7 (diff)
parent8ffd45cf6832b67960dbaa10654c4b84358fe3f9 (diff)
downloadQt-603ee8b841385c04c5118650075134154aee29a7.zip
Qt-603ee8b841385c04c5118650075134154aee29a7.tar.gz
Qt-603ee8b841385c04c5118650075134154aee29a7.tar.bz2
Merge remote branch 'origin/4.7' into 4.7
Conflicts: src/gui/text/qstatictext.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/linguist/messagemodel.cpp2
-rw-r--r--tools/linguist/lupdate/main.cpp3
-rw-r--r--tools/linguist/shared/numerus.cpp65
-rw-r--r--tools/linguist/shared/po.cpp472
-rw-r--r--tools/linguist/shared/qm.cpp4
-rw-r--r--tools/linguist/shared/translator.cpp2
-rw-r--r--tools/linguist/shared/translator.h2
-rw-r--r--tools/linguist/shared/xliff.cpp2
-rw-r--r--tools/qdoc3/codemarker.cpp2
-rw-r--r--tools/qdoc3/codemarker.h24
-rw-r--r--tools/qdoc3/cppcodemarker.cpp76
-rw-r--r--tools/qdoc3/htmlgenerator.cpp8
-rw-r--r--tools/qdoc3/node.cpp2
-rw-r--r--tools/qdoc3/qscodemarker.cpp18
14 files changed, 457 insertions, 225 deletions
diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp
index 4e2b473..39ba9fd 100644
--- a/tools/linguist/linguist/messagemodel.cpp
+++ b/tools/linguist/linguist/messagemodel.cpp
@@ -402,7 +402,7 @@ bool DataModel::setLanguageAndCountry(QLocale::Language lang, QLocale::Country c
if (lang == QLocale::C || uint(lang) > uint(QLocale::LastLanguage)) // XXX does this make any sense?
lang = QLocale::English;
QByteArray rules;
- bool ok = getNumerusInfo(lang, country, &rules, &m_numerusForms);
+ bool ok = getNumerusInfo(lang, country, &rules, &m_numerusForms, 0);
m_localizedLanguage = QCoreApplication::translate("MessageEditor", QLocale::languageToString(lang).toAscii());
m_countRefNeeds.clear();
for (int i = 0; i < rules.size(); ++i) {
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 0003baa..6c9157a 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -409,7 +409,7 @@ static void processProjects(
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
- m_defaultExtensions = QLatin1String("ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx");
+ m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,qs,qml");
QStringList args = app.arguments();
QStringList tsFileNames;
@@ -634,6 +634,7 @@ int main(int argc, char **argv)
sourceFiles << fn;
if (!fn.endsWith(QLatin1String(".java"))
+ && !fn.endsWith(QLatin1String(".jui"))
&& !fn.endsWith(QLatin1String(".ui"))
&& !fn.endsWith(QLatin1String(".js"))
&& !fn.endsWith(QLatin1String(".qs"))
diff --git a/tools/linguist/shared/numerus.cpp b/tools/linguist/shared/numerus.cpp
index d45dfed..6066732 100644
--- a/tools/linguist/shared/numerus.cpp
+++ b/tools/linguist/shared/numerus.cpp
@@ -64,7 +64,7 @@ static const uchar icelandicRules[] =
static const uchar irishStyleRules[] =
{ Q_EQ, 1, Q_NEWRULE,
Q_EQ, 2 };
-static const uchar slovakRules[] =
+static const uchar slovakStyleRules[] =
{ Q_EQ, 1, Q_NEWRULE,
Q_BETWEEN, 2, 4 };
static const uchar macedonianRules[] =
@@ -100,7 +100,7 @@ static const uchar arabicRules[] =
Q_EQ, 1, Q_NEWRULE,
Q_EQ, 2, Q_NEWRULE,
Q_MOD_100 | Q_BETWEEN, 3, 10, Q_NEWRULE,
- Q_MOD_100 | Q_NOT | Q_BETWEEN, 0, 2 };
+ Q_MOD_100 | Q_GEQ, 11 };
static const uchar tagalogRules[] =
{ Q_LEQ, 1, Q_NEWRULE,
Q_MOD_10 | Q_EQ, 4, Q_OR, Q_MOD_10 | Q_EQ, 6, Q_OR, Q_MOD_10 | Q_EQ, 9 };
@@ -114,7 +114,7 @@ static const char * const frenchStyleForms[] = { "Singular", "Plural", 0 };
static const char * const icelandicForms[] = { "Singular", "Plural", 0 };
static const char * const latvianForms[] = { "Singular", "Plural", "Nullar", 0 };
static const char * const irishStyleForms[] = { "Singular", "Dual", "Plural", 0 };
-static const char * const slovakForms[] = { "Singular", "Paucal", "Plural", 0 };
+static const char * const slovakStyleForms[] = { "Singular", "Paucal", "Plural", 0 };
static const char * const macedonianForms[] = { "Singular", "Dual", "Plural", 0 };
static const char * const lithuanianForms[] = { "Singular", "Paucal", "Plural", 0 };
static const char * const russianStyleForms[] = { "Singular", "Dual", "Plural", 0 };
@@ -279,7 +279,7 @@ static const QLocale::Language irishStyleLanguages[] = {
QLocale::Sanskrit,
EOL
};
-static const QLocale::Language slovakLanguages[] = { QLocale::Slovak, QLocale::Czech, EOL };
+static const QLocale::Language slovakStyleLanguages[] = { QLocale::Slovak, QLocale::Czech, EOL };
static const QLocale::Language macedonianLanguage[] = { QLocale::Macedonian, EOL };
static const QLocale::Language lithuanianLanguage[] = { QLocale::Lithuanian, EOL };
static const QLocale::Language russianStyleLanguages[] = {
@@ -318,28 +318,45 @@ struct NumerusTableEntry {
const char * const *forms;
const QLocale::Language *languages;
const QLocale::Country *countries;
+ const char * const gettextRules;
};
static const NumerusTableEntry numerusTable[] = {
- { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0 },
- { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0 },
+ { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0, "nplurals=1; plural=0;" },
+ { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0,
+ "nplurals=2; plural=(n != 1);" },
{ frenchStyleRules, sizeof(frenchStyleRules), frenchStyleForms, frenchStyleLanguages,
- frenchStyleCountries },
- { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0 },
- { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0 },
- { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0 },
- { slovakRules, sizeof(slovakRules), slovakForms, slovakLanguages, 0 },
- { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0 },
- { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0 },
- { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0 },
- { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0 },
- { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0 },
- { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0 },
- { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0 },
- { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0 },
- { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0 },
- { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0 },
- { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0 }
+ frenchStyleCountries, "nplurals=2; plural=(n > 1);" },
+ { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" },
+ { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0,
+ "nplurals=2; plural=(n%10==1 && n%100!=11 ? 0 : 1);" },
+ { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0,
+ "nplurals=3; plural=(n==1 ? 0 : n==2 ? 1 : 2);" },
+ { slovakStyleRules, sizeof(slovakStyleRules), slovakStyleForms, slovakStyleLanguages, 0,
+ "nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);" },
+ { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0,
+ "nplurals=3; plural=(n%100==1 ? 0 : n%100==2 ? 1 : 2);" },
+ { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);" },
+ { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0,
+ "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);" },
+ { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0,
+ "nplurals=4; plural=(n==1 ? 0 : (n==0 || (n%100>=1 && n%100<=10)) ? 1 : (n%100>=11 && n%100<=19) ? 2 : 3);" },
+ { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0,
+ "nplurals=5; plural=(n==0 ? 0 : n==1 ? 1 : (n>=2 && n<=5) ? 2 : n==6 ? 3 : 4);" },
+ { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0,
+ "nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : (n%100>=3 && n%100<=10) ? 3 : n%100>=11 ? 4 : 5);" },
+ { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n%10==4 || n%10==6 || n%10== 9) ? 1 : 2);" },
+ { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n==11 || n/1000==11 || n/1000000==11 || n/1000000000==11) ? 1 : 2);" },
};
static const int NumerusTableSize = sizeof(numerusTable) / sizeof(numerusTable[0]);
@@ -352,7 +369,7 @@ static const uchar magic[MagicLength] = {
};
bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
- QByteArray *rules, QStringList *forms)
+ QByteArray *rules, QStringList *forms, const char **gettextRules)
{
while (true) {
for (int i = 0; i < NumerusTableSize; ++i) {
@@ -365,6 +382,8 @@ bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
*rules = QByteArray::fromRawData(reinterpret_cast<const char *>(entry.rules),
entry.rulesSize);
}
+ if (gettextRules)
+ *gettextRules = entry.gettextRules;
if (forms) {
forms->clear();
for (int k = 0; entry.forms[k]; ++k)
diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp
index 3354d61..097b4bf 100644
--- a/tools/linguist/shared/po.cpp
+++ b/tools/linguist/shared/po.cpp
@@ -45,6 +45,7 @@
#include <QtCore/QIODevice>
#include <QtCore/QHash>
#include <QtCore/QString>
+#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
#include <ctype.h>
@@ -201,55 +202,54 @@ public:
public:
- QString id;
- QString context;
- QString tscomment;
- QString oldTscomment;
- QString lineNumber;
- QString fileName;
- QString references;
- QString translatorComments;
- QString automaticComments;
- QString msgId;
- QString oldMsgId;
- QStringList msgStr;
+ QByteArray id;
+ QByteArray context;
+ QByteArray tscomment;
+ QByteArray oldTscomment;
+ QByteArray lineNumber;
+ QByteArray fileName;
+ QByteArray references;
+ QByteArray translatorComments;
+ QByteArray automaticComments;
+ QByteArray msgId;
+ QByteArray oldMsgId;
+ QList<QByteArray> msgStr;
bool isPlural;
bool isFuzzy;
QHash<QString, QString> extra;
};
-static bool isTranslationLine(const QString &line)
+static bool isTranslationLine(const QByteArray &line)
{
- return line.startsWith(QLatin1String("#~ msgstr"))
- || line.startsWith(QLatin1String("msgstr"));
+ return line.startsWith("#~ msgstr") || line.startsWith("msgstr");
}
-static QString slurpEscapedString(const QStringList &lines, int & l,
- int offset, const QString &prefix, ConversionData &cd)
+static QByteArray slurpEscapedString(const QList<QByteArray> &lines, int &l,
+ int offset, const QByteArray &prefix, ConversionData &cd)
{
- QString msg;
+ QByteArray msg;
int stoff;
for (; l < lines.size(); ++l) {
- const QString &line = lines.at(l);
+ const QByteArray &line = lines.at(l);
if (line.isEmpty() || !line.startsWith(prefix))
break;
- while (line[offset].isSpace()) // No length check, as string has no trailing spaces.
+ while (::isspace(line[offset])) // No length check, as string has no trailing spaces.
offset++;
- if (line[offset].unicode() != '"')
+ if (line[offset] != '"')
break;
offset++;
forever {
if (offset == line.length())
goto premature_eol;
- ushort c = line[offset++].unicode();
+ uchar c = line[offset++];
if (c == '"') {
if (offset == line.length())
break;
- while (line[offset].isSpace())
+ while (::isspace(line[offset]))
offset++;
- if (line[offset++].unicode() != '"') {
+ if (line[offset++] != '"') {
cd.appendError(QString::fromLatin1(
"PO parsing error: extra characters on line %1.")
.arg(l + 1));
@@ -260,34 +260,34 @@ static QString slurpEscapedString(const QStringList &lines, int & l,
if (c == '\\') {
if (offset == line.length())
goto premature_eol;
- c = line[offset++].unicode();
+ c = line[offset++];
switch (c) {
case 'r':
- msg += QLatin1Char('\r'); // Maybe just throw it away?
+ msg += '\r'; // Maybe just throw it away?
break;
case 'n':
- msg += QLatin1Char('\n');
+ msg += '\n';
break;
case 't':
- msg += QLatin1Char('\t');
+ msg += '\t';
break;
case 'v':
- msg += QLatin1Char('\v');
+ msg += '\v';
break;
case 'a':
- msg += QLatin1Char('\a');
+ msg += '\a';
break;
case 'b':
- msg += QLatin1Char('\b');
+ msg += '\b';
break;
case 'f':
- msg += QLatin1Char('\f');
+ msg += '\f';
break;
case '"':
- msg += QLatin1Char('"');
+ msg += '"';
break;
case '\\':
- msg += QLatin1Char('\\');
+ msg += '\\';
break;
case '0':
case '1':
@@ -298,28 +298,28 @@ static QString slurpEscapedString(const QStringList &lines, int & l,
case '6':
case '7':
stoff = offset - 1;
- while ((c = line[offset].unicode()) >= '0' && c <= '7')
+ while ((c = line[offset]) >= '0' && c <= '7')
if (++offset == line.length())
goto premature_eol;
- msg += QChar(line.mid(stoff, offset - stoff).toUInt(0, 8));
+ msg += line.mid(stoff, offset - stoff).toUInt(0, 8);
break;
case 'x':
stoff = offset;
- while (isxdigit(line[offset].unicode()))
+ while (::isxdigit(line[offset]))
if (++offset == line.length())
goto premature_eol;
- msg += QChar(line.mid(stoff, offset - stoff).toUInt(0, 16));
+ msg += line.mid(stoff, offset - stoff).toUInt(0, 16);
break;
default:
cd.appendError(QString::fromLatin1(
"PO parsing error: invalid escape '\\%1' (line %2).")
- .arg(QChar(c)).arg(l + 1));
- msg += QLatin1Char('\\');
- msg += QChar(c);
+ .arg(QChar((uint)c)).arg(l + 1));
+ msg += '\\';
+ msg += c;
break;
}
} else {
- msg += QChar(c);
+ msg += c;
}
}
offset = prefix.size();
@@ -330,36 +330,61 @@ static QString slurpEscapedString(const QStringList &lines, int & l,
premature_eol:
cd.appendError(QString::fromLatin1(
"PO parsing error: premature end of line %1.").arg(l + 1));
- return QString();
+ return QByteArray();
}
-static void slurpComment(QString &msg, const QStringList &lines, int & l)
+static void slurpComment(QByteArray &msg, const QList<QByteArray> &lines, int & l)
{
- const QChar newline = QLatin1Char('\n');
- QString prefix = lines.at(l);
+ QByteArray prefix = lines.at(l);
for (int i = 1; ; i++) {
- if (prefix.at(i).unicode() != ' ') {
+ if (prefix.at(i) != ' ') {
prefix.truncate(i);
break;
}
}
for (; l < lines.size(); ++l) {
- const QString &line = lines.at(l);
+ const QByteArray &line = lines.at(l);
if (line.startsWith(prefix))
msg += line.mid(prefix.size());
- else if (line != QLatin1String("#"))
+ else if (line != "#")
break;
- msg += newline;
+ msg += '\n';
}
--l;
}
+static QString makePoHeader(const QString &str)
+{
+ return QLatin1String("po-header-") + str.toLower().replace(QLatin1Char('-'), QLatin1Char('_'));
+}
+
+static QByteArray QByteArrayList_join(const QList<QByteArray> &that, char sep)
+{
+ int totalLength = 0;
+ const int size = that.size();
+
+ for (int i = 0; i < size; ++i)
+ totalLength += that.at(i).size();
+
+ if (size > 0)
+ totalLength += size - 1;
+
+ QByteArray res;
+ if (totalLength == 0)
+ return res;
+ res.reserve(totalLength);
+ for (int i = 0; i < that.size(); ++i) {
+ if (i)
+ res += sep;
+ res += that.at(i);
+ }
+ return res;
+}
+
bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
{
- const QChar quote = QLatin1Char('"');
- const QChar newline = QLatin1Char('\n');
- QTextStream in(&dev);
- in.setCodec(cd.m_codecForSource.isEmpty() ? QByteArray("UTF-8") : cd.m_codecForSource);
+ QTextCodec *codec = QTextCodec::codecForName(
+ cd.m_codecForSource.isEmpty() ? QByteArray("UTF-8") : cd.m_codecForSource);
bool error = false;
// format of a .po file entry:
@@ -380,25 +405,23 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
// ...
// we need line based lookahead below.
- QStringList lines;
- while (!in.atEnd())
- lines.append(in.readLine().trimmed());
- lines.append(QString());
+ QList<QByteArray> lines;
+ while (!dev.atEnd())
+ lines.append(dev.readLine().trimmed());
+ lines.append(QByteArray());
- int l = 0;
+ int l = 0, lastCmtLine = -1;
PoItem item;
for (; l != lines.size(); ++l) {
- QString line = lines.at(l);
+ QByteArray line = lines.at(l);
if (line.isEmpty())
continue;
if (isTranslationLine(line)) {
- bool isObsolete = line.startsWith(QLatin1String("#~ msgstr"));
- const QString prefix = QLatin1String(isObsolete ? "#~ " : "");
+ bool isObsolete = line.startsWith("#~ msgstr");
+ const QByteArray prefix = isObsolete ? "#~ " : "";
while (true) {
- int idx = line.indexOf(QLatin1Char(' '), prefix.length());
- QString str = slurpEscapedString(lines, l, idx, prefix, cd);
- str.replace(QChar(Translator::TextVariantSeparator),
- QChar(Translator::BinaryVariantSeparator));
+ int idx = line.indexOf(' ', prefix.length());
+ QByteArray str = slurpEscapedString(lines, l, idx, prefix, cd);
item.msgStr.append(str);
if (l + 1 >= lines.size() || !isTranslationLine(lines.at(l + 1)))
break;
@@ -406,31 +429,109 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
line = lines.at(l);
}
if (item.msgId.isEmpty()) {
- QRegExp rx(QLatin1String("\\bX-Language: ([^\n]*)\n"));
- int idx = rx.indexIn(item.msgStr.first());
- if (idx >= 0) {
- translator.setLanguageCode(rx.cap(1));
- item.msgStr.first().remove(idx, rx.matchedLength());
+ QHash<QString, QByteArray> extras;
+ QList<QByteArray> hdrOrder;
+ QByteArray pluralForms;
+ foreach (const QByteArray &hdr, item.msgStr.first().split('\n')) {
+ if (hdr.isEmpty())
+ continue;
+ int idx = hdr.indexOf(':');
+ if (idx < 0) {
+ cd.appendError(QString::fromLatin1("Unexpected PO header format '%1'\n")
+ .arg(QString::fromLatin1(hdr)));
+ error = true;
+ break;
+ }
+ QByteArray hdrName = hdr.left(idx).trimmed();
+ QByteArray hdrValue = hdr.mid(idx + 1).trimmed();
+ hdrOrder << hdrName;
+ if (hdrName == "X-Language") {
+ translator.setLanguageCode(QString::fromLatin1(hdrValue));
+ } else if (hdrName == "X-Source-Language") {
+ translator.setSourceLanguageCode(QString::fromLatin1(hdrValue));
+ } else if (hdrName == "Plural-Forms") {
+ pluralForms = hdrValue;
+ } else if (hdrName == "MIME-Version") {
+ // just assume it is 1.0
+ } else if (hdrName == "Content-Type") {
+ if (cd.m_codecForSource.isEmpty()) {
+ if (!hdrValue.startsWith("text/plain; charset=")) {
+ cd.appendError(QString::fromLatin1("Unexpected Content-Type header '%1'\n")
+ .arg(QString::fromLatin1(hdrValue)));
+ error = true;
+ // This will avoid a flood of conversion errors.
+ codec = QTextCodec::codecForName("latin1");
+ } else {
+ QByteArray cod = hdrValue.mid(20);
+ QTextCodec *cdc = QTextCodec::codecForName(cod);
+ if (!cdc) {
+ cd.appendError(QString::fromLatin1("Unsupported codec '%1'\n")
+ .arg(QString::fromLatin1(cod)));
+ error = true;
+ // This will avoid a flood of conversion errors.
+ codec = QTextCodec::codecForName("latin1");
+ } else {
+ codec = cdc;
+ }
+ }
+ }
+ } else if (hdrName == "Content-Transfer-Encoding") {
+ if (hdrValue != "8bit") {
+ cd.appendError(QString::fromLatin1("Unexpected Content-Transfer-Encoding '%1'\n")
+ .arg(QString::fromLatin1(hdrValue)));
+ return false;
+ }
+ } else if (hdrName == "X-Virgin-Header") {
+ // legacy
+ } else {
+ extras[makePoHeader(QString::fromLatin1(hdrName))] = hdrValue;
+ }
}
- QRegExp rx2(QLatin1String("\\bX-Source-Language: ([^\n]*)\n"));
- int idx2 = rx2.indexIn(item.msgStr.first());
- if (idx2 >= 0) {
- translator.setSourceLanguageCode(rx2.cap(1));
- item.msgStr.first().remove(idx2, rx2.matchedLength());
+ if (!pluralForms.isEmpty()) {
+ if (translator.languageCode().isEmpty()) {
+ extras[makePoHeader(QLatin1String("Plural-Forms"))] = pluralForms;
+ } else {
+ // FIXME: have fun with making a consistency check ...
+ }
}
- if (item.msgStr.first().indexOf(
- QRegExp(QLatin1String("\\bX-Virgin-Header:[^\n]*\n"))) >= 0) {
- item = PoItem();
- continue;
+ // Eliminate the field if only headers we added are present in standard order.
+ // Keep in sync with savePO
+ static const char * const dfltHdrs[] = {
+ "MIME-Version", "Content-Type", "Content-Transfer-Encoding",
+ "Plural-Forms", "X-Language", "X-Source-Language"
+ };
+ uint cdh = 0;
+ for (int cho = 0; cho < hdrOrder.length(); cho++) {
+ for (;; cdh++) {
+ if (cdh == sizeof(dfltHdrs)/sizeof(dfltHdrs[0])) {
+ extras[QLatin1String("po-headers")] =
+ QByteArrayList_join(hdrOrder, ',');
+ goto doneho;
+ }
+ if (hdrOrder.at(cho) == dfltHdrs[cdh]) {
+ cdh++;
+ break;
+ }
+ }
}
+ doneho:
+ if (lastCmtLine != -1)
+ extras[QLatin1String("po-header_comment")] =
+ QByteArrayList_join(lines.mid(0, lastCmtLine + 1), '\n');
+ for (QHash<QString, QByteArray>::ConstIterator it = extras.constBegin(),
+ end = extras.constEnd();
+ it != end; ++it)
+ translator.setExtra(it.key(), codec->toUnicode(it.value()));
+ item = PoItem();
+ continue;
}
// build translator message
TranslatorMessage msg;
- msg.setContext(item.context);
+ msg.setContext(codec->toUnicode(item.context));
if (!item.references.isEmpty()) {
foreach (const QString &ref,
- item.references.split(QRegExp(QLatin1String("\\s")),
- QString::SkipEmptyParts)) {
+ codec->toUnicode(item.references).split(
+ QRegExp(QLatin1String("\\s")), QString::SkipEmptyParts)) {
int pos = ref.lastIndexOf(QLatin1Char(':'));
if (pos != -1)
msg.addReference(ref.left(pos), ref.mid(pos + 1).toInt());
@@ -438,18 +539,25 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
} else if (isObsolete) {
msg.setFileName(QLatin1String(MAGIC_OBSOLETE_REFERENCE));
}
- msg.setId(item.id);
- msg.setSourceText(item.msgId);
- msg.setOldSourceText(item.oldMsgId);
- msg.setComment(item.tscomment);
- msg.setOldComment(item.oldTscomment);
- msg.setExtraComment(item.automaticComments);
- msg.setTranslatorComment(item.translatorComments);
+ msg.setId(codec->toUnicode(item.id));
+ msg.setSourceText(codec->toUnicode(item.msgId));
+ msg.setOldSourceText(codec->toUnicode(item.oldMsgId));
+ msg.setComment(codec->toUnicode(item.tscomment));
+ msg.setOldComment(codec->toUnicode(item.oldTscomment));
+ msg.setExtraComment(codec->toUnicode(item.automaticComments));
+ msg.setTranslatorComment(codec->toUnicode(item.translatorComments));
msg.setPlural(item.isPlural || item.msgStr.size() > 1);
- msg.setTranslations(item.msgStr);
+ QStringList translations;
+ foreach (const QByteArray &bstr, item.msgStr) {
+ QString str = codec->toUnicode(bstr);
+ str.replace(QChar(Translator::TextVariantSeparator),
+ QChar(Translator::BinaryVariantSeparator));
+ translations << str;
+ }
+ msg.setTranslations(translations);
if (isObsolete)
msg.setType(TranslatorMessage::Obsolete);
- else if (item.isFuzzy)
+ else if (item.isFuzzy || (!msg.sourceText().isEmpty() && !msg.isTranslated()))
msg.setType(TranslatorMessage::Unfinished);
else
msg.setType(TranslatorMessage::Finished);
@@ -460,18 +568,19 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
//qDebug() << flags << msg.m_extra;
translator.append(msg);
item = PoItem();
- } else if (line.startsWith(QLatin1Char('#'))) {
- switch(line.size() < 2 ? 0 : line.at(1).unicode()) {
+ } else if (line.startsWith('#')) {
+ switch (line.size() < 2 ? 0 : line.at(1)) {
case ':':
item.references += line.mid(3);
- item.references += newline;
+ item.references += '\n';
break;
case ',': {
QStringList flags =
- line.mid(2).split(QRegExp(QLatin1String("[, ]")),
- QString::SkipEmptyParts);
+ QString::fromLatin1(line.mid(2)).split(
+ QRegExp(QLatin1String("[, ]")), QString::SkipEmptyParts);
if (flags.removeOne(QLatin1String("fuzzy")))
item.isFuzzy = true;
+ flags.removeOne(QLatin1String("qt-format"));
TranslatorMessage::ExtraData::const_iterator it =
item.extra.find(QLatin1String("po-flags"));
if (it != item.extra.end())
@@ -481,103 +590,130 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
break;
}
case 0:
- item.translatorComments += newline;
+ item.translatorComments += '\n';
break;
case ' ':
slurpComment(item.translatorComments, lines, l);
break;
case '.':
- if (line.startsWith(QLatin1String("#. ts-context "))) {
+ if (line.startsWith("#. ts-context ")) {
item.context = line.mid(14);
- } else if (line.startsWith(QLatin1String("#. ts-id "))) {
+ } else if (line.startsWith("#. ts-id ")) {
item.id = line.mid(9);
} else {
item.automaticComments += line.mid(3);
- item.automaticComments += newline;
+ item.automaticComments += '\n';
}
break;
case '|':
- if (line.startsWith(QLatin1String("#| msgid "))) {
- item.oldMsgId = slurpEscapedString(lines, l, 9, QLatin1String("#| "), cd);
- } else if (line.startsWith(QLatin1String("#| msgid_plural "))) {
- QString extra = slurpEscapedString(lines, l, 16, QLatin1String("#| "), cd);
+ if (line.startsWith("#| msgid ")) {
+ item.oldMsgId = slurpEscapedString(lines, l, 9, "#| ", cd);
+ } else if (line.startsWith("#| msgid_plural ")) {
+ QByteArray extra = slurpEscapedString(lines, l, 16, "#| ", cd);
if (extra != item.oldMsgId)
- item.extra[QLatin1String("po-old_msgid_plural")] = extra;
- } else if (line.startsWith(QLatin1String("#| msgctxt "))) {
- item.oldTscomment = slurpEscapedString(lines, l, 11, QLatin1String("#| "), cd);
+ item.extra[QLatin1String("po-old_msgid_plural")] =
+ codec->toUnicode(extra);
+ } else if (line.startsWith("#| msgctxt ")) {
+ item.oldTscomment = slurpEscapedString(lines, l, 11, "#| ", cd);
} else {
cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n"))
- .arg(l + 1).arg(lines[l]));
+ .arg(l + 1).arg(codec->toUnicode(lines[l])));
error = true;
}
break;
case '~':
- if (line.startsWith(QLatin1String("#~ msgid "))) {
- item.msgId = slurpEscapedString(lines, l, 9, QLatin1String("#~ "), cd);
- } else if (line.startsWith(QLatin1String("#~ msgid_plural "))) {
- QString extra = slurpEscapedString(lines, l, 16, QLatin1String("#~ "), cd);
+ if (line.startsWith("#~ msgid ")) {
+ item.msgId = slurpEscapedString(lines, l, 9, "#~ ", cd);
+ } else if (line.startsWith("#~ msgid_plural ")) {
+ QByteArray extra = slurpEscapedString(lines, l, 16, "#~ ", cd);
if (extra != item.msgId)
- item.extra[QLatin1String("po-msgid_plural")] = extra;
+ item.extra[QLatin1String("po-msgid_plural")] =
+ codec->toUnicode(extra);
item.isPlural = true;
- } else if (line.startsWith(QLatin1String("#~ msgctxt "))) {
- item.tscomment = slurpEscapedString(lines, l, 11, QLatin1String("#~ "), cd);
+ } else if (line.startsWith("#~ msgctxt ")) {
+ item.tscomment = slurpEscapedString(lines, l, 11, "#~ ", cd);
} else {
cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n"))
- .arg(l + 1).arg(lines[l]));
+ .arg(l + 1).arg(codec->toUnicode(lines[l])));
error = true;
}
break;
default:
cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'\n"))
- .arg(l + 1).arg(lines[l]));
+ .arg(l + 1).arg(codec->toUnicode(lines[l])));
error = true;
break;
}
- } else if (line.startsWith(QLatin1String("msgctxt "))) {
- item.tscomment = slurpEscapedString(lines, l, 8, QString(), cd);
- } else if (line.startsWith(QLatin1String("msgid "))) {
- item.msgId = slurpEscapedString(lines, l, 6, QString(), cd);
- } else if (line.startsWith(QLatin1String("msgid_plural "))) {
- QString extra = slurpEscapedString(lines, l, 13, QString(), cd);
+ lastCmtLine = l;
+ } else if (line.startsWith("msgctxt ")) {
+ item.tscomment = slurpEscapedString(lines, l, 8, QByteArray(), cd);
+ } else if (line.startsWith("msgid ")) {
+ item.msgId = slurpEscapedString(lines, l, 6, QByteArray(), cd);
+ } else if (line.startsWith("msgid_plural ")) {
+ QByteArray extra = slurpEscapedString(lines, l, 13, QByteArray(), cd);
if (extra != item.msgId)
- item.extra[QLatin1String("po-msgid_plural")] = extra;
+ item.extra[QLatin1String("po-msgid_plural")] = codec->toUnicode(extra);
item.isPlural = true;
} else {
cd.appendError(QString(QLatin1String("PO-format error in line %1: '%2'\n"))
- .arg(l + 1).arg(lines[l]));
+ .arg(l + 1).arg(codec->toUnicode(lines[l])));
error = true;
}
}
return !error && cd.errors().isEmpty();
}
+static void addPoHeader(Translator::ExtraData &headers, QStringList &hdrOrder,
+ const char *name, const QString &value)
+{
+ QString qName = QLatin1String(name);
+ if (!hdrOrder.contains(qName))
+ hdrOrder << qName;
+ headers[makePoHeader(qName)] = value;
+}
+
bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
{
+ QString str_format = QLatin1String("-format");
+
bool ok = true;
QTextStream out(&dev);
out.setCodec(cd.m_outputCodec.isEmpty() ? QByteArray("UTF-8") : cd.m_outputCodec);
- bool first = true;
- if (translator.messages().isEmpty() || !translator.messages().first().sourceText().isEmpty()) {
- out <<
- "# SOME DESCRIPTIVE TITLE.\n"
- "# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n"
- "# This file is distributed under the same license as the PACKAGE package.\n"
- "# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n"
- "#\n"
- "#, fuzzy\n"
- "msgid \"\"\n"
- "msgstr \"\"\n"
- "\"X-Virgin-Header: remove this line if you change anything in the header.\\n\"\n";
- if (!translator.languageCode().isEmpty())
- out << "\"X-Language: " << translator.languageCode() << "\\n\"\n";
- if (!translator.sourceLanguageCode().isEmpty())
- out << "\"X-Source-Language: " << translator.sourceLanguageCode() << "\\n\"\n";
- first = false;
+ QString cmt = translator.extra(QLatin1String("po-header_comment"));
+ if (!cmt.isEmpty())
+ out << cmt << '\n';
+ out << "msgid \"\"\n";
+ Translator::ExtraData headers = translator.extras();
+ QStringList hdrOrder = translator.extra(QLatin1String("po-headers")).split(
+ QLatin1Char(','), QString::SkipEmptyParts);
+ // Keep in sync with loadPO
+ addPoHeader(headers, hdrOrder, "MIME-Version", QLatin1String("1.0"));
+ addPoHeader(headers, hdrOrder, "Content-Type",
+ QLatin1String("text/plain; charset=" + out.codec()->name()));
+ addPoHeader(headers, hdrOrder, "Content-Transfer-Encoding", QLatin1String("8bit"));
+ if (!translator.languageCode().isEmpty()) {
+ QLocale::Language l;
+ QLocale::Country c;
+ Translator::languageAndCountry(translator.languageCode(), &l, &c);
+ const char *gettextRules;
+ if (getNumerusInfo(l, c, 0, 0, &gettextRules))
+ addPoHeader(headers, hdrOrder, "Plural-Forms", QLatin1String(gettextRules));
+ addPoHeader(headers, hdrOrder, "X-Language", translator.languageCode());
}
+ if (!translator.sourceLanguageCode().isEmpty())
+ addPoHeader(headers, hdrOrder, "X-Source-Language", translator.sourceLanguageCode());
+ QString hdrStr;
+ foreach (const QString &hdr, hdrOrder) {
+ hdrStr += hdr;
+ hdrStr += QLatin1String(": ");
+ hdrStr += headers.value(makePoHeader(hdr));
+ hdrStr += QLatin1Char('\n');
+ }
+ out << poEscapedString(QString(), QString::fromLatin1("msgstr"), true, hdrStr);
+
foreach (const TranslatorMessage &msg, translator.messages()) {
- if (!first)
- out << endl;
+ out << endl;
if (!msg.translatorComment().isEmpty())
out << poEscapedLines(QLatin1String("#"), true, msg.translatorComment());
@@ -599,16 +735,36 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
}
bool noWrap = false;
+ bool skipFormat = false;
QStringList flags;
- if (msg.type() == TranslatorMessage::Unfinished)
+ if (msg.type() == TranslatorMessage::Unfinished && msg.isTranslated())
flags.append(QLatin1String("fuzzy"));
TranslatorMessage::ExtraData::const_iterator itr =
msg.extras().find(QLatin1String("po-flags"));
if (itr != msg.extras().end()) {
- if (itr->split(QLatin1String(", ")).contains(QLatin1String("no-wrap")))
+ QStringList atoms = itr->split(QLatin1String(", "));
+ foreach (const QString &atom, atoms)
+ if (atom.endsWith(str_format)) {
+ skipFormat = true;
+ break;
+ }
+ if (atoms.contains(QLatin1String("no-wrap")))
noWrap = true;
flags.append(*itr);
}
+ if (!skipFormat) {
+ QString source = msg.sourceText();
+ // This is fuzzy logic, as we don't know whether the string is
+ // actually used with QString::arg().
+ for (int off = 0; (off = source.indexOf(QLatin1Char('%'), off)) >= 0; ) {
+ if (++off >= source.length())
+ break;
+ if (source.at(off) == QLatin1Char('n') || source.at(off).isDigit()) {
+ flags.append(QLatin1String("qt-format"));
+ break;
+ }
+ }
+ }
if (!flags.isEmpty())
out << "#, " << flags.join(QLatin1String(", ")) << '\n';
@@ -626,11 +782,8 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
out << poEscapedString(prefix, QLatin1String("msgid"), noWrap, msg.sourceText());
if (!msg.isPlural()) {
QString transl = msg.translation();
- if (first) {
- transl.remove(QRegExp(QLatin1String("\\bX-Language:[^\n]*\n")));
- if (!translator.languageCode().isEmpty())
- transl += QLatin1String("X-Language: ") + translator.languageCode() + QLatin1Char('\n');
- }
+ transl.replace(QChar(Translator::BinaryVariantSeparator),
+ QChar(Translator::TextVariantSeparator));
out << poEscapedString(prefix, QLatin1String("msgstr"), noWrap, transl);
} else {
QString plural = msg.extra(QLatin1String("po-msgid_plural"));
@@ -646,11 +799,17 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
str);
}
}
- first = false;
}
return ok;
}
+static bool savePOT(const Translator &translator, QIODevice &dev, ConversionData &cd)
+{
+ Translator ttor = translator;
+ ttor.dropTranslations();
+ return savePO(ttor, dev, cd);
+}
+
int initPO()
{
Translator::FileFormat format;
@@ -661,6 +820,13 @@ int initPO()
format.fileType = Translator::FileFormat::TranslationSource;
format.priority = 1;
Translator::registerFileFormat(format);
+ format.extension = QLatin1String("pot");
+ format.description = QObject::tr("GNU Gettext localization template files");
+ format.loader = &loadPO;
+ format.saver = &savePOT;
+ format.fileType = Translator::FileFormat::TranslationSource;
+ format.priority = -1;
+ Translator::registerFileFormat(format);
return 1;
}
diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp
index de1284f..e2c4f4a 100644
--- a/tools/linguist/shared/qm.cpp
+++ b/tools/linguist/shared/qm.cpp
@@ -564,7 +564,7 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd)
Translator::languageAndCountry(translator.languageCode(), &l, &c);
QStringList numerusForms;
bool guessPlurals = true;
- if (getNumerusInfo(l, c, 0, &numerusForms))
+ if (getNumerusInfo(l, c, 0, &numerusForms, 0))
guessPlurals = (numerusForms.count() == 1);
QString context, contextUtf8;
@@ -704,7 +704,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData
QLocale::Country c;
Translator::languageAndCountry(translator.languageCode(), &l, &c);
QByteArray rules;
- if (getNumerusInfo(l, c, &rules, 0))
+ if (getNumerusInfo(l, c, &rules, 0, 0))
releaser.setNumerusRules(rules);
releaser.setCodecName(translator.codecName());
diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp
index 4331ce6..465355d 100644
--- a/tools/linguist/shared/translator.cpp
+++ b/tools/linguist/shared/translator.cpp
@@ -652,7 +652,7 @@ void Translator::normalizeTranslations(ConversionData &cd)
int numPlurals = 1;
if (l != QLocale::C) {
QStringList forms;
- if (getNumerusInfo(l, c, 0, &forms))
+ if (getNumerusInfo(l, c, 0, &forms, 0))
numPlurals = forms.count(); // includes singular
}
for (int i = 0; i < m_messages.count(); ++i) {
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index 0b88c07..bb199f0 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -233,7 +233,7 @@ private:
};
bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
- QByteArray *rules, QStringList *forms);
+ QByteArray *rules, QStringList *forms, const char **gettextRules);
/*
This is a quick hack. The proper way to handle this would be
diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp
index 20303ec..6411426 100644
--- a/tools/linguist/shared/xliff.cpp
+++ b/tools/linguist/shared/xliff.cpp
@@ -503,6 +503,8 @@ bool XLIFFHandler::startElement(const QString& namespaceURI,
m_language.replace(QLatin1Char('-'), QLatin1Char('_'));
m_sourceLanguage = atts.value(QLatin1String("source-language"));
m_sourceLanguage.replace(QLatin1Char('-'), QLatin1Char('_'));
+ if (m_sourceLanguage == QLatin1String("en"))
+ m_sourceLanguage.clear();
} else if (localName == QLatin1String("group")) {
if (atts.value(QLatin1String("restype")) == QLatin1String(restypeContext)) {
m_context = atts.value(QLatin1String("resname"));
diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp
index 15f2c2d..818a91f 100644
--- a/tools/qdoc3/codemarker.cpp
+++ b/tools/qdoc3/codemarker.cpp
@@ -457,7 +457,7 @@ bool CodeMarker::insertReimpFunc(FastSection& fs, Node* node, Status status)
void CodeMarker::append(QList<Section>& sectionList, const FastSection& fs)
{
if (!fs.isEmpty()) {
- Section section(fs.name,fs.singularMember,fs.pluralMember);
+ Section section(fs.name,fs.divClass,fs.singularMember,fs.pluralMember);
section.members = fs.memberMap.values();
section.reimpMembers = fs.reimpMemberMap.values();
section.inherited = fs.inherited;
diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h
index 1b21753..aab8a9c 100644
--- a/tools/qdoc3/codemarker.h
+++ b/tools/qdoc3/codemarker.h
@@ -58,6 +58,7 @@ class Tree;
struct Section
{
QString name;
+ QString divClass;
QString singularMember;
QString pluralMember;
NodeList members;
@@ -66,9 +67,11 @@ struct Section
Section() { }
Section(const QString& name0,
+ const QString& divClass0,
const QString& singularMember0,
const QString& pluralMember0)
- : name(name0),
+ : name(name0),
+ divClass(divClass0),
singularMember(singularMember0),
pluralMember(pluralMember0) { }
void appendMember(Node* node) { members.append(node); }
@@ -79,6 +82,7 @@ struct FastSection
{
const InnerNode *innerNode;
QString name;
+ QString divClass;
QString singularMember;
QString pluralMember;
QMap<QString, Node *> memberMap;
@@ -86,20 +90,30 @@ struct FastSection
QList<QPair<ClassNode *, int> > inherited;
FastSection(const InnerNode *innerNode0,
- const QString& name0 = "",
- const QString& singularMember0 = "member",
- const QString& pluralMember0 = "members")
+ const QString& name0,
+ const QString& divClass0,
+ const QString& singularMember0,
+ const QString& pluralMember0)
: innerNode(innerNode0),
name(name0),
+ divClass(divClass0),
singularMember(singularMember0),
pluralMember(pluralMember0) { }
bool isEmpty() const {
- return (memberMap.isEmpty() && inherited.isEmpty() &&
+ return (memberMap.isEmpty() &&
+ inherited.isEmpty() &&
reimpMemberMap.isEmpty());
}
};
+#if 0
+ const QString& name0 = "",
+ const QString& divClass0 = "",
+ const QString& singularMember0 = "member",
+ const QString& pluralMember0 = "members")
+#endif
+
class CodeMarker
{
public:
diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp
index 3ff6ebe..c4ee054 100644
--- a/tools/qdoc3/cppcodemarker.cpp
+++ b/tools/qdoc3/cppcodemarker.cpp
@@ -482,55 +482,66 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
if (style == Summary) {
FastSection privateFunctions(classe,
"Private Functions",
+ "",
"private function",
"private functions");
- FastSection privateSlots(classe, "Private Slots", "private slot", "private slots");
- FastSection privateTypes(classe, "Private Types", "private type", "private types");
+ FastSection privateSlots(classe, "Private Slots", "", "private slot", "private slots");
+ FastSection privateTypes(classe, "Private Types", "", "private type", "private types");
FastSection protectedFunctions(classe,
"Protected Functions",
+ "",
"protected function",
"protected functions");
FastSection protectedSlots(classe,
"Protected Slots",
+ "",
"protected slot",
"protected slots");
FastSection protectedTypes(classe,
"Protected Types",
+ "",
"protected type",
"protected types");
FastSection protectedVariables(classe,
"Protected Variables",
+ "",
"protected type",
"protected variables");
FastSection publicFunctions(classe,
"Public Functions",
+ "",
"public function",
"public functions");
- FastSection publicSignals(classe, "Signals", "signal", "signals");
- FastSection publicSlots(classe, "Public Slots", "public slot", "public slots");
- FastSection publicTypes(classe, "Public Types", "public type", "public types");
+ FastSection publicSignals(classe, "Signals", "", "signal", "signals");
+ FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots");
+ FastSection publicTypes(classe, "Public Types", "", "public type", "public types");
FastSection publicVariables(classe,
"Public Variables",
- "public type",
+ "",
+ "public variable",
"public variables");
- FastSection properties(classe, "Properties", "property", "properties");
+ FastSection properties(classe, "Properties", "", "property", "properties");
FastSection relatedNonMembers(classe,
"Related Non-Members",
+ "",
"related non-member",
"related non-members");
FastSection staticPrivateMembers(classe,
"Static Private Members",
+ "",
"static private member",
"static private members");
FastSection staticProtectedMembers(classe,
"Static Protected Members",
+ "",
"static protected member",
"static protected members");
FastSection staticPublicMembers(classe,
"Static Public Members",
+ "",
"static public member",
"static public members");
- FastSection macros(inner, "Macros", "macro", "macros");
+ FastSection macros(inner, "Macros", "", "macro", "macros");
NodeList::ConstIterator r = classe->relatedNodes().begin();
while (r != classe->relatedNodes().end()) {
@@ -666,12 +677,12 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
append(sections, macros);
}
else if (style == Detailed) {
- FastSection memberFunctions(classe,"Member Function Documentation");
- FastSection memberTypes(classe,"Member Type Documentation");
- FastSection memberVariables(classe,"Member Variable Documentation");
- FastSection properties(classe,"Property Documentation");
- FastSection relatedNonMembers(classe,"Related Non-Members");
- FastSection macros(classe,"Macro Documentation");
+ FastSection memberFunctions(classe,"Member Function Documentation","func","member","members");
+ FastSection memberTypes(classe,"Member Type Documentation","types","member","members");
+ FastSection memberVariables(classe,"Member Variable Documentation","vars","member","members");
+ FastSection properties(classe,"Property Documentation","prop","member","members");
+ FastSection relatedNonMembers(classe,"Related Non-Members","relnonmem","member","members");
+ FastSection macros(classe,"Macro Documentation","macros","member","members");
NodeList::ConstIterator r = classe->relatedNodes().begin();
while (r != classe->relatedNodes().end()) {
@@ -717,7 +728,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
append(sections, macros);
}
else {
- FastSection all(classe);
+ FastSection all(classe,"","","member","members");
QStack<const ClassNode *> stack;
stack.push(classe);
@@ -747,25 +758,29 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
if (style == Summary || style == Detailed) {
FastSection namespaces(inner,
"Namespaces",
+ style == Detailed ? "nmspace" : "",
"namespace",
"namespaces");
FastSection classes(inner,
"Classes",
+ style == Detailed ? "classes" : "",
"class",
"classes");
FastSection types(inner,
- style == Summary ?
- "Types" : "Type Documentation",
+ style == Summary ? "Types" : "Type Documentation",
+ style == Detailed ? "types" : "",
"type",
"types");
FastSection functions(inner,
style == Summary ?
"Functions" : "Function Documentation",
+ style == Detailed ? "func" : "",
"function",
"functions");
FastSection macros(inner,
style == Summary ?
"Macros" : "Macro Documentation",
+ style == Detailed ? "macros" : "",
"macro",
"macros");
@@ -1116,26 +1131,32 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode,
if (style == Summary) {
FastSection qmlproperties(qmlClassNode,
"Properties",
+ "",
"property",
"properties");
FastSection qmlattachedproperties(qmlClassNode,
"Attached Properties",
+ "",
"property",
"properties");
FastSection qmlsignals(qmlClassNode,
- "Signals",
- "signal",
- "signals");
+ "Signals",
+ "",
+ "signal",
+ "signals");
FastSection qmlattachedsignals(qmlClassNode,
"Attached Signals",
+ "",
"signal",
"signals");
FastSection qmlmethods(qmlClassNode,
"Methods",
+ "",
"method",
"methods");
FastSection qmlattachedmethods(qmlClassNode,
"Attached Methods",
+ "",
"method",
"methods");
@@ -1179,12 +1200,15 @@ QList<Section> CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode,
append(sections,qmlattachedmethods);
}
else if (style == Detailed) {
- FastSection qmlproperties(qmlClassNode, "Property Documentation");
- FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation");
- FastSection qmlsignals(qmlClassNode,"Signal Documentation");
- FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation");
- FastSection qmlmethods(qmlClassNode,"Method Documentation");
- FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation");
+ FastSection qmlproperties(qmlClassNode, "Property Documentation","qmlprop","member","members");
+ FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation","qmlattprop",
+ "member","members");
+ FastSection qmlsignals(qmlClassNode,"Signal Documentation","qmlsig","member","members");
+ FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation","qmlattsig",
+ "member","members");
+ FastSection qmlmethods(qmlClassNode,"Method Documentation","qmlmeth","member","members");
+ FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation","qmlattmeth",
+ "member","members");
NodeList::ConstIterator c = qmlClassNode->childNodes().begin();
while (c != qmlClassNode->childNodes().end()) {
if ((*c)->subType() == Node::QmlPropertyGroup) {
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index cd3da3e..fb9fa95 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -696,7 +696,7 @@ int HtmlGenerator::generateAtom(const Atom *atom,
QList<Section> sections;
QList<Section>::ConstIterator s;
for (int i=0; i<LastSinceType; ++i)
- sections.append(Section(sinceTitle(i),QString(),QString()));
+ sections.append(Section(sinceTitle(i),QString(),QString(),QString()));
NodeMultiMap::const_iterator n = nsmap.value().constBegin();
while (n != nsmap.value().constEnd()) {
@@ -1356,8 +1356,10 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner,
if (!inner->doc().isEmpty()) {
out() << "<hr />\n"
+ << "<div class=\"descr\"/>\n"
<< "<h2>" << "Detailed Description" << "</h2>\n";
generateBody(inner, marker);
+ out() << "</div>\n";
generateAlsoList(inner, marker);
}
@@ -1365,6 +1367,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner,
s = sections.begin();
while (s != sections.end()) {
out() << "<hr />\n";
+ if (!(*s).divClass.isEmpty())
+ out() << "<div class=\"" << (*s).divClass << "\"/>\n";
out() << "<h2>" << protectEnc((*s).name) << "</h2>\n";
NodeList::ConstIterator m = (*s).members.begin();
@@ -1414,6 +1418,8 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner,
}
++m;
}
+ if (!(*s).divClass.isEmpty())
+ out() << "</div>\n";
++s;
}
generateFooter(inner);
diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp
index 37d6b31..a2bd948 100644
--- a/tools/qdoc3/node.cpp
+++ b/tools/qdoc3/node.cpp
@@ -1334,7 +1334,7 @@ QString QmlClassNode::fileBase() const
void QmlClassNode::addInheritedBy(const QString& base, Node* sub)
{
inheritedBy.insert(base,sub);
-#ifdef DEBUG_MULTIPLE-QDOCCONF_FILES
+#ifdef DEBUG_MULTIPLE_QDOCCONF_FILES
qDebug() << "QmlClassNode::addInheritedBy(): insert" << base << sub->name() << inheritedBy.size();
#endif
}
diff --git a/tools/qdoc3/qscodemarker.cpp b/tools/qdoc3/qscodemarker.cpp
index 89c9c5c..d4b8e80 100644
--- a/tools/qdoc3/qscodemarker.cpp
+++ b/tools/qdoc3/qscodemarker.cpp
@@ -279,11 +279,11 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty
const ClassNode *classe = static_cast<const ClassNode *>(inner);
if ( style == Summary ) {
- FastSection enums(classe, "Enums", "enum", "enums");
- FastSection functions(classe, "Functions", "function", "functions");
- FastSection readOnlyProperties(classe, "Read-Only Properties", "property", "properties");
- FastSection signalz(classe, "Signals", "signal", "signals");
- FastSection writableProperties(classe, "Writable Properties", "property", "properties");
+ FastSection enums(classe, "Enums", "", "enum", "enums");
+ FastSection functions(classe, "Functions", "", "function", "functions");
+ FastSection readOnlyProperties(classe, "", "Read-Only Properties", "property", "properties");
+ FastSection signalz(classe, "Signals", "", "signal", "signals");
+ FastSection writableProperties(classe, "", "Writable Properties", "property", "properties");
QStack<const ClassNode *> stack;
stack.push( classe );
@@ -328,9 +328,9 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty
append( sections, functions );
append( sections, signalz );
} else if ( style == Detailed ) {
- FastSection enums( classe, "Enum Documentation" );
- FastSection functionsAndSignals( classe, "Function and Signal Documentation" );
- FastSection properties( classe, "Property Documentation" );
+ FastSection enums( classe, "Enum Documentation", "", "member", "members");
+ FastSection functionsAndSignals( classe, "Function and Signal Documentation", "", "member", "members");
+ FastSection properties( classe, "Property Documentation", "", "member", "members");
NodeList::ConstIterator c = classe->childNodes().begin();
while ( c != classe->childNodes().end() ) {
@@ -349,7 +349,7 @@ QList<Section> QsCodeMarker::sections( const InnerNode *inner, SynopsisStyle sty
append( sections, properties );
append( sections, functionsAndSignals );
} else { // ( style == SeparateList )
- FastSection all( classe );
+ FastSection all(classe, "", "", "member", "members");
QStack<const ClassNode *> stack;
stack.push( classe );