File indexing completed on 2024-06-09 04:53:12
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar> 0003 SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef REPLACER_H 0009 #define REPLACER_H 0010 0011 #include "core/rangelist.h" 0012 #include "core/subtitle.h" 0013 #include "core/subtitleline.h" 0014 0015 #include <QExplicitlySharedDataPointer> 0016 #include <QObject> 0017 0018 QT_FORWARD_DECLARE_CLASS(QGroupBox) 0019 QT_FORWARD_DECLARE_CLASS(QRadioButton) 0020 QT_FORWARD_DECLARE_CLASS(QDialog) 0021 class KReplace; 0022 class KReplaceDialog; 0023 0024 namespace SubtitleComposer { 0025 class SubtitleIterator; 0026 0027 class Replacer : public QObject 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit Replacer(QWidget *parent = 0); 0033 virtual ~Replacer(); 0034 0035 QWidget * parentWidget(); 0036 0037 public slots: 0038 void setSubtitle(Subtitle *subtitle = 0); 0039 void setTranslationMode(bool enabled); 0040 0041 void replace(const RangeList &selectionRanges, int currentIndex, const QString &text = QString()); 0042 0043 signals: 0044 void found(SubtitleLine *line, bool primary, int startIndex, int endIndex); 0045 0046 private: 0047 void invalidate(); 0048 0049 QDialog * replaceNextDialog(); 0050 0051 private slots: 0052 void onFindNext(); 0053 void onHighlight(const QString &text, int matchingIndex, int matchedLength); 0054 void onReplace(const QString &text, int replacementIndex, int replacedLength, int matchedLength); 0055 0056 private: 0057 QExplicitlySharedDataPointer<const Subtitle> m_subtitle; 0058 bool m_translationMode; 0059 bool m_feedingPrimary; 0060 0061 KReplace *m_replace; 0062 KReplaceDialog *m_dialog; 0063 QGroupBox *m_targetGroupBox; 0064 QRadioButton *m_targetRadioButtons[SubtitleTargetSize]; 0065 SubtitleIterator *m_iterator; 0066 int m_firstIndex; 0067 }; 0068 } 0069 #endif