1 /* 2 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 3 SPDX-FileCopyrightText: 2010-2018 Mladen Milinkovic <max@smoothware.net> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #ifndef FINDER_H 9 #define FINDER_H 10 11 #include "core/subtitle.h" 12 #include "core/subtitleline.h" 13 14 #include <QExplicitlySharedDataPointer> 15 #include <QObject> 16 17 QT_FORWARD_DECLARE_CLASS(QGroupBox) 18 QT_FORWARD_DECLARE_CLASS(QRadioButton) 19 class KFind; 20 class KFindDialog; 21 22 namespace SubtitleComposer { 23 class SubtitleIterator; 24 25 class Finder : public QObject 26 { 27 Q_OBJECT 28 29 public: 30 explicit Finder(QWidget *parent = 0); 31 virtual ~Finder(); 32 33 QWidget * parentWidget(); 34 35 public slots: 36 void setSubtitle(Subtitle *subtitle = 0); 37 void setTranslationMode(bool enabled); 38 39 void find(const RangeList &selectionRanges, int currentIndex, const QString &text = QString(), bool findBackwards = false); 40 bool findNext(); 41 bool findPrevious(); 42 43 signals: 44 void found(SubtitleLine *line, bool primary, int startIndex, int endIndex); 45 46 private slots: 47 void invalidate(); 48 49 void onLinePrimaryTextChanged(); 50 void onLineSecondaryTextChanged(); 51 52 void onHighlight(const QString &text, int matchingIndex, int matchedLength); 53 54 void onIteratorSynchronized(int firstIndex, int lastIndex, bool inserted); 55 56 private: 57 void advance(); 58 59 private: 60 QExplicitlySharedDataPointer<const Subtitle> m_subtitle; 61 bool m_translationMode; 62 bool m_feedingPrimary; 63 64 KFind *m_find; 65 KFindDialog *m_dialog; 66 QGroupBox *m_targetGroupBox; 67 QRadioButton *m_targetRadioButtons[SubtitleTargetSize]; 68 SubtitleIterator *m_iterator; 69 SubtitleLine *m_dataLine; 70 bool m_instancesFound; 71 int m_allSearchedIndex; 72 }; 73 } 74 #endif 75