summaryrefslogtreecommitdiffstats
path: root/libkdchart/KDChartEnums.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-04 22:38:03 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-04 22:38:03 +0000
commitdadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (patch)
tree99e72842fe687baea16376a147619b6048d7e441 /libkdchart/KDChartEnums.cpp
downloadkmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.tar.gz
kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.zip
Added kmymoney
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdchart/KDChartEnums.cpp')
-rw-r--r--libkdchart/KDChartEnums.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/libkdchart/KDChartEnums.cpp b/libkdchart/KDChartEnums.cpp
new file mode 100644
index 0000000..b94f16d
--- /dev/null
+++ b/libkdchart/KDChartEnums.cpp
@@ -0,0 +1,98 @@
+#include "KDChartEnums.h"
+
+QString KDChartEnums::positionFlagToString( PositionFlag type )
+{
+ switch( type ) {
+ case PosTopLeft:
+ return "TopLeft";
+ case PosTopCenter:
+ return "TopCenter";
+ case PosTopRight:
+ return "TopRight";
+ case PosCenterLeft:
+ return "CenterLeft";
+ case PosCenter:
+ return "Center";
+ case PosCenterRight:
+ return "CenterRight";
+ case PosBottomLeft:
+ return "BottomLeft";
+ case PosBottomCenter:
+ return "BottomCenter";
+ case PosBottomRight:
+ return "BottomRight";
+ default: // should not happen
+ qDebug( "Unknown content position" );
+ return "TopLeft";
+ }
+}
+
+KDChartEnums::PositionFlag KDChartEnums::stringToPositionFlag( const QString& string )
+{
+ if( string == "TopLeft" )
+ return PosTopLeft;
+ else if( string == "TopCenter" )
+ return PosTopCenter;
+ else if( string == "TopRight" )
+ return PosTopRight;
+ else if( string == "CenterLeft" )
+ return PosCenterLeft;
+ else if( string == "Center" )
+ return PosCenter;
+ else if( string == "CenterRight" )
+ return PosCenterRight;
+ else if( string == "BottomLeft" )
+ return PosBottomLeft;
+ else if( string == "BottomCenter" )
+ return PosBottomCenter;
+ else if( string == "BottomRight" )
+ return PosBottomRight;
+ else // default, should not happen
+ return PosTopLeft;
+}
+
+QPoint KDChartEnums::positionFlagToPoint( const QRect& rect,
+ PositionFlag pos )
+{
+ QPoint pt;
+ if( rect.isValid() ) {
+ switch( pos ) {
+ case KDChartEnums::PosTopLeft:
+ pt = rect.topLeft();
+ break;
+ case KDChartEnums::PosTopCenter:
+ pt.setY( rect.top() );
+ pt.setX( rect.center().x() );
+ break;
+ case KDChartEnums::PosTopRight:
+ pt = rect.topRight();
+ break;
+ case KDChartEnums::PosCenterLeft:
+ pt.setY( rect.center().y() );
+ pt.setX( rect.left() );
+ break;
+ case KDChartEnums::PosCenter:
+ pt = rect.center();
+ break;
+ case KDChartEnums::PosCenterRight:
+ pt.setY( rect.center().y() );
+ pt.setX( rect.right() );
+ break;
+ case KDChartEnums::PosBottomLeft:
+ pt = rect.bottomLeft();
+ break;
+ case KDChartEnums::PosBottomCenter:
+ pt.setY( rect.bottom() );
+ pt.setX( rect.center().x() );
+ break;
+ case KDChartEnums::PosBottomRight:
+ pt = rect.bottomRight();
+ break;
+ }
+ }
+ return pt;
+}
+
+#ifndef KDCHART_MASTER_CVS
+#include "KDChartEnums.moc"
+#endif