Warning, file /office/calligra/libs/main/KoFindMatch.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KOFINDMATCH_H
0022 #define KOFINDMATCH_H
0023 
0024 #include <QSharedDataPointer>
0025 #include "komain_export.h"
0026 
0027 class QVariant;
0028 
0029 /**
0030  * \brief Encapsulation of a search result.
0031  *
0032  * Due to the fact that Calligra handles many types of documents,
0033  * we cannot rely on something like QTextCursor working for each
0034  * document. Thus, we need to encapsulate the results into
0035  * something more generic. This class serves that function.
0036  *
0037  * This generalisation means this class only stores QVariant
0038  * values. The contents of these variants is dependent on the
0039  * KoFindBase-derived search implementation and the documentation
0040  * of these classes should be consulted for details regarding
0041  * implementation specifics.
0042  *
0043  * This class is implicitly-shared and thus safe to copy around.
0044  *
0045  * \see KoFindBase
0046  */
0047 class KOMAIN_EXPORT KoFindMatch
0048 {
0049 public:
0050     /**
0051      * Default constructor. Creates a match with an invalid
0052      * document and location.
0053      */
0054     KoFindMatch();
0055     /**
0056      * Constructor. Creates a match with the given values used.
0057      *
0058      * \param container The container containing the match.
0059      * \param location The location of the match within the container.
0060      *
0061      * \see container()
0062      * \see location()
0063      */
0064     KoFindMatch(const QVariant &container, const QVariant &location);
0065     /**
0066      * Copy constructor.
0067      *
0068      * \param other The match to copy.
0069      */
0070     KoFindMatch(const KoFindMatch &other);
0071     /**
0072      * Destructor.
0073      */
0074     ~KoFindMatch();
0075 
0076     KoFindMatch &operator=(const KoFindMatch &other);
0077 
0078     /**
0079      * Equals operator.
0080      *
0081      * \param other The other match to compare to.
0082      *
0083      * \return True if this.container == other.container
0084      * and this.location == other.location.
0085      */
0086     bool operator==(const KoFindMatch &other) const;
0087 
0088     /**
0089      * Check whether this is a valid match.
0090      *
0091      * \return True if this.container is valid and
0092      * this.location is valid.
0093      */
0094     bool isValid() const;
0095 
0096     /**
0097      * Retrieve the container of this match.
0098      *
0099      * The container is the first structure that has a clear
0100      * "contains" relationship with a match. For example, for a
0101      * block of text, this will be a QTextDocument. For a
0102      * spreadsheet, it will instead be a sheet. See the
0103      * implementation documentation for specific details.
0104      *
0105      * \return The container of this match.
0106      */
0107     QVariant container() const;
0108 
0109     /**
0110      * Set the container of this match.
0111      *
0112      * \param container The new container to set.
0113      */
0114     void setContainer(const QVariant &container);
0115 
0116     /**
0117      * Retrieve the location of this match.
0118      *
0119      * \return The location of this match.
0120      */
0121     QVariant location() const;
0122 
0123     /**
0124      * Set the location of this match.
0125      *
0126      * \param location The new location to set.
0127      */
0128     void setLocation(const QVariant &location);
0129 
0130 private:
0131     class Private;
0132     QSharedDataPointer<Private> d;
0133 };
0134 
0135 #endif // KOFINDMATCH_H