Changeset 769 for trunk/tools/linguist
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/tools/linguist/linguist.pro
r2 r769 5 5 lupdate \ 6 6 lconvert 7 CONFIG += ordered8 -
trunk/tools/linguist/linguist/linguist.pro
r561 r769 99 99 TR_DIR = $$PWD/../../../translations 100 100 TRANSLATIONS = \ 101 101 102 $$TR_DIR/linguist_de.ts \ 102 103 $$TR_DIR/linguist_fr.ts \ -
trunk/tools/linguist/linguist/linguist.qrc
r561 r769 1 1 <RCC> 2 <qresource prefix="/" 2 <qresource prefix="/"> 3 3 <file>images/appicon.png</file> 4 4 <file>images/mac/accelerator.png</file> … … 29 29 <file>images/s_check_warning.png</file> 30 30 <file>images/splash.png</file> 31 <file>images/transbox.png</file>32 31 <file>images/up.png</file> 33 32 <file>images/down.png</file> -
trunk/tools/linguist/linguist/mainwindow.cpp
r663 r769 94 94 #include <QUrl> 95 95 #include <QWhatsThis> 96 97 96 98 97 99 QT_BEGIN_NAMESPACE … … 2367 2369 static bool haveMnemonic(const QString &str) 2368 2370 { 2369 QString mnemonic = QKeySequence::mnemonic(str); 2370 if (mnemonic == QLatin1String("Alt+Space")) { 2371 // "Nobody" ever really uses these, and they are highly annoying 2372 // because we get a lot of false positives. 2373 return false; 2374 } 2375 return !mnemonic.isEmpty(); 2371 for (const ushort *p = (ushort *)str.constData();; ) { // Assume null-termination 2372 ushort c = *p++; 2373 if (!c) 2374 break; 2375 if (c == '&') { 2376 c = *p++; 2377 if (!c) 2378 return false; 2379 // "Nobody" ever really uses these alt-space, and they are highly annoying 2380 // because we get a lot of false positives. 2381 if (c != '&' && c != ' ' && QChar(c).isPrint()) { 2382 const ushort *pp = p; 2383 for (; *p < 256 && ::isalpha(*p); p++) ; 2384 if (pp == p || *p != ';') 2385 return true; 2386 // This looks like a HTML &entity;, so ignore it. As a HTML string 2387 // won't contain accels anyway, we can stop scanning here. 2388 break; 2389 } 2390 } 2391 } 2392 return false; 2376 2393 } 2377 2394 -
trunk/tools/linguist/linguist/messageeditor.cpp
r651 r769 99 99 setObjectName(QLatin1String("scroll area")); 100 100 101 // Use white explicitly as the background color for the editor page.102 101 QPalette p; 103 p.setColor(QPalette::Active, QPalette::Base, Qt::white); 104 p.setColor(QPalette::Inactive, QPalette::Base, Qt::white); 105 p.setColor(QPalette::Disabled, QPalette::Base, Qt::white); 106 p.setColor(QPalette::Active, QPalette::Window, Qt::white); 107 p.setColor(QPalette::Inactive, QPalette::Window, Qt::white); 108 p.setColor(QPalette::Disabled, QPalette::Window, Qt::white); 102 p.setBrush(QPalette::Window, p.brush(QPalette::Active, QPalette::Base)); 109 103 setPalette(p); 110 104 … … 136 130 { 137 131 QFrame *editorPage = new QFrame; 138 139 editorPage->setStyleSheet(QLatin1String(140 "QLabel { font-weight: bold; }"141 ));142 132 editorPage->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 143 133 -
trunk/tools/linguist/linguist/messageeditorwidgets.cpp
r651 r769 172 172 173 173 m_label = new QLabel(this); 174 175 176 174 177 m_label->setText(label); 175 178 layout->addWidget(m_label); … … 250 253 { 251 254 m_label = new QLabel(this); 255 256 257 252 258 m_label->setText(label); 253 259 -
trunk/tools/linguist/linguist/messagemodel.cpp
r651 r769 585 585 } 586 586 587 void MultiContextItem::appendMessageItem(MessageItem *m) 588 { 587 void MultiContextItem::appendMessageItems(const QList<MessageItem *> &m) 588 { 589 QList<MessageItem *> nullItems = m; // Basically, just a reservation 590 for (int i = 0; i < nullItems.count(); ++i) 591 nullItems[i] = 0; 589 592 for (int i = 0; i < m_messageLists.count() - 1; ++i) 590 m_messageLists[i].append(0); 591 m_messageLists.last().append(m); 592 m_multiMessageList.append(MultiMessageItem(m)); 593 m_messageLists[i] += nullItems; 594 m_messageLists.last() += m; 595 foreach (MessageItem *mi, m) 596 m_multiMessageList.append(MultiMessageItem(mi)); 593 597 } 594 598 … … 711 715 } 712 716 m_msgModel->endInsertColumns(); 717 713 718 for (int i = 0; i < dm->contextCount(); ++i) { 714 719 ContextItem *c = dm->contextItem(i); … … 717 722 MultiContextItem *mc = multiContextItem(mcx); 718 723 mc->assignLastModel(c, readWrite); 724 719 725 for (int j = 0; j < c->messageCount(); ++j) { 720 726 MessageItem *m = c->messageItem(j); 721 727 int msgIdx = mc->findMessage(m->text(), m->comment()); 722 if (msgIdx >= 0) {728 if (msgIdx >= 0) 723 729 mc->putMessageItem(msgIdx, m); 724 } else { 725 int msgCnt = mc->messageCount(); 726 m_msgModel->beginInsertRows(m_msgModel->createIndex(mcx, 0, 0), msgCnt, msgCnt); 727 mc->appendMessageItem(m); 728 m_msgModel->endInsertRows(); 729 ++m_numMessages; 730 } 730 else 731 appendItems << m; 732 } 733 if (!appendItems.isEmpty()) { 734 int msgCnt = mc->messageCount(); 735 m_msgModel->beginInsertRows(m_msgModel->createIndex(mcx, 0, 0), 736 msgCnt, msgCnt + appendItems.size() - 1); 737 mc->appendMessageItems(appendItems); 738 m_msgModel->endInsertRows(); 739 m_numMessages += appendItems.size(); 731 740 } 732 741 } else { 733 MultiContextItem item(modelCount() - 1, c, readWrite); 734 m_msgModel->beginInsertRows(QModelIndex(), contextCount(), contextCount()); 735 m_multiContextList.append(item); 736 m_msgModel->endInsertRows(); 737 m_numMessages += item.messageCount(); 738 } 742 m_multiContextList << MultiContextItem(modelCount() - 1, c, readWrite); 743 m_numMessages += c->messageCount(); 744 ++appendedContexts; 745 } 746 } 747 if (appendedContexts) { 748 // Do that en block to avoid itemview inefficiency. It doesn't hurt that we 749 // announce the availability of the data "long" after it was actually added. 750 m_msgModel->beginInsertRows(QModelIndex(), 751 contextCount() - appendedContexts, contextCount() - 1); 752 m_msgModel->endInsertRows(); 739 753 } 740 754 dm->setWritable(readWrite); -
trunk/tools/linguist/linguist/messagemodel.h
r651 r769 333 333 void moveModel(int oldPos, int newPos); // newPos is *before* removing at oldPos 334 334 void putMessageItem(int pos, MessageItem *m); 335 void appendMessageItem (MessageItem *m);335 void appendMessageItemm); 336 336 void removeMultiMessageItem(int pos); 337 337 void incrementFinishedCount() { ++m_finishedCount; } -
trunk/tools/linguist/lupdate/cpp.cpp
r651 r769 66 66 class HashString { 67 67 public: 68 HashString() : m_hash ed(false) {}69 explicit HashString(const QString &str) : m_str(str), m_hash ed(false) {}70 void setValue(const QString &str) { m_str = str; m_hash ed = false; }68 HashString() : m_hash) {} 69 explicit HashString(const QString &str) : m_str(str), m_hash) {} 70 void setValue(const QString &str) { m_str = str; m_hash; } 71 71 const QString &value() const { return m_str; } 72 72 bool operator==(const HashString &other) const { return m_str == other.m_str; } 73 73 private: 74 74 QString m_str; 75 76 75 77 mutable uint m_hash; 76 mutable bool m_hashed;77 78 friend uint qHash(const HashString &str); 78 79 }; … … 80 81 uint qHash(const HashString &str) 81 82 { 82 if (!str.m_hashed) { 83 str.m_hashed = true; 83 if (str.m_hash & 0x80000000) 84 84 str.m_hash = qHash(str.m_str); 85 }86 85 return str.m_hash; 87 86 } … … 89 88 class HashStringList { 90 89 public: 91 explicit HashStringList(const QList<HashString> &list) : m_list(list), m_hash ed(false) {}90 explicit HashStringList(const QList<HashString> &list) : m_list(list), m_hash) {} 92 91 const QList<HashString> &value() const { return m_list; } 93 92 bool operator==(const HashStringList &other) const { return m_list == other.m_list; } … … 95 94 QList<HashString> m_list; 96 95 mutable uint m_hash; 97 mutable bool m_hashed;98 96 friend uint qHash(const HashStringList &list); 99 97 }; … … 101 99 uint qHash(const HashStringList &list) 102 100 { 103 if (!list.m_hashed) { 104 list.m_hashed = true; 101 if (list.m_hash & 0x80000000) { 105 102 uint hash = 0; 106 103 foreach (const HashString &qs, list.m_list) { 107 hash ^= qHash(qs) ^ 0x a09df22f;108 hash = ( hash << 13) | (hash >> 19);104 hash ^= qHash(qs) ^ 0x; 105 hash = (); 109 106 } 110 107 list.m_hash = hash; … … 216 213 struct IfdefState { 217 214 IfdefState() {} 218 IfdefState(int _braceDepth, int _parenDepth) : 215 IfdefState(int _bracketDepth, int _braceDepth, int _parenDepth) : 216 bracketDepth(_bracketDepth), 219 217 braceDepth(_braceDepth), 220 218 parenDepth(_parenDepth), … … 223 221 224 222 SavedState state; 223 225 224 int braceDepth, braceDepth1st; 226 225 int parenDepth, parenDepth1st; … … 260 259 bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const; 261 260 bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const; 261 262 262 263 bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, 263 264 NamespaceList *resolved) const; … … 279 280 enum { 280 281 Tok_Eof, Tok_class, Tok_friend, Tok_namespace, Tok_using, Tok_return, 281 Tok_tr = 10, Tok_trUtf8, Tok_translate, Tok_translateUtf8, Tok_trid,282 Tok_Q_OBJECT = 20, Tok_Q_DECLARE_TR_FUNCTIONS,282 Tok_tr, Tok_trUtf8, Tok_translate, Tok_translateUtf8, Tok_trid, 283 Tok_Q_OBJECT, Tok_Q_DECLARE_TR_FUNCTIONS, 283 284 Tok_Ident, Tok_Comment, Tok_String, Tok_Arrow, Tok_Colon, Tok_ColonColon, 284 Tok_Equals, 285 Tok_LeftBrace = 30, Tok_RightBrace, Tok_LeftParen, Tok_RightParen, Tok_Comma, Tok_Semicolon,286 Tok_Null = 40, Tok_Integer,287 Tok_QuotedInclude = 50, Tok_AngledInclude,288 Tok_Other = 99285 Tok_Equals, 286 Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen, Tok_RightParen, Tok_Comma, Tok_Semicolon, 287 Tok_Null, Tok_Integer, 288 Tok_QuotedInclude, Tok_AngledInclude, 289 Tok_Other 289 290 }; 290 291 … … 298 299 qlonglong yyInteger; 299 300 QStack<IfdefState> yyIfdefStack; 301 300 302 int yyBraceDepth; 301 303 int yyParenDepth; 302 304 int yyLineNo; 303 305 int yyCurLineNo; 306 304 307 int yyBraceLineNo; 305 308 int yyParenLineNo; … … 338 341 directInclude = false; 339 342 } 343 340 344 yyBraceDepth = 0; 341 345 yyParenDepth = 0; 342 346 yyCurLineNo = 1; 347 343 348 yyBraceLineNo = 1; 344 349 yyParenLineNo = 1; … … 567 572 if (yyCh == 'f') { 568 573 // if, ifdef, ifndef 569 yyIfdefStack.push(IfdefState(yyBrac eDepth, yyParenDepth));574 yyIfdefStack.push(IfdefState(yyBraceDepth, yyParenDepth)); 570 575 yyCh = getChar(); 571 576 } else if (yyCh == 'n') { … … 606 611 IfdefState &is = yyIfdefStack.top(); 607 612 if (is.elseLine != -1) { 608 if (yyBraceDepth != is.braceDepth1st || yyParenDepth != is.parenDepth1st) 609 qWarning("%s:%d: Parenthesis/brace mismatch between " 613 if (yyBracketDepth != is.bracketDepth1st 614 || yyBraceDepth != is.braceDepth1st 615 || yyParenDepth != is.parenDepth1st) 616 qWarning("%s:%d: Parenthesis/bracket/brace mismatch between " 610 617 "#if and #else branches; using #if branch\n", 611 618 qPrintable(yyFileName), is.elseLine); 612 619 } else { 620 613 621 is.braceDepth1st = yyBraceDepth; 614 622 is.parenDepth1st = yyParenDepth; … … 616 624 } 617 625 is.elseLine = yyLineNo; 626 618 627 yyBraceDepth = is.braceDepth; 619 628 yyParenDepth = is.parenDepth; … … 625 634 IfdefState is = yyIfdefStack.pop(); 626 635 if (is.elseLine != -1) { 627 if (yyBraceDepth != is.braceDepth1st || yyParenDepth != is.parenDepth1st) 636 if (yyBracketDepth != is.bracketDepth1st 637 || yyBraceDepth != is.braceDepth1st 638 || yyParenDepth != is.parenDepth1st) 628 639 qWarning("%s:%d: Parenthesis/brace mismatch between " 629 640 "#if and #else branches; using #if branch\n", 630 641 qPrintable(yyFileName), is.elseLine); 642 631 643 yyBraceDepth = is.braceDepth1st; 632 644 yyParenDepth = is.parenDepth1st; … … 901 913 yyCh = getChar(); 902 914 return Tok_RightParen; 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 903 930 case ',': 904 931 yyCh = getChar(); … … 1037 1064 1038 1065 struct QualifyOneData { 1039 QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd) 1040 : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd) 1066 QualifyOneData(const NamespaceList &ns, int nsc, const HashString &seg, NamespaceList *rslvd, 1067 QSet<HashStringList> *visited) 1068 : namespaces(ns), nsCount(nsc), segment(seg), resolved(rslvd), visitedUsings(visited) 1041 1069 {} 1042 1070 … … 1045 1073 const HashString &segment; 1046 1074 NamespaceList *resolved; 1047 QSet<HashStringList> visitedUsings;1075 QSet<HashStringList> visitedUsings; 1048 1076 }; 1049 1077 … … 1079 1107 QualifyOneData *data = (QualifyOneData *)context; 1080 1108 foreach (const HashStringList &use, ns->usings) 1081 if (!data->visitedUsings.contains(use)) { 1082 data->visitedUsings.insert(use); 1083 if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved)) 1109 if (!data->visitedUsings->contains(use)) { 1110 data->visitedUsings->insert(use); 1111 if (qualifyOne(use.value(), use.value().count(), data->segment, data->resolved, 1112 data->visitedUsings)) 1084 1113 return true; 1085 1114 } … … 1088 1117 1089 1118 bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment, 1090 NamespaceList *resolved ) const1091 { 1092 QualifyOneData data(namespaces, nsCnt, segment, resolved );1119 NamespaceList *resolved) const 1120 { 1121 QualifyOneData data(namespaces, nsCnt, segment, resolved); 1093 1122 1094 1123 if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data)) … … 1096 1125 1097 1126 return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data); 1127 1128 1129 1130 1131 1132 1133 1134 1098 1135 } 1099 1136 … … 1526 1563 yyTok = getToken(); 1527 1564 while (yyTok != Tok_Eof) { 1565 1566 1567 1568 1569 1570 1528 1571 //qDebug() << "TOKEN: " << yyTok; 1529 1572 switch (yyTok) { … … 1993 2036 context = comment.left(k); 1994 2037 comment.remove(0, k + 1); 1995 recordMessage(yyLineNo, context, QString(), comment, extracomment, 1996 QString(), TranslatorMessage::ExtraData(), false, false); 2038 TranslatorMessage msg( 2039 transcode(context, false), QString(), 2040 transcode(comment, false), QString(), 2041 yyFileName, yyLineNo, QStringList(), 2042 TranslatorMessage::Finished, false); 2043 msg.setExtraComment(transcode(extracomment.simplified(), false)); 1997 2044 extracomment.clear(); 2045 1998 2046 tor->setExtras(extra); 1999 2047 extra.clear(); … … 2066 2114 if (!yyParenDepth) 2067 2115 prospectiveContext.clear(); 2116 2117 2118 2068 2119 case_default: 2069 2120 yyTok = getToken(); … … 2080 2131 " (or abuse of the C++ preprocessor)\n", 2081 2132 qPrintable(yyFileName), yyParenLineNo); 2133 2134 2135 2136 2082 2137 } 2083 2138 -
trunk/tools/linguist/lupdate/main.cpp
r651 r769 137 137 138 138 static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFileNames, 139 const QByteArray &codecForTr, const QString &sourceLanguage, const QString &targetLanguage,139 , const QString &sourceLanguage, const QString &targetLanguage, 140 140 UpdateOptions options, bool *fail) 141 141 { … … 155 155 tor.resolveDuplicates(); 156 156 cd.clearErrors(); 157 if ( !codecForTr.isEmpty() && codecForTr != tor.codecName())157 if (()) 158 158 qWarning("lupdate warning: Codec for tr() '%s' disagrees with " 159 159 "existing file's codec '%s'. Expect trouble.", 160 codecForTr.constData(), tor.codecName().constData());160 .constData(), tor.codecName().constData()); 161 161 if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode()) 162 162 qWarning("lupdate warning: Specified target language '%s' disagrees with " … … 168 168 qPrintable(sourceLanguage), qPrintable(tor.sourceLanguageCode())); 169 169 } else { 170 if ( !codecForTr.isEmpty())171 tor.setCodec Name(codecForTr);170 if () 171 tor.setCodec); 172 172 if (!targetLanguage.isEmpty()) 173 173 tor.setLanguageCode(targetLanguage); … … 191 191 theseOptions |= NoLocations; 192 192 Translator out = merge(tor, fetchedTor, theseOptions, err); 193 if ( !codecForTr.isEmpty())194 out.setCodec Name(codecForTr);193 if () 194 out.setCodec); 195 195 196 196 if ((options & Verbose) && !err.isEmpty()) { … … 375 375 } 376 376 Translator tor; 377 QByteArray codecForTr;377 ; 378 378 QStringList tmp = visitor.values(QLatin1String("CODEC")) 379 379 + visitor.values(QLatin1String("DEFAULTCODEC")) 380 380 + visitor.values(QLatin1String("CODECFORTR")); 381 381 if (!tmp.isEmpty()) { 382 codecForTr = tmp.last().toLatin1();383 tor.setCodecName(codecForTr);382 ); 383 ; 384 384 } 385 385 processProject(false, pfi, visitor, options, codecForSource, 386 386 targetLanguage, sourceLanguage, &tor, fail); 387 updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail);387 updateTsFiles(tor, tsFiles, , sourceLanguage, targetLanguage, options, fail); 388 388 continue; 389 389 } … … 658 658 fetchedTor.setCodecName(codecForTr); 659 659 processSources(fetchedTor, sourceFiles, cd); 660 updateTsFiles(fetchedTor, tsFileNames, codecForTr,660 updateTsFiles(fetchedTor, tsFileNames, , 661 661 sourceLanguage, targetLanguage, options, &fail); 662 662 } else { … … 670 670 processProjects(true, true, proFiles, options, QByteArray(), 671 671 targetLanguage, sourceLanguage, &fetchedTor, &fail); 672 updateTsFiles(fetchedTor, tsFileNames, codecForTr,672 updateTsFiles(fetchedTor, tsFileNames, , 673 673 sourceLanguage, targetLanguage, options, &fail); 674 674 } else { -
trunk/tools/linguist/phrasebooks/russian.qph
r561 r769 1176 1176 <target>ÐглавлеМОе</target> 1177 1177 </phrase> 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1178 1218 </QPH> -
trunk/tools/linguist/shared/qm.cpp
r651 r769 595 595 } 596 596 m += 4; 597 QString str = QString ::fromUtf16((const ushort*)m, len/2);597 QString str = QString *)m, len/2); 598 598 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { 599 599 for (int i = 0; i < str.length(); ++i) -
trunk/tools/linguist/shared/translator.h
r651 r769 154 154 155 155 void setCodecName(const QByteArray &name); 156 156 157 QByteArray codecName() const; 157 158 QTextCodec *codec() const { return m_codec; }
Note:
See TracChangeset
for help on using the changeset viewer.