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

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • dashboard
gradereferencewidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  Copyright 2014 Andreas Xavier
3  Copyright 2014 Inge Wallin
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  ***************************************************************************/
14 
15 
16 // Own
17 #include "gradereferencewidget.h"
18 
19 // Qt
20 #include <QDebug>
21 #include <QWidget>
22 #include <QPainter>
23 #include <QPen>
24 
25 // KDE
26 #include <klocalizedstring.h>
27 
28 // Parley
29 #include "barwidget.h" // for gradeColor^WglobalColors
30 
31 
32 GradeReferenceWidget::GradeReferenceWidget(QWidget *parent)
33  : QWidget(parent)
34 {
35 }
36 
37 void GradeReferenceWidget::paintEvent(QPaintEvent *)
38 {
39  QPainter painter(this);
40  const int legendWidth = this->width();
41  const int legendHeight = this->height();
42  const int legendOffsetY = 0;
43  const int legendOffsetX = (this->width() / 2) - (legendWidth / 2);;
44  const int gradeBarWidth = this->width()/8;
45  //const int alphaValueIncrement = 35;
46  QRect roundedRect(0 + legendOffsetX, 0 + legendOffsetY, legendWidth, legendHeight);
47  roundedRect.adjust(1, 1, -1, -1);
48  QPainterPath roundedPath;
49  roundedPath.addRoundedRect(roundedRect, 2.0, 2.0);
50 
51  for (int i = 7; i >= 0; --i) {
52  QRectF barElement(0 + legendOffsetX + (7 - i) * gradeBarWidth,
53  0 + legendOffsetY,
54  gradeBarWidth, legendHeight);
55  QPainterPath barElementPath;
56  barElementPath.addRect(barElement);
57  QPainterPath barElementIntersectedPath = roundedPath.intersected(barElementPath);
58  QColor color = globalColors.longTermColors[i];
59  painter.setBrush(QBrush(color));
60  painter.drawPath(barElementIntersectedPath);
61  }
62 }
QWidget
QPainterPath::addRoundedRect
void addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
QBrush
ConfidenceColors::longTermColors
QColor longTermColors[KV_MAX_GRADE+1]
Definition: utils.h:60
QWidget::width
int width() const
QRect
GradeReferenceWidget::paintEvent
void paintEvent(QPaintEvent *)
Definition: gradereferencewidget.cpp:37
QPainter
globalColors
ConfidenceColors globalColors
Definition: barwidget.cpp:34
QPainterPath::addRect
void addRect(const QRectF &rectangle)
QPainter::setBrush
void setBrush(const QBrush &brush)
QColor
GradeReferenceWidget::GradeReferenceWidget
GradeReferenceWidget(QWidget *parent=0)
Definition: gradereferencewidget.cpp:32
gradereferencewidget.h
QPainterPath
QPainter::drawPath
void drawPath(const QPainterPath &path)
QRectF
QRect::adjust
void adjust(int dx1, int dy1, int dx2, int dy2)
QPaintEvent
barwidget.h
QWidget::height
int height() const
QPainterPath::intersected
QPainterPath intersected(const QPainterPath &p) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 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
  • 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