File indexing completed on 2024-06-16 04:38:28

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 SPELLER_H
0009 #define SPELLER_H
0010 
0011 #include "core/subtitle.h"
0012 #include "core/subtitleline.h"
0013 
0014 #include <QExplicitlySharedDataPointer>
0015 #include <QObject>
0016 
0017 namespace Sonnet {
0018 class Dialog;
0019 }
0020 namespace SubtitleComposer {
0021 class SubtitleIterator;
0022 
0023 class Speller : public QObject
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit Speller(QWidget *parent = 0);
0029     virtual ~Speller();
0030 
0031     QWidget * parentWidget();
0032 
0033 public slots:
0034     void setSubtitle(Subtitle *subtitle = 0);
0035     void setTranslationMode(bool enabled);
0036     void setUseTranslation(bool useTranslation);
0037 
0038     void spellCheck(int currentIndex);
0039 
0040 signals:
0041     void misspelled(SubtitleLine *line, bool primary, int startIndex, int endIndex);
0042 
0043 private:
0044     void invalidate();
0045     bool advance();
0046     void updateBuffer();
0047 
0048 private slots:
0049     void onBufferDone();
0050     void onMisspelling(const QString &before, int pos);
0051     void onCorrected(const QString &before, int pos, const QString &after);
0052 
0053     void onConfigChanged();
0054 
0055 private:
0056     QExplicitlySharedDataPointer<const Subtitle> m_subtitle;
0057     bool m_translationMode;
0058     bool m_useTranslation;
0059 
0060     Sonnet::Dialog *m_sonnetDialog;
0061     SubtitleIterator *m_iterator;
0062     int m_firstIndex;
0063 };
0064 }
0065 #endif