diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-12 12:35:46 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-12 12:35:46 (GMT) |
commit | c53414e11b3f980f81a4470b3fb52f9d1aa80d56 (patch) | |
tree | 7d51540148af638b1c4fb7cda939d34739245457 /tools/assistant | |
parent | f2b93868f48a3e2d6e462ca8a051ab47eefef49d (diff) | |
parent | 304bf2ef0a99882d2d969347f85a330523086fb3 (diff) | |
download | Qt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.zip Qt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.tar.gz Qt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.tar.bz2 |
Merge commit 'origin/4.5'
Conflicts:
demos/boxes/glshaders.cpp
src/gui/graphicsview/qgraphicsitem.cpp
tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
tools/linguist/shared/cpp.cpp
translations/linguist_ja.qm
translations/qt_ru.qm
Diffstat (limited to 'tools/assistant')
-rw-r--r-- | tools/assistant/lib/qhelpgenerator.cpp | 94 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchengine.cpp | 2 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/centralwidget.cpp | 3 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/mainwindow.cpp | 4 |
4 files changed, 55 insertions, 48 deletions
diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp index 03df3cc..8512adb 100644 --- a/tools/assistant/lib/qhelpgenerator.cpp +++ b/tools/assistant/lib/qhelpgenerator.cpp @@ -467,8 +467,9 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa emit statusChanged(tr("Insert files...")); QList<int> filterAtts; - foreach (QString filterAtt, filterAttributes) { - d->query->prepare(QLatin1String("SELECT Id FROM FilterAttributeTable WHERE Name=?")); + foreach (const QString &filterAtt, filterAttributes) { + d->query->prepare(QLatin1String("SELECT Id FROM FilterAttributeTable " + "WHERE Name=?")); d->query->bindValue(0, filterAtt); d->query->exec(); if (d->query->next()) @@ -482,76 +483,76 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa if (filterSetId < 0) return false; ++filterSetId; - foreach (int attId, filterAtts) { - d->query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable VALUES(?, ?)")); + foreach (const int &attId, filterAtts) { + d->query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable " + "VALUES(?, ?)")); d->query->bindValue(0, filterSetId); d->query->bindValue(1, attId); d->query->exec(); } - QString title; - QString charSet; - QMap<int, QSet<int> > tmpFileFilterMap; - QList<FileNameTableData> fileNameDataList; - QList<QByteArray> fileDataList; - int tableFileId = 1; d->query->exec(QLatin1String("SELECT MAX(Id) FROM FileDataTable")); if (d->query->next()) tableFileId = d->query->value(0).toInt() + 1; + QString title; + QString charSet; FileNameTableData fileNameData; + QList<QByteArray> fileDataList; + QMap<int, QSet<int> > tmpFileFilterMap; + QList<FileNameTableData> fileNameDataList; int i = 0; - foreach (QString file, files) { - QFileInfo fi(rootPath + QDir::separator() + file); + foreach (const QString &file, files) { + const QString fileName = QDir::cleanPath(file); + if (fileName.startsWith(QLatin1String("../"))) { + emit warning(tr("The referenced file %1 must be inside or within a " + "subdirectory of (%2). Skipping it.").arg(fileName).arg(rootPath)); + continue; + } + + QFile fi(rootPath + QDir::separator() + fileName); if (!fi.exists()) { emit warning(tr("The file %1 does not exist! Skipping it.") - .arg(fi.absoluteFilePath())); + .arg(QDir::cleanPath(rootPath + QDir::separator() + fileName))); continue; } - QFile f(fi.absoluteFilePath()); - if (!f.open(QIODevice::ReadOnly)) { + if (!fi.open(QIODevice::ReadOnly)) { emit warning(tr("Cannot open file %1! Skipping it.") - .arg(fi.absoluteFilePath())); + .arg(QDir::cleanPath(rootPath + QDir::separator() + fileName))); continue; } - title.clear(); - QByteArray data; - data = f.readAll(); - - if (fi.suffix() == QLatin1String("html") || fi.suffix() == QLatin1String("htm")) { - charSet = QHelpGlobal::charsetFromData(data); - QTextStream stream(&data); - stream.setCodec(QTextCodec::codecForName(charSet.toLatin1().constData())); - title = QHelpGlobal::documentTitle(stream.readAll()); + QByteArray data = fi.readAll(); + if (fileName.endsWith(QLatin1String(".html")) + || fileName.endsWith(QLatin1String(".htm"))) { + charSet = QHelpGlobal::charsetFromData(data); + QTextStream stream(&data); + stream.setCodec(QTextCodec::codecForName(charSet.toLatin1().constData())); + title = QHelpGlobal::documentTitle(stream.readAll()); } else { title = fi.fileName(); } - QString fName = QDir::cleanPath(file); - if (fName.startsWith(QLatin1String("./"))) - fName = fName.mid(2); - int fileId = -1; - if (!d->fileMap.contains(fName)) { + if (!d->fileMap.contains(fileName)) { fileDataList.append(qCompress(data)); - fileNameData.name = fName; + fileNameData.name = fileName; fileNameData.fileId = tableFileId; fileNameData.title = title; fileNameDataList.append(fileNameData); - d->fileMap.insert(fName, tableFileId); + d->fileMap.insert(fileName, tableFileId); d->fileFilterMap.insert(tableFileId, filterAtts.toSet()); tmpFileFilterMap.insert(tableFileId, filterAtts.toSet()); ++tableFileId; } else { - fileId = d->fileMap.value(fName); - foreach (int filter, filterAtts) { + fileId = d->fileMap.value(fileName); + foreach (const int &filter, filterAtts) { if (!d->fileFilterMap.value(fileId).contains(filter) && !tmpFileFilterMap.value(fileId).contains(filter)) { d->fileFilterMap[fileId].insert(filter); @@ -565,20 +566,22 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa d->query->exec(QLatin1String("BEGIN")); QMap<int, QSet<int> >::const_iterator it = tmpFileFilterMap.constBegin(); while (it != tmpFileFilterMap.constEnd()) { - QSet<int>::const_iterator i = it.value().constBegin(); - while (i != it.value().constEnd()) { - d->query->prepare(QLatin1String("INSERT INTO FileFilterTable VALUES(?, ?)")); - d->query->bindValue(0, *i); + QSet<int>::const_iterator si = it.value().constBegin(); + while (si != it.value().constEnd()) { + d->query->prepare(QLatin1String("INSERT INTO FileFilterTable " + "VALUES(?, ?)")); + d->query->bindValue(0, *si); d->query->bindValue(1, it.key()); d->query->exec(); - ++i; + ++si; } ++it; } QList<QByteArray>::const_iterator fileIt = fileDataList.constBegin(); while (fileIt != fileDataList.constEnd()) { - d->query->prepare(QLatin1String("INSERT INTO FileDataTable VALUES (Null, ?)")); + d->query->prepare(QLatin1String("INSERT INTO FileDataTable VALUES " + "(Null, ?)")); d->query->bindValue(0, *fileIt); d->query->exec(); ++fileIt; @@ -586,10 +589,11 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa addProgress(d->fileStep*20.0); } - QList<FileNameTableData>::const_iterator fileNameIt = fileNameDataList.constBegin(); + QList<FileNameTableData>::const_iterator fileNameIt = + fileNameDataList.constBegin(); while (fileNameIt != fileNameDataList.constEnd()) { - d->query->prepare(QLatin1String("INSERT INTO FileNameTable (FolderId, Name, FileId, Title) " - " VALUES (?, ?, ?, ?)")); + d->query->prepare(QLatin1String("INSERT INTO FileNameTable " + "(FolderId, Name, FileId, Title) VALUES (?, ?, ?, ?)")); d->query->bindValue(0, 1); d->query->bindValue(1, (*fileNameIt).name); d->query->bindValue(2, (*fileNameIt).fileId); @@ -609,8 +613,8 @@ bool QHelpGenerator::insertFiles(const QStringList &files, const QString &rootPa return false; } -bool QHelpGenerator::registerCustomFilter(const QString &filterName, const QStringList &filterAttribs, - bool forceUpdate) +bool QHelpGenerator::registerCustomFilter(const QString &filterName, + const QStringList &filterAttribs, bool forceUpdate) { if (!d->query) return false; diff --git a/tools/assistant/lib/qhelpsearchengine.cpp b/tools/assistant/lib/qhelpsearchengine.cpp index 9025f4f..5e7974d 100644 --- a/tools/assistant/lib/qhelpsearchengine.cpp +++ b/tools/assistant/lib/qhelpsearchengine.cpp @@ -243,7 +243,7 @@ private: This enum type specifies the field names that are handled by the search engine. \value DEFAULT the default field provided by the search widget, several terms should be - splitted and stored in the wordlist except search terms enclosed in quotes. + split and stored in the word list except search terms enclosed in quotes. \value FUZZY a field only provided in use with clucene. Terms should be split in seperate words and passed to the search engine. \value WITHOUT a field only provided in use with clucene. Terms should be split in seperate diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 52d48d5..95e458c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -780,6 +780,9 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) menu.addSeparator(); QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page...")); + const QString &url = viewer->source().toString(); + if (url.isEmpty() || url == QLatin1String("about:blank")) + newBookmark->setEnabled(false); QAction *pickedAction = menu.exec(tabBar->mapToGlobal(point)); if (pickedAction == newPage) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2b53f09..44ef211 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -468,7 +468,7 @@ void MainWindow::setupActions() menu = menuBar()->addMenu(tr("&Go")); m_homeAction = menu->addAction(tr("&Home"), m_centralWidget, SLOT(home())); - m_homeAction->setShortcut(tr("Ctrl+Home")); + m_homeAction->setShortcut(tr("ALT+Home")); m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png"))); m_backAction = menu->addAction(tr("&Back"), m_centralWidget, SLOT(backward())); @@ -748,7 +748,7 @@ void MainWindow::copyAvailable(bool yes) void MainWindow::addNewBookmark(const QString &title, const QString &url) { - if (url.isEmpty()) + if (url.isEmpty() || url == QLatin1String("about:blank")) return; m_bookmarkManager->showBookmarkDialog(this, title, url); |