• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • statistics
statisticsmodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "statisticsmodel.h"
17 
18 #include <KLocalizedString>
19 #include <QGradient>
20 
21 StatisticsModel::StatisticsModel(QObject * parent)
22  :ContainerModel(KEduVocContainer::Lesson, parent)
23 {
24  setSupportedDragActions(0);
25 }
26 
27 QVariant StatisticsModel::headerData(int section, Qt::Orientation orientation, int role) const
28 {
29  if (section >= 2) {
30  if(role == Qt::DisplayRole) {
31  return i18nc("Grade in language, table header", "Grade (%1)", m_doc->identifier(section-2).name());
32  }
33  }
34  return ContainerModel::headerData(section, orientation, role);
35 }
36 
37 QVariant StatisticsModel::data(const QModelIndex & index, int role) const
38 {
39  if (index.column() >= 2) {
40  KEduVocContainer *container = static_cast<KEduVocContainer*>(index.internalPointer());
41  switch (role) {
42  case TotalPercent: // Average grade
43  return container->averageGrade(index.column()-2, KEduVocContainer::Recursive);
44  case TotalCount:
45  return container->entryCount(KEduVocContainer::Recursive);
46  default:
47  if (role >= Qt::UserRole) {
48  return container->expressionsOfGrade(index.column()-2, role - Grade0, KEduVocContainer::Recursive);
49  }
50  }
51  }
52 
53  // checkboxes
54  if (index.column() == 0 && role == Qt::CheckStateRole) {
55  KEduVocContainer *container = static_cast<KEduVocContainer*>(index.internalPointer());
56  if (container->inPractice()) {
57  return Qt::Checked;
58  } else {
59  return Qt::Unchecked;
60  }
61  }
62 
63  return ContainerModel::data(index, role);
64 }
65 
66 
67 
68 Qt::ItemFlags StatisticsModel::flags(const QModelIndex & index) const
69 {
70  if (index.isValid()) {
71  if (index.column() == 0) {
72  return (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
73  }
74  return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
75  }
76  return 0;
77 }
78 
79 int StatisticsModel::columnCount(const QModelIndex & parent) const
80 {
81  Q_UNUSED(parent)
82  return m_doc->identifierCount() + 2;
83 }
84 
85 KEduVocContainer * StatisticsModel::rootContainer() const
86 {
87  if (!m_doc) {
88  return 0;
89  }
90  return m_doc->lesson();
91 }
92 
93 #include "statisticsmodel.moc"
94 
95 
StatisticsModel::data
virtual QVariant data(const QModelIndex &index, int role) const
Definition: statisticsmodel.cpp:37
StatisticsModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: statisticsmodel.cpp:27
StatisticsModel::TotalCount
Definition: statisticsmodel.h:30
QObject
StatisticsModel::StatisticsModel
StatisticsModel(QObject *parent=0)
Definition: statisticsmodel.cpp:21
StatisticsModel::columnCount
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: statisticsmodel.cpp:79
StatisticsModel::TotalPercent
Definition: statisticsmodel.h:29
Editor::ContainerModel
Model for the tree of containers (lessons, word types).
Definition: containermodel.h:33
Editor::BasicContainerModel::m_doc
KEduVocDocument * m_doc
Definition: basiccontainermodel.h:63
StatisticsModel::Grade0
Definition: statisticsmodel.h:31
statisticsmodel.h
StatisticsModel::rootContainer
KEduVocContainer * rootContainer() const
Definition: statisticsmodel.cpp:85
StatisticsModel::flags
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Definition: statisticsmodel.cpp:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal