Warning, file /office/calligra/libs/text/KoFindStrategy.cpp 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 * Copyright (C) 2008 Thorsten Zachmann <zachmann@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 #include "KoFindStrategy.h" 0021 0022 #include <kfind.h> 0023 #include <kfinddialog.h> 0024 #include <kmessagebox.h> 0025 #include <klocalizedstring.h> 0026 0027 #include "FindDirection_p.h" 0028 0029 class NonClosingFindDialog : public KFindDialog 0030 { 0031 Q_OBJECT 0032 public: 0033 NonClosingFindDialog(QWidget *parent) 0034 : KFindDialog(parent) {} 0035 0036 void accept() override {} 0037 }; 0038 0039 KoFindStrategy::KoFindStrategy(QWidget *parent) 0040 : m_dialog(new NonClosingFindDialog(parent)) 0041 , m_matches(0) 0042 { 0043 m_dialog->setOptions(KFind::FromCursor); 0044 } 0045 0046 KoFindStrategy::~KoFindStrategy() 0047 { 0048 if (m_dialog->parent() == 0) 0049 delete m_dialog; 0050 } 0051 0052 KFindDialog *KoFindStrategy::dialog() const 0053 { 0054 return m_dialog; 0055 } 0056 0057 void KoFindStrategy::reset() 0058 { 0059 m_matches = 0; 0060 } 0061 0062 void KoFindStrategy::displayFinalDialog() 0063 { 0064 KMessageBox::information(m_dialog, m_matches ? i18np("Found 1 match", "Found %1 matches", m_matches) : i18n("Found no match")); 0065 reset(); 0066 } 0067 0068 bool KoFindStrategy::foundMatch(QTextCursor &cursor, FindDirection *findDirection) 0069 { 0070 ++m_matches; 0071 findDirection->select(cursor); 0072 return false; 0073 } 0074 #include "KoFindStrategy.moc"