~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to words/part/dockers/KWStatisticsWidget.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-10-23 21:09:16 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121023210916-m82w6zxnxhaxz7va
Tags: 1:2.5.90-0ubuntu1
* New upstream alpha release (LP: #1070436)
  - Add libkactivities-dev and libopenimageio-dev to build-depends
  - Add kubuntu_build_calligraactive.diff to build calligraactive by default
  - Add package for calligraauthor and move files that are shared between
    calligrawords and calligraauthor to calligrawords-common
* Document the patches
* Remove numbers from patches so they follow the same naming scheme as
  the rest of our patches.
* calligra-data breaks replaces krita-data (<< 1:2.5.3) (LP: #1071686)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
 * Copyright (C) 2005, 2007 Thomas Zander <zander@kde.org>
 
3
 * Copyright (C) 2012 Shreya Pandit <shreya@shreyapandit.com>
 
4
 * Copyright (C) 2012 Inge Wallin <inge@lysator.liu.se>
 
5
 * 
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public License
 
17
 * along with this library; see the file COPYING.LIB.  If not, write to
 
18
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
 * Boston, MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef KWSTATISTICSWIDGET_H
 
23
#define KWSTATISTICSWIDGET_H
 
24
 
 
25
#include <QWidget>
 
26
#include <QToolButton>
 
27
#include <QLabel>
 
28
 
 
29
#include <kglobal.h>
 
30
 
 
31
// FIXME: Don't cross include
 
32
//#include "KWStatisticsDocker.h"
 
33
#include "StatisticsPreferencesPopup.h"
 
34
 
 
35
class QTimer;
 
36
class QTextDocument;
 
37
class QToolButton;
 
38
class KConfigGroup;
 
39
class KoCanvasResourceManager;
 
40
class KoSelection;
 
41
class KWDocument;
 
42
class StatisticsPreferencesPopup;
 
43
 
 
44
/** KWStatisticswidget shows text statistics about a text document.
 
45
 *
 
46
 * In addition to being a widget, it also contains the statistics data
 
47
 * itself and functions to update this data.
 
48
 *
 
49
 * FIXME: The pure statistics part should be separated from the
 
50
 *        widget, e.g. to a QAbstractListModel so that it could also
 
51
 *        be used from a QML based interface.
 
52
 */ 
 
53
 
 
54
class KWStatisticsWidget : public QWidget
 
55
{
 
56
    Q_OBJECT
 
57
public:
 
58
    KWStatisticsWidget(KoCanvasResourceManager *provider, KWDocument *m_document,
 
59
                       KoSelection *selection = 0, QWidget *parent = 0);
 
60
 
 
61
    virtual ~KWStatisticsWidget();
 
62
    void updateDataUi();
 
63
    void initUi();
 
64
    friend class KWStatisticsDocker;
 
65
    friend class StatisticsPreferencesPopup;
 
66
    
 
67
public slots:
 
68
    void wordsDisplayChanged(int);
 
69
    void sentencesDisplayChanged(int);
 
70
    void linesDisplayChanged(int);
 
71
    void syllablesDisplayChanged(int);
 
72
    void charspaceDisplayChanged(int);
 
73
    void charnospaceDisplayChanged(int);
 
74
    void eastDisplayChanged(int);
 
75
    void fleschDisplayChanged(int);
 
76
 
 
77
    void updateData();
 
78
    void selectionChanged();
 
79
 
 
80
private:
 
81
    int countCJKChars(const QString &text);
 
82
 
 
83
    // Labels, e.g. "Words:"
 
84
    QLabel *m_wordsLabel;
 
85
    QLabel *m_sentencesLabel;
 
86
    QLabel *m_syllablesLabel;
 
87
    QLabel *m_spacesLabel;
 
88
    QLabel *m_fleschLabel;
 
89
    QLabel *m_cjkcharsLabel;
 
90
    QLabel *m_nospacesLabel;
 
91
    QLabel *m_linesLabel;
 
92
 
 
93
    // The values.
 
94
    QLabel *m_countWords;
 
95
    QLabel *m_countSentences;
 
96
    QLabel *m_countSyllables;
 
97
    QLabel *m_countSpaces;
 
98
    QLabel *m_countFlesch;
 
99
    QLabel *m_countCjkchars;
 
100
    QLabel *m_countNospaces;
 
101
    QLabel *m_countLines;
 
102
 
 
103
    KoCanvasResourceManager *m_resourceManager;
 
104
    KoSelection *m_selection;
 
105
    KWDocument *m_document;
 
106
    QTextDocument *m_textDocument;
 
107
    QTimer *m_timer;
 
108
 
 
109
    QToolButton *m_preferencesButton;
 
110
    StatisticsPreferencesPopup *m_menu;
 
111
 
 
112
    // The actual data.
 
113
    long m_charsWithSpace;
 
114
    long m_charsWithoutSpace;
 
115
    long m_words;
 
116
    long m_sentences;
 
117
    long m_lines;
 
118
    long m_syllables;
 
119
    long m_paragraphs;
 
120
    long m_cjkChars;
 
121
};
 
122
 
 
123
#endif // KWSTATISTICSWIDGET_H