Changeset 769 for trunk/tools/linguist


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/linguist/linguist.pro

    r2 r769  
    55    lupdate \
    66    lconvert
    7 CONFIG  += ordered
    8 
  • trunk/tools/linguist/linguist/linguist.pro

    r561 r769  
    9999TR_DIR = $$PWD/../../../translations
    100100TRANSLATIONS = \
     101
    101102    $$TR_DIR/linguist_de.ts \
    102103    $$TR_DIR/linguist_fr.ts \
  • trunk/tools/linguist/linguist/linguist.qrc

    r561 r769  
    11<RCC>
    2     <qresource prefix="/" >
     2    <qresource prefix="/">
    33        <file>images/appicon.png</file>
    44        <file>images/mac/accelerator.png</file>
     
    2929        <file>images/s_check_warning.png</file>
    3030        <file>images/splash.png</file>
    31         <file>images/transbox.png</file>
    3231        <file>images/up.png</file>
    3332        <file>images/down.png</file>
  • trunk/tools/linguist/linguist/mainwindow.cpp

    r663 r769  
    9494#include <QUrl>
    9595#include <QWhatsThis>
     96
     97
    9698
    9799QT_BEGIN_NAMESPACE
     
    23672369static bool haveMnemonic(const QString &str)
    23682370{
    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;
    23762393}
    23772394
  • trunk/tools/linguist/linguist/messageeditor.cpp

    r651 r769  
    9999    setObjectName(QLatin1String("scroll area"));
    100100
    101     // Use white explicitly as the background color for the editor page.
    102101    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));
    109103    setPalette(p);
    110104
     
    136130{
    137131    QFrame *editorPage = new QFrame;
    138 
    139     editorPage->setStyleSheet(QLatin1String(
    140             "QLabel { font-weight: bold; }"
    141             ));
    142132    editorPage->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    143133
  • trunk/tools/linguist/linguist/messageeditorwidgets.cpp

    r651 r769  
    172172
    173173    m_label = new QLabel(this);
     174
     175
     176
    174177    m_label->setText(label);
    175178    layout->addWidget(m_label);
     
    250253{
    251254    m_label = new QLabel(this);
     255
     256
     257
    252258    m_label->setText(label);
    253259
  • trunk/tools/linguist/linguist/messagemodel.cpp

    r651 r769  
    585585}
    586586
    587 void MultiContextItem::appendMessageItem(MessageItem *m)
    588 {
     587void 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;
    589592    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));
    593597}
    594598
     
    711715    }
    712716    m_msgModel->endInsertColumns();
     717
    713718    for (int i = 0; i < dm->contextCount(); ++i) {
    714719        ContextItem *c = dm->contextItem(i);
     
    717722            MultiContextItem *mc = multiContextItem(mcx);
    718723            mc->assignLastModel(c, readWrite);
     724
    719725            for (int j = 0; j < c->messageCount(); ++j) {
    720726                MessageItem *m = c->messageItem(j);
    721727                int msgIdx = mc->findMessage(m->text(), m->comment());
    722                 if (msgIdx >= 0) {
     728                if (msgIdx >= 0)
    723729                    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();
    731740            }
    732741        } 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();
    739753    }
    740754    dm->setWritable(readWrite);
  • trunk/tools/linguist/linguist/messagemodel.h

    r651 r769  
    333333    void moveModel(int oldPos, int newPos); // newPos is *before* removing at oldPos
    334334    void putMessageItem(int pos, MessageItem *m);
    335     void appendMessageItem(MessageItem *m);
     335    void appendMessageItemm);
    336336    void removeMultiMessageItem(int pos);
    337337    void incrementFinishedCount() { ++m_finishedCount; }
  • trunk/tools/linguist/lupdate/cpp.cpp

    r651 r769  
    6666class HashString {
    6767public:
    68     HashString() : m_hashed(false) {}
    69     explicit HashString(const QString &str) : m_str(str), m_hashed(false) {}
    70     void setValue(const QString &str) { m_str = str; m_hashed = 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; }
    7171    const QString &value() const { return m_str; }
    7272    bool operator==(const HashString &other) const { return m_str == other.m_str; }
    7373private:
    7474    QString m_str;
     75
     76
    7577    mutable uint m_hash;
    76     mutable bool m_hashed;
    7778    friend uint qHash(const HashString &str);
    7879};
     
    8081uint qHash(const HashString &str)
    8182{
    82     if (!str.m_hashed) {
    83         str.m_hashed = true;
     83    if (str.m_hash & 0x80000000)
    8484        str.m_hash = qHash(str.m_str);
    85     }
    8685    return str.m_hash;
    8786}
     
    8988class HashStringList {
    9089public:
    91     explicit HashStringList(const QList<HashString> &list) : m_list(list), m_hashed(false) {}
     90    explicit HashStringList(const QList<HashString> &list) : m_list(list), m_hash) {}
    9291    const QList<HashString> &value() const { return m_list; }
    9392    bool operator==(const HashStringList &other) const { return m_list == other.m_list; }
     
    9594    QList<HashString> m_list;
    9695    mutable uint m_hash;
    97     mutable bool m_hashed;
    9896    friend uint qHash(const HashStringList &list);
    9997};
     
    10199uint qHash(const HashStringList &list)
    102100{
    103     if (!list.m_hashed) {
    104         list.m_hashed = true;
     101    if (list.m_hash & 0x80000000) {
    105102        uint hash = 0;
    106103        foreach (const HashString &qs, list.m_list) {
    107             hash ^= qHash(qs) ^ 0xa09df22f;
    108             hash = (hash << 13) | (hash >> 19);
     104            hash ^= qHash(qs) ^ 0x;
     105            hash = ();
    109106        }
    110107        list.m_hash = hash;
     
    216213    struct IfdefState {
    217214        IfdefState() {}
    218         IfdefState(int _braceDepth, int _parenDepth) :
     215        IfdefState(int _bracketDepth, int _braceDepth, int _parenDepth) :
     216            bracketDepth(_bracketDepth),
    219217            braceDepth(_braceDepth),
    220218            parenDepth(_parenDepth),
     
    223221
    224222        SavedState state;
     223
    225224        int braceDepth, braceDepth1st;
    226225        int parenDepth, parenDepth1st;
     
    260259    bool qualifyOneCallbackOwn(const Namespace *ns, void *context) const;
    261260    bool qualifyOneCallbackUsing(const Namespace *ns, void *context) const;
     261
     262
    262263    bool qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
    263264                    NamespaceList *resolved) const;
     
    279280    enum {
    280281        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,
    283284        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 = 99
     285        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
    289290    };
    290291
     
    298299    qlonglong yyInteger;
    299300    QStack<IfdefState> yyIfdefStack;
     301
    300302    int yyBraceDepth;
    301303    int yyParenDepth;
    302304    int yyLineNo;
    303305    int yyCurLineNo;
     306
    304307    int yyBraceLineNo;
    305308    int yyParenLineNo;
     
    338341        directInclude = false;
    339342    }
     343
    340344    yyBraceDepth = 0;
    341345    yyParenDepth = 0;
    342346    yyCurLineNo = 1;
     347
    343348    yyBraceLineNo = 1;
    344349    yyParenLineNo = 1;
     
    567572                if (yyCh == 'f') {
    568573                    // if, ifdef, ifndef
    569                     yyIfdefStack.push(IfdefState(yyBraceDepth, yyParenDepth));
     574                    yyIfdefStack.push(IfdefState(yyBraceDepth, yyParenDepth));
    570575                    yyCh = getChar();
    571576                } else if (yyCh == 'n') {
     
    606611                        IfdefState &is = yyIfdefStack.top();
    607612                        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 "
    610617                                         "#if and #else branches; using #if branch\n",
    611618                                         qPrintable(yyFileName), is.elseLine);
    612619                        } else {
     620
    613621                            is.braceDepth1st = yyBraceDepth;
    614622                            is.parenDepth1st = yyParenDepth;
     
    616624                        }
    617625                        is.elseLine = yyLineNo;
     626
    618627                        yyBraceDepth = is.braceDepth;
    619628                        yyParenDepth = is.parenDepth;
     
    625634                        IfdefState is = yyIfdefStack.pop();
    626635                        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)
    628639                                qWarning("%s:%d: Parenthesis/brace mismatch between "
    629640                                         "#if and #else branches; using #if branch\n",
    630641                                         qPrintable(yyFileName), is.elseLine);
     642
    631643                            yyBraceDepth = is.braceDepth1st;
    632644                            yyParenDepth = is.parenDepth1st;
     
    901913                yyCh = getChar();
    902914                return Tok_RightParen;
     915
     916
     917
     918
     919
     920
     921
     922
     923
     924
     925
     926
     927
     928
     929
    903930            case ',':
    904931                yyCh = getChar();
     
    10371064
    10381065struct 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)
    10411069    {}
    10421070
     
    10451073    const HashString &segment;
    10461074    NamespaceList *resolved;
    1047     QSet<HashStringList> visitedUsings;
     1075    QSet<HashStringList> visitedUsings;
    10481076};
    10491077
     
    10791107    QualifyOneData *data = (QualifyOneData *)context;
    10801108    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))
    10841113                return true;
    10851114        }
     
    10881117
    10891118bool CppParser::qualifyOne(const NamespaceList &namespaces, int nsCnt, const HashString &segment,
    1090                            NamespaceList *resolved) const
    1091 {
    1092     QualifyOneData data(namespaces, nsCnt, segment, resolved);
     1119                           NamespaceList *resolved) const
     1120{
     1121    QualifyOneData data(namespaces, nsCnt, segment, resolved);
    10931122
    10941123    if (visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackOwn, &data))
     
    10961125
    10971126    return visitNamespace(namespaces, nsCnt, &CppParser::qualifyOneCallbackUsing, &data);
     1127
     1128
     1129
     1130
     1131
     1132
     1133
     1134
    10981135}
    10991136
     
    15261563    yyTok = getToken();
    15271564    while (yyTok != Tok_Eof) {
     1565
     1566
     1567
     1568
     1569
     1570
    15281571        //qDebug() << "TOKEN: " << yyTok;
    15291572        switch (yyTok) {
     
    19932036                        context = comment.left(k);
    19942037                        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));
    19972044                        extracomment.clear();
     2045
    19982046                        tor->setExtras(extra);
    19992047                        extra.clear();
     
    20662114            if (!yyParenDepth)
    20672115                prospectiveContext.clear();
     2116
     2117
     2118
    20682119        case_default:
    20692120            yyTok = getToken();
     
    20802131                 " (or abuse of the C++ preprocessor)\n",
    20812132                 qPrintable(yyFileName), yyParenLineNo);
     2133
     2134
     2135
     2136
    20822137}
    20832138
  • trunk/tools/linguist/lupdate/main.cpp

    r651 r769  
    137137
    138138static 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,
    140140    UpdateOptions options, bool *fail)
    141141{
     
    155155            tor.resolveDuplicates();
    156156            cd.clearErrors();
    157             if (!codecForTr.isEmpty() && codecForTr != tor.codecName())
     157            if (())
    158158                qWarning("lupdate warning: Codec for tr() '%s' disagrees with "
    159159                         "existing file's codec '%s'. Expect trouble.",
    160                          codecForTr.constData(), tor.codecName().constData());
     160                         .constData(), tor.codecName().constData());
    161161            if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode())
    162162                qWarning("lupdate warning: Specified target language '%s' disagrees with "
     
    168168                         qPrintable(sourceLanguage), qPrintable(tor.sourceLanguageCode()));
    169169        } else {
    170             if (!codecForTr.isEmpty())
    171                 tor.setCodecName(codecForTr);
     170            if ()
     171                tor.setCodec);
    172172            if (!targetLanguage.isEmpty())
    173173                tor.setLanguageCode(targetLanguage);
     
    191191            theseOptions |= NoLocations;
    192192        Translator out = merge(tor, fetchedTor, theseOptions, err);
    193         if (!codecForTr.isEmpty())
    194             out.setCodecName(codecForTr);
     193        if ()
     194            out.setCodec);
    195195
    196196        if ((options & Verbose) && !err.isEmpty()) {
     
    375375            }
    376376            Translator tor;
    377             QByteArray codecForTr;
     377            ;
    378378            QStringList tmp = visitor.values(QLatin1String("CODEC"))
    379379                              + visitor.values(QLatin1String("DEFAULTCODEC"))
    380380                              + visitor.values(QLatin1String("CODECFORTR"));
    381381            if (!tmp.isEmpty()) {
    382                 codecForTr = tmp.last().toLatin1();
    383                 tor.setCodecName(codecForTr);
     382                );
     383                ;
    384384            }
    385385            processProject(false, pfi, visitor, options, codecForSource,
    386386                           targetLanguage, sourceLanguage, &tor, fail);
    387             updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail);
     387            updateTsFiles(tor, tsFiles, , sourceLanguage, targetLanguage, options, fail);
    388388            continue;
    389389        }
     
    658658        fetchedTor.setCodecName(codecForTr);
    659659        processSources(fetchedTor, sourceFiles, cd);
    660         updateTsFiles(fetchedTor, tsFileNames, codecForTr,
     660        updateTsFiles(fetchedTor, tsFileNames, ,
    661661                      sourceLanguage, targetLanguage, options, &fail);
    662662    } else {
     
    670670            processProjects(true, true, proFiles, options, QByteArray(),
    671671                            targetLanguage, sourceLanguage, &fetchedTor, &fail);
    672             updateTsFiles(fetchedTor, tsFileNames, codecForTr,
     672            updateTsFiles(fetchedTor, tsFileNames, ,
    673673                          sourceLanguage, targetLanguage, options, &fail);
    674674        } else {
  • trunk/tools/linguist/phrasebooks/russian.qph

    r561 r769  
    11761176    <target>ОглавлеМОе</target>
    11771177</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
    11781218</QPH>
  • trunk/tools/linguist/shared/qm.cpp

    r651 r769  
    595595                }
    596596                m += 4;
    597                 QString str = QString::fromUtf16((const ushort *)m, len/2);
     597                QString str = QString *)m, len/2);
    598598                if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
    599599                    for (int i = 0; i < str.length(); ++i)
  • trunk/tools/linguist/shared/translator.h

    r651 r769  
    154154
    155155    void setCodecName(const QByteArray &name);
     156
    156157    QByteArray codecName() const;
    157158    QTextCodec *codec() const { return m_codec; }
Note: See TracChangeset for help on using the changeset viewer.