KTextEditor

wordcounter.h
1/*
2 SPDX-FileCopyrightText: 2015 Michal Humpula <michal.humpula@hudrydum.cz>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef WORDCOUNTER_H
8#define WORDCOUNTER_H
9
10#include <QObject>
11#include <QString>
12#include <QTimer>
13#include <vector>
14
15namespace KTextEditor
16{
17class Document;
18class View;
19class ViewPrivate;
20class Range;
21}
22
23class WordCounter : public QObject
24{
26
27public:
28 explicit WordCounter(KTextEditor::ViewPrivate *view);
29
31 void changed(int wordsInDocument, int wordsInSelection, int charsInDocument, int charsInSelection);
32
33private Q_SLOTS:
34 void textInserted(KTextEditor::Document *document, KTextEditor::Range range);
35 void textRemoved(KTextEditor::Document *document, KTextEditor::Range range, const QString &oldText);
36 void recalculate(KTextEditor::Document *document);
37 void selectionChanged(KTextEditor::View *view);
38 void recalculateLines();
39
40private:
41 std::vector<int> m_countByLine;
42 int m_wordsInDocument, m_wordsInSelection;
43 int m_charsInDocument, m_charsInSelection;
44 QTimer m_timer;
45 int m_startRecalculationFrom;
46 KTextEditor::Document *m_document;
47};
48
49#endif
A KParts derived class representing a text document.
Definition document.h:284
An object representing a section of text, from one Cursor to another.
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.