• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmacomponents
qrangemodel_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the Qt Components project on Qt Labs.
8 **
9 ** No Commercial Usage
10 ** This file contains pre-release code and may not be distributed.
11 ** You may use this file in accordance with the terms and conditions contained
12 ** in the Technology Preview License Agreement accompanying this package.
13 **
14 ** GNU Lesser General Public License Usage
15 ** Alternatively, this file may be used under the terms of the GNU Lesser
16 ** General Public License version 2.1 as published by the Free Software
17 ** Foundation and appearing in the file LICENSE.LGPL included in the
18 ** packaging of this file. Please review the following information to
19 ** ensure the GNU Lesser General Public License version 2.1 requirements
20 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
21 **
22 ** If you have questions regarding the use of this file, please contact
23 ** Nokia at qt-info@nokia.com.
24 **
25 ****************************************************************************/
26 
27 #ifndef QRANGEMODEL_P_H
28 #define QRANGEMODEL_P_H
29 
30 //
31 // W A R N I N G
32 // -------------
33 //
34 // This file is not part of the Qt Components API. It exists purely as an
35 // implementation detail. This header file may change from version to
36 // version without notice, or even be removed.
37 //
38 // We mean it.
39 //
40 
41 #include "qrangemodel.h"
42 
43 namespace Plasma
44 {
45 
46 class QRangeModelPrivate
47 {
48  Q_DECLARE_PUBLIC(QRangeModel)
49 public:
50  QRangeModelPrivate(QRangeModel *qq);
51  virtual ~QRangeModelPrivate();
52 
53  void init();
54 
55  qreal posatmin, posatmax;
56  qreal minimum, maximum, stepSize, pos, value;
57 
58  uint inverted : 1;
59 
60  QRangeModel *q_ptr;
61 
62  inline qreal effectivePosAtMin() const {
63  return inverted ? posatmax : posatmin;
64  }
65 
66  inline qreal effectivePosAtMax() const {
67  return inverted ? posatmin : posatmax;
68  }
69 
70  inline qreal equivalentPosition(qreal value) const {
71  // Return absolute position from absolute value
72  const qreal valueRange = maximum - minimum;
73  if (valueRange == 0)
74  return effectivePosAtMin();
75 
76  const qreal scale = (effectivePosAtMax() - effectivePosAtMin()) / valueRange;
77  return (value - minimum) * scale + effectivePosAtMin();
78  }
79 
80  inline qreal equivalentValue(qreal pos) const {
81  // Return absolute value from absolute position
82  const qreal posRange = effectivePosAtMax() - effectivePosAtMin();
83  if (posRange == 0)
84  return minimum;
85 
86  const qreal scale = (maximum - minimum) / posRange;
87  return (pos - effectivePosAtMin()) * scale + minimum;
88  }
89 
90  qreal publicPosition(qreal position) const;
91  qreal publicValue(qreal value) const;
92  void emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition);
93 };
94 
95 } // Plasma namespace
96 
97 #endif // QRANGEMODEL_P_H
Plasma::QRangeModelPrivate::value
qreal value
Definition: qrangemodel_p.h:56
Plasma::QRangeModelPrivate::equivalentPosition
qreal equivalentPosition(qreal value) const
Definition: qrangemodel_p.h:70
Plasma::QRangeModelPrivate
Definition: qrangemodel_p.h:46
Plasma::QRangeModelPrivate::pos
qreal pos
Definition: qrangemodel_p.h:56
Plasma::QRangeModelPrivate::emitValueAndPositionIfChanged
void emitValueAndPositionIfChanged(const qreal oldValue, const qreal oldPosition)
Definition: qrangemodel.cpp:167
Plasma::QRangeModelPrivate::equivalentValue
qreal equivalentValue(qreal pos) const
Definition: qrangemodel_p.h:80
Plasma::QRangeModelPrivate::stepSize
qreal stepSize
Definition: qrangemodel_p.h:56
Plasma::QRangeModelPrivate::inverted
uint inverted
Definition: qrangemodel_p.h:58
Plasma::QRangeModelPrivate::init
void init()
Definition: qrangemodel.cpp:79
Plasma::QRangeModelPrivate::effectivePosAtMin
qreal effectivePosAtMin() const
Definition: qrangemodel_p.h:62
Plasma::QRangeModelPrivate::QRangeModelPrivate
QRangeModelPrivate(QRangeModel *qq)
Definition: qrangemodel.cpp:70
Plasma::QRangeModelPrivate::publicValue
qreal publicValue(qreal value) const
Definition: qrangemodel.cpp:139
Plasma::QRangeModelPrivate::minimum
qreal minimum
Definition: qrangemodel_p.h:56
qrangemodel.h
Plasma::QRangeModel
Definition: qrangemodel.h:51
Plasma::QRangeModelPrivate::q_ptr
QRangeModel * q_ptr
Definition: qrangemodel_p.h:60
Plasma::QRangeModelPrivate::~QRangeModelPrivate
virtual ~QRangeModelPrivate()
Definition: qrangemodel.cpp:75
Plasma::QRangeModelPrivate::posatmax
qreal posatmax
Definition: qrangemodel_p.h:55
Plasma::QRangeModelPrivate::maximum
qreal maximum
Definition: qrangemodel_p.h:56
Plasma::QRangeModelPrivate::publicPosition
qreal publicPosition(qreal position) const
Definition: qrangemodel.cpp:98
Plasma::QRangeModelPrivate::effectivePosAtMax
qreal effectivePosAtMax() const
Definition: qrangemodel_p.h:66
Plasma::QRangeModelPrivate::posatmin
qreal posatmin
Definition: qrangemodel_p.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaComponents

Skip menu "PlasmaComponents"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

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