Line data Source code
1 : #include "widget.hpp" 2 : 3 : namespace qtreports { 4 : namespace detail { 5 : 6 357 : Widget::Widget() : 7 : m_isBold( false ), 8 : m_rect( 0, 0, 0, 0 ), 9 357 : m_alignment( Qt::AlignmentFlag::AlignLeft | Qt::AlignmentFlag::AlignVCenter ) {} 10 : 11 357 : Widget::~Widget() {} 12 : 13 0 : void Widget::setPosition( const QPoint & pos ) { 14 0 : m_rect.setTopLeft( pos ); 15 0 : } 16 : 17 278 : void Widget::setX( int x ) { 18 278 : m_rect.setLeft( x ); 19 278 : } 20 : 21 278 : void Widget::setY( int y ) { 22 278 : m_rect.setTop( y ); 23 278 : } 24 : 25 0 : void Widget::setSize( const QSize & size ) { 26 0 : m_rect.setSize( size ); 27 0 : } 28 : 29 278 : void Widget::setWidth( int width ) { 30 278 : m_rect.setWidth( width ); 31 278 : } 32 : 33 348 : void Widget::setHeight( int height ) { 34 348 : m_rect.setHeight( height ); 35 348 : } 36 : 37 0 : void Widget::setRect( const QRect & rect ) { 38 0 : m_rect = rect; 39 0 : } 40 : /* 41 : void Widget::setStyle( const StylePtr & style ) { 42 : m_style = style; 43 : } 44 : */ 45 126 : void Widget::setStyle( const QString & style ) 46 : { 47 126 : m_style = style; 48 126 : } 49 : 50 139 : void Widget::setAlignment( Qt::Alignment alignment ) { 51 139 : m_alignment = alignment; 52 139 : } 53 : 54 2208 : Qt::Alignment Widget::getAlignment() { 55 2208 : return m_alignment; 56 : } 57 : 58 10 : const QPoint Widget::getPos() const { 59 10 : return m_rect.topLeft(); 60 : } 61 : 62 531 : int Widget::getX() const { 63 531 : return m_rect.x(); 64 : } 65 : 66 531 : int Widget::getY() const { 67 531 : return m_rect.y(); 68 : } 69 : 70 269 : const QSize Widget::getSize() const { 71 269 : return m_rect.size(); 72 : } 73 : 74 740 : int Widget::getWidth() const { 75 740 : return m_rect.width(); 76 : } 77 : 78 1103 : int Widget::getHeight() const { 79 1103 : return m_rect.height(); 80 : } 81 : 82 357 : const QRect Widget::getRect() const { 83 357 : return m_rect; 84 : } 85 : /* 86 : const StylePtr Widget::getStyle() const { 87 : return m_style; 88 : } 89 : */ 90 1 : const QString Widget::getStyle() const 91 : { 92 1 : return m_style; 93 : } 94 : 95 171 : bool Widget::isBold() const { 96 171 : return m_isBold; 97 : } 98 : 99 126 : void Widget::setBold( bool isBold ) { 100 126 : m_isBold = isBold; 101 126 : } 102 : 103 : 104 : /* 105 : bool Widget::setParameter( const QString & name, const QVariant & value ) { 106 : QString _x( "x" ), _y( "y" ), _w( "w" ), _h( "h" ), _style_name( "style_name" ); 107 : 108 : if( !value.isValid() ) { 109 : m_lastError = "Invalid parameter value"; 110 : return false; 111 : } 112 : 113 : if( isEquals( name, _x ) ) { 114 : if( value.type() != QVariant::Int ) { 115 : m_lastError = "Invalid type for this argument"; 116 : return false; 117 : } 118 : 119 : m_pos.setX( value.toInt() ); 120 : 121 : return true; 122 : } 123 : 124 : if( isEquals( name, _y ) ) { 125 : if( value.type() != QVariant::Int ) { 126 : m_lastError = "Invalid type for this argument"; 127 : return false; 128 : } 129 : 130 : m_pos.setY( value.toInt() ); 131 : 132 : return true; 133 : } 134 : 135 : if( isEquals( name, _w ) ) { 136 : if( value.type() != QVariant::Int ) { 137 : m_lastError = "Invalid type for this argument"; 138 : return false; 139 : } 140 : 141 : m_size.setWidth( value.toInt() ); 142 : return true; 143 : } 144 : 145 : if( isEquals( name, _h ) ) { 146 : if( value.type() != QVariant::Int ) { 147 : m_lastError = "Invalid type for this argument"; 148 : return false; 149 : } 150 : 151 : m_size.setHeight( value.toInt() ); 152 : return true; 153 : } 154 : 155 : if( isEquals( name, _style_name ) ) { 156 : if( value.type() != QVariant::String ) { 157 : m_lastError = "Invalid type for this argument"; 158 : return false; 159 : } 160 : 161 : m_styleName = value.toString(); 162 : 163 : return true; 164 : } 165 : 166 : return Object::setParameter( name, value ); 167 : } 168 : */ 169 : 170 : } 171 : }