summaryrefslogtreecommitdiffstats
path: root/kugar/lib/mreportdetail.cpp
blob: 6fa4bc530ace47348c7f396ffc4112eb1325810f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************************************
             mreportdetail.cpp  -  Kugar report detail section
             -------------------
   begin     : Mon Aug 23 1999
   copyright : (C) 1999 by Mutiny Bay Software
   email     : info@mutinybaysoftware.com
***************************************************************************/

#include "mreportdetail.h"

namespace Kugar
{

/** Constructor */
MReportDetail::MReportDetail() : MReportSection()
{
    // Set the label list to AutoDelete
    fields.setAutoDelete( true );
}

/** Copy constructor */
MReportDetail::MReportDetail( const MReportDetail& mReportDetail ) : MReportSection( ( MReportSection & ) mReportDetail )
{
    copy( &mReportDetail );
}

/** Assignment operator */
MReportDetail MReportDetail::operator=( const MReportDetail& mReportDetail )
{
    if ( &mReportDetail == this )
        return * this;

    // Copy the derived class's data
    copy( &mReportDetail );

    // Copy the base class's data
    ( ( MReportSection & ) * this ) = mReportDetail;

    return *this;
}

/** Destructor */
MReportDetail::~MReportDetail()
{
    clear();
}

/** Frees all resources allocated by the report section */
void MReportDetail::clear()
{
    // Free the base resources
    clearBase();

    // Clear the field collection
    fields.clear();
}

void MReportDetail::setRepeat( bool b )
{
    repeat = b;
}

bool MReportDetail::getRepeat() const
{
    return repeat;
}

/** Draws the detail section to the selected painter & x/y-offsets */
void MReportDetail::draw( QPainter* p, int xoffset, int yoffset )
{
    MFieldObject * field;

    // Set the offsets
    int xcalc = xoffset;
    int ycalc = yoffset;

    // Draw the base objects
    drawObjects( p, xoffset, yoffset );

    // Draw the field collection
    for ( field = fields.first(); field != 0; field = fields.next() )
    {
        field->draw( p, xcalc, ycalc );
    }
}

/** Adds a new field object to the section's field collection */
void MReportDetail::addField( MFieldObject* field )
{
    fields.append( field );
}

/** Sets the data for the field at the specified index */
void MReportDetail::setFieldData( int idx, QString data )
{
    MFieldObject * field = fields.at( idx );

    field->setText( data );
}

/** Returns the number of fields in the detail section */
int MReportDetail::getFieldCount()
{
    return fields.count();
}

/** Returns the name of the bound field for field object at the given index */
QString MReportDetail::getFieldName( int idx )
{
    MFieldObject * field = fields.at( idx );

    return field->getFieldName();
}

/** Copies member data from one object to another.
      Used by the copy constructor and assignment operator */
void MReportDetail::copy( const MReportDetail* mReportDetail )
{
    // Copy the field list
    fields = mReportDetail->fields;
}

}