Changeset 561 for trunk/tools/assistant/lib/qhelpprojectdata.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/assistant/lib/qhelpprojectdata.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the Qt Assistant of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 42 42 #include "qhelpprojectdata_p.h" 43 43 44 #include <QtCore/QDir> 44 45 #include <QtCore/QFileInfo> 45 46 #include <QtCore/QStack> 46 47 #include <QtCore/QMap> 48 #include <QtCore/QRegExp> 47 49 #include <QtCore/QVariant> 48 50 #include <QtXml/QXmlStreamReader> … … 74 76 void readFiles(); 75 77 void raiseUnknownTokenError(); 78 void addMatchingFiles(const QString &pattern); 79 80 QMap<QString, QStringList> dirEntriesCache; 76 81 }; 77 82 … … 162 167 if (isStartElement()) { 163 168 if (name() == QLatin1String("filterAttribute")) 164 filterSectionList.last().addFilterAttribute(readElementText()); 169 filterSectionList.last().addFilterAttribute(readElementText()); 165 170 else if (name() == QLatin1String("toc")) 166 171 readTOC(); … … 245 250 if (isStartElement()) { 246 251 if (name() == QLatin1String("file")) 247 filterSectionList.last().addFile(readElementText());252 addMatchingFiles(readElementText()); 248 253 else 249 254 raiseUnknownTokenError(); … … 259 264 } 260 265 261 266 // Expand file pattern and add matches into list. If the pattern does not match 267 // any files, insert the pattern itself so the QHelpGenerator will emit a 268 // meaningful warning later. 269 void QHelpProjectDataPrivate::addMatchingFiles(const QString &pattern) 270 { 271 // The pattern matching is expensive, so we skip it if no 272 // wildcard symbols occur in the string. 273 if (!pattern.contains('?') && !pattern.contains('*') 274 && !pattern.contains('[') && !pattern.contains(']')) { 275 filterSectionList.last().addFile(pattern); 276 return; 277 } 278 279 QFileInfo fileInfo(rootPath + '/' + pattern); 280 const QDir &dir = fileInfo.dir(); 281 const QString &path = dir.canonicalPath(); 282 283 // QDir::entryList() is expensive, so we cache the results. 284 QMap<QString, QStringList>::ConstIterator it = dirEntriesCache.find(path); 285 const QStringList &entries = it != dirEntriesCache.constEnd() ? 286 it.value() : dir.entryList(QDir::Files); 287 if (it == dirEntriesCache.constEnd()) 288 dirEntriesCache.insert(path, entries); 289 290 bool matchFound = false; 291 #ifdef Q_OS_WIN 292 Qt::CaseSensitivity cs = Qt::CaseInsensitive; 293 #else 294 Qt::CaseSensitivity cs = Qt::CaseSensitive; 295 #endif 296 QRegExp regExp(fileInfo.fileName(), cs, QRegExp::Wildcard); 297 foreach (const QString &file, entries) { 298 if (regExp.exactMatch(file)) { 299 matchFound = true; 300 filterSectionList.last(). 301 addFile(QFileInfo(pattern).dir().path() + '/' + file); 302 } 303 } 304 if (!matchFound) 305 filterSectionList.last().addFile(pattern); 306 } 262 307 263 308 /*! … … 325 370 326 371 /*! 327 \ reimp372 \internal 328 373 */ 329 374 QString QHelpProjectData::namespaceName() const … … 333 378 334 379 /*! 335 \ reimp380 \internal 336 381 */ 337 382 QString QHelpProjectData::virtualFolder() const … … 341 386 342 387 /*! 343 \ reimp388 \internal 344 389 */ 345 390 QList<QHelpDataCustomFilter> QHelpProjectData::customFilters() const … … 349 394 350 395 /*! 351 \ reimp396 \internal 352 397 */ 353 398 QList<QHelpDataFilterSection> QHelpProjectData::filterSections() const … … 357 402 358 403 /*! 359 \ reimp404 \internal 360 405 */ 361 406 QMap<QString, QVariant> QHelpProjectData::metaData() const … … 365 410 366 411 /*! 367 \ reimp412 \internal 368 413 */ 369 414 QString QHelpProjectData::rootPath() const
Note:
See TracChangeset
for help on using the changeset viewer.