Changeset View
Changeset View
Standalone View
Standalone View
words/part/dockers/KWStatisticsWidget.cpp
Show All 32 Lines | |||||
33 | #include <KoShape.h> | 33 | #include <KoShape.h> | ||
34 | #include <KoIcon.h> | 34 | #include <KoIcon.h> | ||
35 | #include <KoTextDocumentLayout.h> | 35 | #include <KoTextDocumentLayout.h> | ||
36 | 36 | | |||
37 | #include <KSharedConfig> | 37 | #include <KSharedConfig> | ||
38 | #include <kconfiggroup.h> | 38 | #include <kconfiggroup.h> | ||
39 | 39 | | |||
40 | #include <QLocale> | 40 | #include <QLocale> | ||
41 | #include <QPointer> | ||||
41 | #include <QTextLayout> | 42 | #include <QTextLayout> | ||
42 | #include <QTextDocument> | 43 | #include <QTextDocument> | ||
43 | #include <QTextBlock> | 44 | #include <QTextBlock> | ||
44 | #include <QTimer> | 45 | #include <QTimer> | ||
45 | 46 | | |||
46 | KWStatisticsWidget::KWStatisticsWidget(QWidget *parent, bool shortVersion) | 47 | KWStatisticsWidget::KWStatisticsWidget(QWidget *parent, bool shortVersion) | ||
47 | : QWidget(parent), | 48 | : QWidget(parent), | ||
48 | m_resourceManager(0), | 49 | m_resourceManager(0), | ||
▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Line(s) | 303 | const QStringList add_syl_regexp { | |||
306 | QStringLiteral("ism$"), | 307 | QStringLiteral("ism$"), | ||
307 | QStringLiteral("[^l]lien"), | 308 | QStringLiteral("[^l]lien"), | ||
308 | QStringLiteral("^coa[dglx]."), | 309 | QStringLiteral("^coa[dglx]."), | ||
309 | QStringLiteral("[^gq]ua[^auieo]"), | 310 | QStringLiteral("[^gq]ua[^auieo]"), | ||
310 | QStringLiteral("dnt$") | 311 | QStringLiteral("dnt$") | ||
311 | }; | 312 | }; | ||
312 | 313 | | |||
313 | foreach (KWFrameSet *fs, m_document->frameSets()) { | 314 | foreach (KWFrameSet *fs, m_document->frameSets()) { | ||
314 | KWTextFrameSet *tfs = dynamic_cast<KWTextFrameSet*>(fs); | 315 | QPointer<KWTextFrameSet> tfs = dynamic_cast<KWTextFrameSet*>(fs); | ||
315 | if (tfs == 0) continue; | 316 | if (tfs == 0) continue; | ||
316 | 317 | | |||
317 | QTextDocument *doc = tfs->document(); | 318 | QPointer<QTextDocument> doc = tfs->document(); | ||
318 | QTextBlock block = doc->begin(); | 319 | QTextBlock block = doc->begin(); | ||
319 | while (block.isValid()) { | 320 | while (block.isValid()) { | ||
320 | // Don't be so heavy on large documents... | 321 | // Don't be so heavy on large documents... | ||
321 | qApp->processEvents(); | 322 | qApp->processEvents(); | ||
323 | if(!tfs || !doc) | ||||
324 | return; | ||||
322 | m_paragraphs += 1; | 325 | m_paragraphs += 1; | ||
323 | m_charsWithSpace += block.text().length(); | 326 | m_charsWithSpace += block.text().length(); | ||
324 | m_charsWithoutSpace += block.text().length() - block.text().count(QRegExp("\\s")); | 327 | m_charsWithoutSpace += block.text().length() - block.text().count(QRegExp("\\s")); | ||
325 | if (block.layout()) { | 328 | if (block.layout()) { | ||
326 | m_lines += block.layout()->lineCount(); | 329 | m_lines += block.layout()->lineCount(); | ||
327 | } | 330 | } | ||
328 | m_cjkChars += countCJKChars(block.text()); | 331 | m_cjkChars += countCJKChars(block.text()); | ||
329 | 332 | | |||
▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines |