tools/assistant/lib/qhelpsearchengine.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Assistant of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    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 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QHELPSEARCHENGINE_H
       
    43 #define QHELPSEARCHENGINE_H
       
    44 
       
    45 #include <QtHelp/qhelp_global.h>
       
    46 
       
    47 #include <QtCore/QMap>
       
    48 #include <QtCore/QUrl>
       
    49 #include <QtCore/QObject>
       
    50 #include <QtCore/QString>
       
    51 #include <QtCore/QStringList>
       
    52 
       
    53 QT_BEGIN_HEADER
       
    54 
       
    55 QT_BEGIN_NAMESPACE
       
    56 
       
    57 QT_MODULE(Help)
       
    58 
       
    59 class QHelpEngineCore;
       
    60 class QHelpSearchQueryWidget;
       
    61 class QHelpSearchResultWidget;
       
    62 class QHelpSearchEnginePrivate;
       
    63 
       
    64 class QHELP_EXPORT QHelpSearchQuery
       
    65 {
       
    66 public:
       
    67     enum FieldName { DEFAULT = 0, FUZZY, WITHOUT, PHRASE, ALL, ATLEAST };
       
    68 
       
    69     QHelpSearchQuery()
       
    70         : fieldName(DEFAULT) { wordList.clear(); }
       
    71     QHelpSearchQuery(FieldName field, const QStringList &wordList)
       
    72         : fieldName(field), wordList(wordList) {}
       
    73 
       
    74     FieldName fieldName;
       
    75     QStringList wordList;
       
    76 };
       
    77 
       
    78 class QHELP_EXPORT QHelpSearchEngine : public QObject
       
    79 {
       
    80     Q_OBJECT
       
    81 
       
    82 public:
       
    83     QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent = 0);
       
    84     ~QHelpSearchEngine();
       
    85 
       
    86     QHelpSearchQueryWidget* queryWidget();
       
    87     QHelpSearchResultWidget* resultWidget();
       
    88 
       
    89     int hitsCount() const;
       
    90 
       
    91     typedef QPair<QString, QString> SearchHit;
       
    92     QList<SearchHit> hits(int start, int end) const;
       
    93 
       
    94     QList<QHelpSearchQuery> query() const;
       
    95 
       
    96 public Q_SLOTS:
       
    97     void reindexDocumentation();
       
    98     void cancelIndexing();
       
    99 
       
   100     void search(const QList<QHelpSearchQuery> &queryList);
       
   101     void cancelSearching();
       
   102 
       
   103 Q_SIGNALS:
       
   104     void indexingStarted();
       
   105     void indexingFinished();
       
   106 
       
   107     void searchingStarted();
       
   108     void searchingFinished(int hits);
       
   109 
       
   110 private Q_SLOTS:
       
   111     void indexDocumentation();
       
   112 
       
   113 private:
       
   114     QHelpSearchEnginePrivate *d;
       
   115 };
       
   116 
       
   117 QT_END_NAMESPACE
       
   118 
       
   119 QT_END_HEADER
       
   120 
       
   121 #endif  // QHELPSEARCHENGINE_H