9#include <KChartPosition.h>
12#include "KChartMath_p.h"
27static const char * staticPositionNames[] = {
28 QT_TRANSLATE_NOOP(
"Position",
"Unknown Position"),
29 QT_TRANSLATE_NOOP(
"Position",
"Center"),
30 QT_TRANSLATE_NOOP(
"Position",
"NorthWest"),
31 QT_TRANSLATE_NOOP(
"Position",
"North"),
32 QT_TRANSLATE_NOOP(
"Position",
"NorthEast"),
33 QT_TRANSLATE_NOOP(
"Position",
"East"),
34 QT_TRANSLATE_NOOP(
"Position",
"SouthEast"),
35 QT_TRANSLATE_NOOP(
"Position",
"South"),
36 QT_TRANSLATE_NOOP(
"Position",
"SouthWest"),
37 QT_TRANSLATE_NOOP(
"Position",
"West"),
38 QT_TRANSLATE_NOOP(
"Position",
"Floating")
46static Position staticPositionUnknown =
Position( KChartEnums::PositionUnknown );
47static Position staticPositionCenter =
Position( KChartEnums::PositionCenter );
48static Position staticPositionNorthWest =
Position( KChartEnums::PositionNorthWest );
50static Position staticPositionNorthEast =
Position( KChartEnums::PositionNorthEast );
52static Position staticPositionSouthEast =
Position( KChartEnums::PositionSouthEast );
54static Position staticPositionSouthWest =
Position( KChartEnums::PositionSouthWest );
56static Position staticPositionFloating =
Position( KChartEnums::PositionFloating );
58static const int maxPositionValue = 10;
62const Position& Position::Unknown = staticPositionUnknown;
63const Position& Position::Center = staticPositionCenter;
64const Position& Position::NorthWest = staticPositionNorthWest;
65const Position& Position::North = staticPositionNorth;
66const Position& Position::NorthEast = staticPositionNorthEast;
67const Position& Position::East = staticPositionEast;
68const Position& Position::SouthEast = staticPositionSouthEast;
69const Position& Position::South = staticPositionSouth;
70const Position& Position::SouthWest = staticPositionSouthWest;
71const Position& Position::West = staticPositionWest;
72const Position& Position::Floating = staticPositionFloating;
87 assert( 0 <=
value ); assert(
value <= maxPositionValue );
116bool Position::isUnknown()
const
118 return m_value == Position::Unknown.
value();
121bool Position::isWestSide()
const
123 return m_value == Position::SouthWest.
value() ||
124 m_value == Position::West.
value() ||
125 m_value == Position::NorthWest.
value();
127bool Position::isNorthSide()
const
129 return m_value == Position::NorthWest.
value() ||
130 m_value == Position::North.
value() ||
131 m_value == Position::NorthEast.
value();
133bool Position::isEastSide()
const
135 return m_value == Position::NorthEast.
value() ||
136 m_value == Position::East.
value() ||
137 m_value == Position::SouthEast.
value();
139bool Position::isSouthSide()
const
141 return m_value == Position::SouthWest.
value() ||
142 m_value == Position::South.
value() ||
143 m_value == Position::SouthEast.
value();
146bool Position::isCorner()
const
148 return m_value == Position::NorthWest.
value() ||
149 m_value == Position::NorthEast.
value() ||
150 m_value == Position::SouthEast.
value() ||
151 m_value == Position::SouthWest.
value();
153bool Position::isPole()
const
155 return m_value == Position::North.
value() ||
156 m_value == Position::South.
value();
159bool Position::isFloating()
const
161 return m_value == Position::Floating.
value();
169 return staticPositionNames[m_value];
177 return tr(staticPositionNames[m_value]);
191 const int start = ( options & IncludeCenter ) ? 1 : 2;
192 const int end = ( options & IncludeFloating ) ? maxPositionValue : maxPositionValue-1;
193 for (
int i=
start; i<=end; ++i)
194 list.
append( staticPositionNames[i] );
208 const int start = ( options & IncludeCenter ) ? 1 : 2;
209 const int end = ( options & IncludeFloating ) ? maxPositionValue : maxPositionValue-1;
210 for (
int i=
start; i<=end; ++i)
215Position Position::fromName(
const char * name)
217 for (
int i=1; i<=maxPositionValue; ++i)
218 if ( !qstricmp(
name, staticPositionNames[i] ) )
224 return fromName(
name.data() );
227bool Position::operator==(
const Position& r )
const
233bool Position::operator==(
int value_ )
const
235 return (
value() == value_ );
239#if !defined(QT_NO_DEBUG_STREAM)
242 dbg <<
"KChart::Position("
Definition of global enums.
Project global class providing some enums needed both by KChartParams and by KChartCustomBox.
PositionValue
Numerical values of the static KChart::Position instances, for using a Position::value() with a switc...
Defines a position, using compass terminology.
QString printableName() const
Returns a translated string, corresponding to this Position.
KChartEnums::PositionValue value() const
Returns an integer value corresponding to this Position.
Position()
Default constructor.
static QList< QByteArray > names(Options options=Options(IncludeCenter|IncludeFloating))
Returns a list of all string, corresponding to the pre-defined positions.
static QStringList printableNames(Options options=Options(IncludeCenter|IncludeFloating))
Returns a list of all translated string, corresponding to the pre-defined positions.
const char * name() const
Returns a non-translated string in English language, corresponding to this Position.
Q_SCRIPTABLE Q_NOREPLY void start()
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
void append(QList< T > &&value)