Changeset 846 for trunk/tools/assistant/lib/qhelp_global.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/assistant/lib/qhelp_global.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include <QtCore/QCoreApplication> 42 43 #include <QtCore/QRegExp> 43 44 #include <QtCore/QMutexLocker> … … 56 57 57 58 return QString::fromLatin1("%1-%2-%3"). 58 arg(name).arg( long(pointer)).arg(counter);59 arg(name).arg(quintptr(pointer)).arg(counter); 59 60 } 60 61 61 62 QString QHelpGlobal::documentTitle(const QString &content) 62 63 { 63 QString title = Q Object::tr("Untitled");64 QString title = QCoreApplication::translate("QHelp", "Untitled"); 64 65 if (!content.isEmpty()) { 65 66 int start = content.indexOf(QLatin1String("<title>"), 0, Qt::CaseInsensitive) + 7; … … 87 88 QString QHelpGlobal::codecFromHtmlData(const QByteArray &data) 88 89 { 89 QString content = QString::fromUtf8(data.constData(), data.size());90 int start = content.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive);90 QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size())); 91 int start = head.indexOf(QLatin1String("<meta"), 0, Qt::CaseInsensitive); 91 92 if (start > 0) { 92 int end;93 93 QRegExp r(QLatin1String("charset=([^\"\\s]+)")); 94 94 while (start != -1) { 95 end = content.indexOf(QLatin1Char('>'), start) + 1; 96 const QString &meta = content.mid(start, end - start).toLower(); 95 const int end = head.indexOf(QLatin1Char('>'), start) + 1; 96 if (end <= start) 97 break; 98 const QString &meta = head.mid(start, end - start).toLower(); 97 99 if (r.indexIn(meta) != -1) 98 100 return r.cap(1); 99 start = content.indexOf(QLatin1String("<meta"), end,101 start = head.indexOf(QLatin1String("<meta"), end, 100 102 Qt::CaseInsensitive); 101 103 } … … 106 108 QString QHelpGlobal::codecFromXmlData(const QByteArray &data) 107 109 { 108 QString content = QString::fromUtf8(data.constData(), data.size());110 QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size())); 109 111 const QRegExp encodingExp(QLatin1String("^\\s*<\\?xml version=" 110 112 "\"\\d\\.\\d\" encoding=\"([^\"]+)\"\\?>.*")); 111 return encodingExp.exactMatch( content) ? encodingExp.cap(1) : QString();113 return encodingExp.exactMatch(head) ? encodingExp.cap(1) : QString(); 112 114 }
Note:
See TracChangeset
for help on using the changeset viewer.