File indexing completed on 2024-05-12 16:39:40
0001 /* This file is part of the KDE project 0002 Copyright (C) 2007 Jarosław Staniek <staniek@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KEXISEARCHANDREPLACEIFACE_H 0021 #define KEXISEARCHANDREPLACEIFACE_H 0022 0023 #include "kexicore_export.h" 0024 0025 #include <KDbTristate> 0026 0027 #include <QString> 0028 0029 class QVariant; 0030 class QStringList; 0031 0032 //! @short An interface used by Kexi views (KexiView) supporting search/replace features 0033 class KEXICORE_EXPORT KexiSearchAndReplaceViewInterface 0034 { 0035 public: 0036 KexiSearchAndReplaceViewInterface(); 0037 virtual ~KexiSearchAndReplaceViewInterface(); 0038 0039 //! @short Specifies options for find and replace operations. 0040 /*! A GUI for setting these options is provided by KexiFindDialog class. */ 0041 class KEXICORE_EXPORT Options 0042 { 0043 public: 0044 Options(); 0045 0046 //! Special values for columnNumber. 0047 enum SpecialLookInValue { 0048 AllColumns = -1, //!< "all columns" (the default) 0049 CurrentColumn = -2 //!< "current column" 0050 }; 0051 //! Column number to look in, AllColumns means "all columns" (the default) 0052 //! and CurrentColumn means "current column". 0053 int columnNumber; 0054 0055 //! Specifies possible options for text matching 0056 enum TextMatching { 0057 MatchAnyPartOfField = 0, //!< Matched text can be any part of field (the default) 0058 MatchWholeField = 1, //!< Matched text must be the whole field 0059 MatchStartOfField = 2 //!< Matched text must be at the start of field 0060 }; 0061 0062 //! Specifies possible options for text matching 0063 TextMatching textMatching; 0064 0065 //! Specifies search direction 0066 enum SearchDirection { 0067 SearchUp = 0, //!< Search up (previous) from the current position 0068 SearchDown = 1, //!< Search down (next) from the current position (the default) 0069 SearchAllRecords = 2, //!< Search from the first to the last record 0070 DefaultSearchDirection = SearchDown //! Used to mark the default 0071 }; 0072 0073 //! Specifies search direction 0074 SearchDirection searchDirection; 0075 0076 //! True for searching is case-sensitive (false by default) 0077 bool caseSensitive; 0078 0079 //! True for searching for whole words only (false by default) 0080 bool wholeWordsOnly; 0081 0082 //! True if question should be displayed before every replacement made (true by default) 0083 bool promptOnReplace; 0084 }; 0085 0086 /*! Sets up data for find/replace dialog, based on view's data model. 0087 \a columnNames should contain column name, \a columnCaptions should contain column captions, 0088 and \a currentColumnName should beset to current column's name. 0089 Implementation should set up values and return true if find/replace dialog should be filled. */ 0090 virtual bool setupFindAndReplace(QStringList& columnNames, QStringList& columnCaptions, 0091 QString& currentColumnName) = 0; 0092 0093 /*! Finds \a valueToFind within the view. 0094 \a options are used to control the process. Selection is moved to found value. 0095 \return true if value has been found, false if value has not been found, 0096 and cancelled if there is nothing to find or there is no data to search in. 0097 If \a next is true, "find next" is performed, else "find previous" is performed. */ 0098 virtual tristate find(const QVariant& valueToFind, 0099 const KexiSearchAndReplaceViewInterface::Options& options, bool next) = 0; 0100 0101 /*! Finds \a valueToFind within the view and replaces with \a replacement 0102 \a options are used to control the process. 0103 \return true if value has been found and replaced, false if value 0104 has not been found and replaced, and cancelled if there is nothing 0105 to find or there is no data to search in or the data is read only. 0106 If \a replaceAll is true, all found values are replaced. */ 0107 virtual tristate findNextAndReplace(const QVariant& valueToFind, const QVariant& replacement, 0108 const KexiSearchAndReplaceViewInterface::Options& options, 0109 bool replaceAll) = 0; 0110 }; 0111 0112 #endif