tools/assistant/lib/qhelpindexwidget.cpp
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the Qt Assistant of the Qt Toolkit.
     7 ** This file is part of the Qt Assistant of the Qt Toolkit.
     8 **
     8 **
   160     m_indices.clear();
   160     m_indices.clear();
   161     m_activeReaders.clear();
   161     m_activeReaders.clear();
   162     QSet<QString> indicesSet;
   162     QSet<QString> indicesSet;
   163     m_mutex.unlock();
   163     m_mutex.unlock();
   164 
   164 
   165     foreach (QString dbFileName, m_helpEngine->fileNameReaderMap.keys()) {
   165     foreach (const QString &dbFileName, m_helpEngine->fileNameReaderMap.keys()) {
   166         m_mutex.lock();
   166         m_mutex.lock();
   167         if (m_abort) {
   167         if (m_abort) {
   168             m_mutex.unlock();
   168             m_mutex.unlock();
   169             return;
   169             return;
   170         }
   170         }
   176         if (!reader.init())
   176         if (!reader.init())
   177             continue;
   177             continue;
   178         QStringList lst = reader.indicesForFilter(atts);
   178         QStringList lst = reader.indicesForFilter(atts);
   179         if (!lst.isEmpty()) {
   179         if (!lst.isEmpty()) {
   180             m_mutex.lock();
   180             m_mutex.lock();
   181             foreach (QString s, lst)
   181             foreach (const QString &s, lst)
   182                 indicesSet.insert(s);
   182                 indicesSet.insert(s);
   183             if (m_abort) {
   183             if (m_abort) {
   184                 m_mutex.unlock();
   184                 m_mutex.unlock();
   185                 return;
   185                 return;
   186             }
   186             }
   315     int perfectMatch = -1;
   315     int perfectMatch = -1;
   316 
   316 
   317     if (!wildcard.isEmpty()) {
   317     if (!wildcard.isEmpty()) {
   318         QRegExp regExp(wildcard, Qt::CaseInsensitive);
   318         QRegExp regExp(wildcard, Qt::CaseInsensitive);
   319         regExp.setPatternSyntax(QRegExp::Wildcard);
   319         regExp.setPatternSyntax(QRegExp::Wildcard);
   320         foreach (QString index, d->indices) {
   320         foreach (const QString &index, d->indices) {
   321             if (index.contains(regExp)) {
   321             if (index.contains(regExp)) {
   322                 lst.append(index);
   322                 lst.append(index);
   323                 if (perfectMatch == -1 && index.startsWith(filter, Qt::CaseInsensitive)) {
   323                 if (perfectMatch == -1 && index.startsWith(filter, Qt::CaseInsensitive)) {
   324                     if (goodMatch == -1)
   324                     if (goodMatch == -1)
   325                         goodMatch = lst.count()-1;
   325                         goodMatch = lst.count()-1;
   330                     perfectMatch = lst.count()-1;
   330                     perfectMatch = lst.count()-1;
   331                 }
   331                 }
   332             }
   332             }
   333         }
   333         }
   334     } else {
   334     } else {
   335         foreach (QString index, d->indices) {
   335         foreach (const QString &index, d->indices) {
   336             if (index.contains(filter, Qt::CaseInsensitive)) {
   336             if (index.contains(filter, Qt::CaseInsensitive)) {
   337                 lst.append(index);
   337                 lst.append(index);
   338                 if (perfectMatch == -1 && index.startsWith(filter, Qt::CaseInsensitive)) {
   338                 if (perfectMatch == -1 && index.startsWith(filter, Qt::CaseInsensitive)) {
   339                     if (goodMatch == -1)
   339                     if (goodMatch == -1)
   340                         goodMatch = lst.count()-1;
   340                         goodMatch = lst.count()-1;