File indexing completed on 2024-05-12 16:35:44

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (c) 2011 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 CALLIGRA_SHEETS_FIND_H
0022 #define CALLIGRA_SHEETS_FIND_H
0023 
0024 #include "sheets_common_export.h"
0025 #include "Cell.h"
0026 
0027 #include <KoFindBase.h>
0028 
0029 namespace Calligra
0030 {
0031 namespace Sheets
0032 {
0033 
0034 class Sheet;
0035 class SheetView;
0036 /**
0037  * Searching implementation for searching through spreadsheets.
0038  *
0039  * This class implements a KoFind-backend for searching in spreadsheets.
0040  *
0041  * Matches found by this class will use Calligra::Sheets::Sheet* as container
0042  * and Calligra::Sheets::Cell as location.
0043  *
0044  * TODO: Add support for searching in notes/comments.
0045  * TODO: Support searching through all Sheets in a document.
0046  * TODO: Search within the displayed text or the user input.
0047  */
0048 class CALLIGRA_SHEETS_COMMON_EXPORT Find : public KoFindBase
0049 {
0050     Q_OBJECT
0051 public:
0052     /**
0053      * Constructor.
0054      */
0055     explicit Find(QObject* parent = 0);
0056 
0057 public Q_SLOTS:
0058     /**
0059      * Set the current active sheet.
0060      *
0061      * Currently this class only searches within the active sheet.
0062      */
0063     void setCurrentSheet(Sheet *sheet, SheetView *view);
0064 
0065 protected:
0066     /**
0067      * Overridden from KoFindBase
0068      */
0069     void replaceImplementation(const KoFindMatch &match, const QVariant &value) override;
0070     /**
0071      * Overridden from KoFindBase
0072      */
0073     void findImplementation(const QString &pattern, KoFindBase::KoFindMatchList &matchList) override;
0074 
0075     /**
0076      * Overridden from KoFindBase
0077      */
0078     void clearMatches() override;
0079 
0080 private:
0081     class Private;
0082     Private * const d;
0083 
0084 private Q_SLOTS:
0085     void setActiveMatch(const KoFindMatch &match);
0086 };
0087 
0088 } //namespace Sheets
0089 } //namespace Calligra
0090 
0091 #endif // CALLIGRA_SHEETS_FIND_H