Changeset 561 for trunk/tools/assistant/lib/qhelpgenerator.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/qhelpgenerator.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 ** … … 468 468 emit statusChanged(tr("Insert files...")); 469 469 QList<int> filterAtts; 470 foreach (QString filterAtt, filterAttributes) { 471 d->query->prepare(QLatin1String("SELECT Id FROM FilterAttributeTable WHERE Name=?")); 470 foreach (const QString &filterAtt, filterAttributes) { 471 d->query->prepare(QLatin1String("SELECT Id FROM FilterAttributeTable " 472 "WHERE Name=?")); 472 473 d->query->bindValue(0, filterAtt); 473 474 d->query->exec(); … … 483 484 return false; 484 485 ++filterSetId; 485 foreach (int attId, filterAtts) { 486 d->query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable VALUES(?, ?)")); 486 foreach (const int &attId, filterAtts) { 487 d->query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable " 488 "VALUES(?, ?)")); 487 489 d->query->bindValue(0, filterSetId); 488 490 d->query->bindValue(1, attId); 489 491 d->query->exec(); 490 492 } 491 492 QString title;493 QString charSet;494 QMap<int, QSet<int> > tmpFileFilterMap;495 QList<FileNameTableData> fileNameDataList;496 QList<QByteArray> fileDataList;497 493 498 494 int tableFileId = 1; … … 501 497 tableFileId = d->query->value(0).toInt() + 1; 502 498 499 QString title; 500 QString charSet; 503 501 FileNameTableData fileNameData; 502 QList<QByteArray> fileDataList; 503 QMap<int, QSet<int> > tmpFileFilterMap; 504 QList<FileNameTableData> fileNameDataList; 504 505 505 506 int i = 0; 506 foreach (QString file, files) { 507 QFileInfo fi(rootPath + QDir::separator() + file); 507 foreach (const QString &file, files) { 508 const QString fileName = QDir::cleanPath(file); 509 if (fileName.startsWith(QLatin1String("../"))) { 510 emit warning(tr("The referenced file %1 must be inside or within a " 511 "subdirectory of (%2). Skipping it.").arg(fileName).arg(rootPath)); 512 continue; 513 } 514 515 QFile fi(rootPath + QDir::separator() + fileName); 508 516 if (!fi.exists()) { 509 517 emit warning(tr("The file %1 does not exist! Skipping it.") 510 .arg( fi.absoluteFilePath()));518 .arg(QDir::cleanPath(rootPath + QDir::separator() + fileName))); 511 519 continue; 512 520 } 513 521 514 QFile f(fi.absoluteFilePath()); 515 if (!f.open(QIODevice::ReadOnly)) { 522 if (!fi.open(QIODevice::ReadOnly)) { 516 523 emit warning(tr("Cannot open file %1! Skipping it.") 517 .arg( fi.absoluteFilePath()));524 .arg(QDir::cleanPath(rootPath + QDir::separator() + fileName))); 518 525 continue; 519 526 } 520 527 521 title.clear(); 522 QByteArray data; 523 data = f.readAll(); 524 525 if (fi.suffix() == QLatin1String("html") || fi.suffix() == QLatin1String("htm")) { 526 charSet = QHelpGlobal::charsetFromData(data); 527 QTextStream stream(&data); 528 stream.setCodec(QTextCodec::codecForName(charSet.toLatin1().constData())); 529 title = QHelpGlobal::documentTitle(stream.readAll()); 528 QByteArray data = fi.readAll(); 529 if (fileName.endsWith(QLatin1String(".html")) 530 || fileName.endsWith(QLatin1String(".htm"))) { 531 charSet = QHelpGlobal::codecFromData(data); 532 QTextStream stream(&data); 533 stream.setCodec(QTextCodec::codecForName(charSet.toLatin1().constData())); 534 title = QHelpGlobal::documentTitle(stream.readAll()); 530 535 } else { 531 title = fi.fileName(); 532 } 533 534 QString fName = QDir::cleanPath(file); 535 if (fName.startsWith(QLatin1String("./"))) 536 fName = fName.mid(2); 536 title = fileName.mid(fileName.lastIndexOf(QLatin1Char('/')) + 1); 537 } 537 538 538 539 int fileId = -1; 539 if (!d->fileMap.contains(f Name)) {540 if (!d->fileMap.contains(fileName)) { 540 541 fileDataList.append(qCompress(data)); 541 542 542 fileNameData.name = f Name;543 fileNameData.name = fileName; 543 544 fileNameData.fileId = tableFileId; 544 545 fileNameData.title = title; 545 546 fileNameDataList.append(fileNameData); 546 547 547 d->fileMap.insert(f Name, tableFileId);548 d->fileMap.insert(fileName, tableFileId); 548 549 d->fileFilterMap.insert(tableFileId, filterAtts.toSet()); 549 550 tmpFileFilterMap.insert(tableFileId, filterAtts.toSet()); … … 551 552 ++tableFileId; 552 553 } else { 553 fileId = d->fileMap.value(f Name);554 foreach ( intfilter, filterAtts) {554 fileId = d->fileMap.value(fileName); 555 foreach (const int &filter, filterAtts) { 555 556 if (!d->fileFilterMap.value(fileId).contains(filter) 556 557 && !tmpFileFilterMap.value(fileId).contains(filter)) { … … 566 567 QMap<int, QSet<int> >::const_iterator it = tmpFileFilterMap.constBegin(); 567 568 while (it != tmpFileFilterMap.constEnd()) { 568 QSet<int>::const_iterator i = it.value().constBegin(); 569 while (i != it.value().constEnd()) { 570 d->query->prepare(QLatin1String("INSERT INTO FileFilterTable VALUES(?, ?)")); 571 d->query->bindValue(0, *i); 569 QSet<int>::const_iterator si = it.value().constBegin(); 570 while (si != it.value().constEnd()) { 571 d->query->prepare(QLatin1String("INSERT INTO FileFilterTable " 572 "VALUES(?, ?)")); 573 d->query->bindValue(0, *si); 572 574 d->query->bindValue(1, it.key()); 573 575 d->query->exec(); 574 ++ i;576 ++si; 575 577 } 576 578 ++it; … … 579 581 QList<QByteArray>::const_iterator fileIt = fileDataList.constBegin(); 580 582 while (fileIt != fileDataList.constEnd()) { 581 d->query->prepare(QLatin1String("INSERT INTO FileDataTable VALUES (Null, ?)")); 583 d->query->prepare(QLatin1String("INSERT INTO FileDataTable VALUES " 584 "(Null, ?)")); 582 585 d->query->bindValue(0, *fileIt); 583 586 d->query->exec(); … … 587 590 } 588 591 589 QList<FileNameTableData>::const_iterator fileNameIt = fileNameDataList.constBegin(); 592 QList<FileNameTableData>::const_iterator fileNameIt = 593 fileNameDataList.constBegin(); 590 594 while (fileNameIt != fileNameDataList.constEnd()) { 591 d->query->prepare(QLatin1String("INSERT INTO FileNameTable (FolderId, Name, FileId, Title)"592 " VALUES (?, ?, ?, ?)"));595 d->query->prepare(QLatin1String("INSERT INTO FileNameTable " 596 "(FolderId, Name, FileId, Title) VALUES (?, ?, ?, ?)")); 593 597 d->query->bindValue(0, 1); 594 598 d->query->bindValue(1, (*fileNameIt).name); … … 610 614 } 611 615 612 bool QHelpGenerator::registerCustomFilter(const QString &filterName, const QStringList &filterAttribs,613 616 bool QHelpGenerator::registerCustomFilter(const QString &filterName, 617 const QStringList &filterAttribs, bool forceUpdate) 614 618 { 615 619 if (!d->query)
Note:
See TracChangeset
for help on using the changeset viewer.