Ejemplo n.º 1
0
QwtDoubleRect Plot::boundingRect ()
{
QMapIterator<int, QwtPlotCurve *> it = d_curves.begin();
QwtPlotCurve *c = (QwtPlotCurve *)it.data();

double minX = c->minXValue();
double minY = c->minYValue();
double maxX = c->maxXValue();
double maxY = c->maxYValue();

it++;

for (it; it != d_curves.end(); ++it) 
	{
	QwtPlotCurve *c = (QwtPlotCurve *)it.data();
	if (!c)
		continue;

	minX = (c->minXValue() < minX) ? c->minXValue() : minX;
	maxX = (c->maxXValue() > maxX) ? c->maxXValue() : maxX;
	minY = (c->minYValue() < minY) ? c->minYValue() : minY;
	maxY = (c->maxYValue() > maxY) ? c->maxYValue() : maxY;
	}

QwtDoubleRect r;
r.setLeft(minX);
r.setRight(maxX);
r.setTop(minY);
r.setBottom(maxY);
return r;
}
Ejemplo n.º 2
0
void * KFileItem::extraData( const void *key )
{
    QMapIterator<const void*,void*> it = m_extra.find( key );
    if ( it != m_extra.end() )
        return it.data();
    return 0L;
}
Ejemplo n.º 3
0
int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)
{
QwtScaleMap map[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
	map[axis] = canvasMap(axis);

double dmin = 1.0e10;
int key = -1;
for (QMapIterator<int, QwtPlotCurve *> it = d_curves.begin(); it != d_curves.end(); ++it ) 
	{
	QwtPlotCurve *c = (QwtPlotCurve *)it.data();
	if (!c)
		continue;

	for (int i=0; i<c->dataSize(); i++)
		{
		double cx = map[c->xAxis()].xTransform(c->x(i)) - double(xpos);
		double cy = map[c->yAxis()].xTransform(c->y(i)) - double(ypos);
		double f = qwtSqr(cx) + qwtSqr(cy);
		if (f < dmin)
			{
			dmin = f;
			key = it.key();
			point = i;
			}
		 }
	}
dist = int(sqrt(dmin));
return key;
}
Ejemplo n.º 4
0
bool tGraph::drawPoints() {
    //return _drawPoints;

    QMapIterator<int, ORStyleData> mit = _setStyle.begin();
    for( ; mit != _setStyle.end(); ++mit) {
        if(mit.data().point) return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 5
0
void KNotify::reconfigure()
{
    kapp->config()->reparseConfiguration();
    loadConfig();

    // clear loaded config files
    d->globalConfig->reparseConfiguration();
    for(QMapIterator< QString, KConfig * > it = d->configs.begin(); it != d->configs.end(); ++it)
        delete it.data();
    d->configs.clear();
}
Ejemplo n.º 6
0
void
QueueManager::addQueuedItem( PlaylistItem *item )
{
    Playlist *pl = Playlist::instance();
    if( !pl ) return; //should never happen

    const int index = pl->m_nextTracks.findRef( item );

    QListViewItem *after;
    if( !index ) after = 0;
    else
    {
        int find = m_listview->childCount();
        if( index - 1 <= find )
            find = index - 1;
        after = m_listview->itemAtIndex( find );
    }

    QValueList<PlaylistItem*>         current = m_map.values();
    QValueListIterator<PlaylistItem*> newItem = current.find( item );

    QString title = i18n("%1 - %2").arg( item->artist(), item->title() );

    if( newItem == current.end() ) //avoid duplication
    {
        after = new QueueItem( m_listview, after, title );
        m_map[ after ] = item;
    }
    else //track is in the queue, remove it.
    {
        QListViewItem *removableItem = m_listview->findItem( title, 0 );

        if( removableItem )
        {
            //Remove the key from the map, so we can re-queue the item
            QMapIterator<QListViewItem*, PlaylistItem*> end(  m_map.end() );
            for( QMapIterator<QListViewItem*, PlaylistItem*> it = m_map.begin(); it != end; ++it )
            {
                if( it.data() == item )
                {
                    m_map.remove( it );

                    //Remove the item from the queuelist
                    m_listview->takeItem( removableItem );
                    delete removableItem;
                    return;
                }
            }
        }
    }

}
Ejemplo n.º 7
0
void
QDialogButtons::handleClicked()
{
    const QObject *s = sender();
    if(!s)
	return;

    for(QMapIterator<QDialogButtons::Button, QWidget *> it = d->buttons.begin(); it != d->buttons.end(); ++it) {
	if(it.data() == s) {
	    emit clicked((QDialogButtons::Button)it.key());
	    switch(it.key()) {
	    case Retry:
		emit retryClicked();
		break;
	    case Ignore:
		emit ignoreClicked();
		break;
	    case Abort:
		emit abortClicked();
		break;
	    case All:
		emit allClicked();
		break;
	    case Accept:
		emit acceptClicked();
		break;
	    case Reject:
		emit rejectClicked();
		break;
	    case Apply:
		emit applyClicked();
		break;
	    case Help:
		emit helpClicked();
		break;
	    default:
		break;
	    }
	    return;
	}
    }
}
Ejemplo n.º 8
0
/*! This function updates .ini file in two stages. It copies original .ini file
  into temporary one line by line, replacing/deleting/adding lines as necessary.
  Then it copies temporary file into original one and deletes temporary file.
*/
bool TEIniFile::update()
{
  close();
	if (!f.open(IO_ReadWrite)) return false;
  QString tempfn=f.name()+".tmp";
  QFile tempf(tempfn);
  if (!tempf.open(IO_ReadWrite | IO_Truncate)) return false;
  QTextStream tsorg;
  bool skipsec=false;

  tsorg.setEncoding(QTextStream::UnicodeUTF8);
  tsorg.setDevice(&f);
	ts.setDevice(&tempf); // writeXXX function hardwired to write into ts. So we set it appropriatedly.
	// prepare
  QMap<QString,bool> secProcd, valueProcd; // processedp flag's maps
  QMapIterator<QString,type_ValueList> it1;
  for(it1=SectionList.begin();it1!=SectionList.end();++it1)
  {
    secProcd[it1.key()]=false;
  }
	// scan form sections
	QString line, sec;
	type_Processing pr = P_NONE;	// nothing done yet
	type_ValueList ValueList;

	while (!((line = tsorg.readLine()).isNull())) {
		if ((pr == P_NONE) || (pr == P_SECTION)) {
			// trim line
			line = line.stripWhiteSpace();
			// skip if empty
			if (line.isEmpty())
      {
        writeBreak();
        continue;
      }
			// skip if comment
			if (line.startsWith("#"))
      {
        writeComment(line.mid(1));
        continue;
      }
			// check if section
			if (line.startsWith("[") && line.endsWith("]")) {
				if (pr == P_SECTION) {
					// update previous section
          // write new values
          type_ValueList::iterator it;
          type_ValueList & curSec=SectionList[sec];
          type_ValueList & curSecDef=SectionListDef[sec];
          for(it=curSec.begin();it!=curSec.end();++it)
          {
            if (!valueProcd[it.key()])
            { // this value was not processed yet, hence it's new or just default.
              if (curSecDef.find(it.key())==curSecDef.end() || curSecDef[it.key()]!=it.data()) // if it equals default value, skip it.
                ts << it.key() << "\t" << it.data() << "\n";
              valueProcd[it.key()]=true; // it is for completeness' sake, so it don't really necessary (yet?).
            }
          }
					secProcd[sec]=true;
				}
				// section found!
        valueProcd.clear(); // get ready for next section
				pr = P_SECTION;
				sec = line.mid(1, line.length()-2).stripWhiteSpace();
        writeSection(sec);
        skipsec=SectionList.find(sec)==SectionList.end() || secProcd[sec]==true; // Skip deleted or already processed section
        type_ValueList & curSec=SectionList[sec];
        type_ValueList::iterator it;
        for(it=curSec.begin();it!=curSec.end();++it)
        {
          valueProcd[it.key()]=false;
        }
				ValueList.clear();
				continue;
			}
			if (pr == P_SECTION) {
				// read name
        if (skipsec)
          continue;
				QString nam;
				int j = 0, l = (int)line.length();
				QChar c;
				while ( (j < l) && !((c = line.ref((uint)j)).isSpace()) ) {
					nam += c;
					j++;
				}
				// read value
        bool rawData=false;
        bool doubleQuotes=false;
				QString val;
				val = line.mid((uint)j).stripWhiteSpace();
				if (val == "data{") {
          rawData=true;
					// read raw data...
					val = "";
					while (!((line = ts.readLine()).isNull())) {
						if (line == "}data") {
							ValueList[nam] = val;
							break;
						}
						val += line + "\n";
					}
				} else {
					// test for ""
					if (val.startsWith("\"") && val.endsWith("\""))
          {
            doubleQuotes=true;
						val = val.mid(1, val.length()-2).stripWhiteSpace();
          }
					ValueList[nam] = val;
				}
        if (SectionList[sec].find(nam)!=SectionList[sec].end() && valueProcd[nam]==false)
        { // write modified value
          if (rawData)
            writeData(nam,SectionList[sec][nam]);
          else if (doubleQuotes)
            writeString(nam,SectionList[sec][nam]);
          else
            ts << nam << "\t" << SectionList[sec][nam] << "\n";
          valueProcd[nam]=true;
        }
			}
      else
        writeComment(line);
		}
	}

	if (pr == P_SECTION) {
		// update last section
    // write new values
    type_ValueList::iterator it;
    type_ValueList & curSec=SectionList[sec];
    type_ValueList & curSecDef=SectionListDef[sec];
    for(it=curSec.begin();it!=curSec.end();++it)
    {
      if (!valueProcd[it.key()])
      { // this value was not processed yet, hence it's new.
        if (curSecDef.find(it.key())==curSecDef.end() || curSecDef[it.key()]!=it.data())
          ts << it.key() << "\t" << it.data() << "\n";
        valueProcd[it.key()]=true; // it is for completeness' sake, so it don't really necessary (yet?).
      }
    }
		secProcd[sec]=true;
	}
  QMapIterator<QString,bool> it;
  for(it=secProcd.begin();it!=secProcd.end();++it)
  {
    QString sec=it.key();
    if (!it.data())
    {
      writeSection(sec);
      type_ValueList & curSec=SectionList[sec];
      type_ValueList & curSecDef=SectionListDef[sec];
      type_ValueList::iterator it1;
      for(it1=curSec.begin();it1!=curSec.end();++it1)
        if (curSecDef.find(it1.key())==curSecDef.end() || curSecDef[it1.key()]!=it1.data())
          ts << it1.key() << "\t" << it1.data() << "\n";
    }
  }
  tempf.flush();
  if (!tempf.reset())
    return false;
  f.close();
  if (!f.open(IO_WriteOnly | IO_Truncate))
    return false;
  const int N=64*1024;
  char * buf=new char[N];
  Q_LONG len;
  while(true)
  {
    len=tempf.readBlock(buf,N);
    if (len<=0)
      break;
    f.writeBlock(buf,(Q_ULONG)len);
  }
  delete [] buf;
  f.close();
  tempf.close();
  tempf.remove();
  ts.setDevice(&f);
	return len>=0;
}
Ejemplo n.º 9
0
void tGraph::draw(QPainter & paint) {
    //QPainter paint(this);
    paint.save();

    int gx1 = hPadding() + _rect.x();
    int gy1 = vPadding() + _rect.y();
    int gx2 = _rect.x() + width() - hPadding();
    int gy2 = _rect.y() + height() - vPadding();

    //paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1);

    QFontMetrics fm(font());
    //QRect brect;

    // get the dimensions of the title label and then draw it
    if(title().length() > 0) {
        fm = QFontMetrics(titleFont());
        //brect = fm.boundingRect(title());
        paint.setFont(titleFont());
        paint.drawText(gx1, gy1, gx2 - gx1, fm.height(), titleAlignment(), title());
        gy1 += fm.height();
    }

    // we need to do some drawing that depends on some other elements having
    // already been placed... since those require that these have already been
    // placed we will just save the old value of gy2 and then calculate the
    // value that we should have after the other code runs without actually
    // drawing anything right now
    int gy2_old = gy2;
    if(dataLabel().length() > 0) {
        fm = QFontMetrics(dataLabelFont());
        gy2 -= fm.height();
    }
    fm = QFontMetrics(dataFont());
    QMapIterator<int, GReference> dlit = _data.begin();
    double tlh = 0.0;
    for(dlit = _data.begin(); dlit != _data.end(); ++dlit) {
        tlh = QMAX(sin45deg * fm.width(dlit.data().first), tlh);
    }
    // don't change this variable as we use it later
    int th = (tlh == 0.0 ? 0 : (int)(tlh + (fm.height() * sin45deg)) + 2);
    gy2 -= th;


    // get the dimensions of the value label then draw it
    if(valueLabel().length() > 0) {
        fm = QFontMetrics(valueLabelFont());
        //brect = fm.boundingRect(valueLabel());
        paint.setFont(valueLabelFont());
        paint.save();
        paint.rotate(-90);
        paint.drawText(-gy2, gx1, gy2 - gy1, fm.height(), valueLabelAlignment(), valueLabel());
        paint.restore();
        gx1 += fm.height();
    }

    fm = QFontMetrics(valueFont());

    QString min_str = QString().sprintf("%-.0f",minValue());
    QString org_str = ( minValue() == 0.0 ? QString::null : "0" );
    QString max_str = QString().sprintf("%-.0f",maxValue());

    int width = QMAX(fm.width(min_str), fm.width(max_str));
    if(org_str.length() > 0) width = QMAX(width, fm.width(org_str));

    gx1 += width;

    int gy_max = gy1;
    int gy_min = gy2 - 1;
    int gy_org = gy_min;

    paint.setFont(valueFont());
    int tfa = Qt::AlignTop | Qt::AlignRight;
    paint.drawText(gx1 - fm.width(min_str), gy_min, fm.width(min_str), fm.height(), tfa, min_str);
    paint.drawLine(gx1 - 3, gy_min, gx1 + 2, gy_min);
    paint.drawText(gx1 - fm.width(max_str), gy_max, fm.width(max_str), fm.height(), tfa, max_str);
    paint.drawLine(gx1 - 3, gy_max, gx1 + 2, gy_max);
    int gheight = gy2 - gy1;
    double grng = maxValue() - minValue();
    if(org_str.length() > 0) {
        double perc = (0 - minValue()) / grng;
        gy_org = gy2 - (int)(perc * (double)gheight);
        paint.drawText(gx1 - fm.width(org_str), gy_org, fm.width(org_str), fm.height(), tfa, org_str);
        paint.drawLine(gx1 - 3, gy_org, gx1 + 2, gy_org);
    }

    gx1 += 3;

    // put the old value back so all the code to come draw correctly!
    gy2 = gy2_old;

    // get the dimensions of the data label then draw it
    if(dataLabel().length() > 0) {
        fm = QFontMetrics(dataLabelFont());
        //brect = fm.boundingRect(dataLabel());
        paint.setFont(dataLabelFont());
        gy2 -= fm.height();
        paint.drawText(gx1, gy2, gx2 - gx1, fm.height(), dataLabelAlignment(), dataLabel());
    }

    gy2 -= th;

    int ref_cnt = _data.count();
    int gwidth = gx2 - gx1;
    gheight = gy2 - gy1;

    if(ref_cnt > 0) {
        paint.save();
        fm = QFontMetrics(dataFont());
        paint.setFont(dataFont());
        int refwidth = QMAX(1, gwidth / ref_cnt);
        int buf = (int)(refwidth / 5);
        int buf2 = buf * 2;
        QMapIterator<int, GReference> rit;
        int pos = gx1 + (int)((gwidth - (refwidth * ref_cnt)) / 2);
        int bar_height;
        int fmheight = fm.height();
        int fmheight_div_2 = fmheight / 2;
        int refwidth_div_2 = refwidth / 2;
        int label_offset = (int)(fmheight_div_2 * cos45deg);
        int last_label_at = -1000;
        QMap<int, double> last_map;
        QMap<int, double> this_map;
        for(rit = _data.begin(); rit != _data.end(); ++rit ) {
            GReference ref = rit.data();
            QString label = ref.first;
            if(label.length() > 0 && ((pos + refwidth_div_2) - last_label_at) > ((label_offset * 2) + 1)) {
                last_label_at = pos + refwidth_div_2;
                int lx = (int)(((pos + refwidth_div_2) * cos45deg) - ((gy2 + label_offset) * sin45deg));
                int ly = (int)(((pos + refwidth_div_2) * sin45deg) + ((gy2 + label_offset) * cos45deg));
                int fmwidth = fm.width(label);
                paint.save();
                paint.rotate(-45);
                paint.drawText(lx - fmwidth, ly - fmheight_div_2, fmwidth, fmheight, Qt::AlignRight | Qt::AlignTop, label);
                paint.restore();
            }

            QMapIterator<int, double> sit;
            paint.save();
            if(drawBars() == TRUE) {
                TSetValue tval;
                QMap<double, TSetValue> sort_map;
                for(sit = ref.second.begin(); sit != ref.second.end(); ++sit ) {
                    if(sit.data() != 0.0 && _setStyle[sit.key()].bar == TRUE) {
                        tval.first = sit.key();
                        tval.second = sit.data();
                        sort_map[(tval.second < 0.0 ? minValue() : maxValue()) - (tval.second < 0.0 ? -tval.second : tval.second)] = tval;
                    }
                }
                QMapIterator<double, TSetValue> it;
                for(it = sort_map.begin(); it != sort_map.end(); ++it) {
                    tval = it.data();
                    if(tval.second != 0.0) {
                        if(tval.second < 0) {
                            bar_height = (int)((tval.second / minValue()) * (gy_org - gy_min));
                        } else {
                            bar_height = (int)((tval.second / maxValue()) * (gy_org - gy_max));
                        } 
                        paint.fillRect(pos + buf, gy_org - bar_height, refwidth - buf2, bar_height, getSetColor(tval.first));
                    }
                }
            }
            if(drawLines() == TRUE) {
                this_map.clear();
                for(sit = ref.second.begin(); sit != ref.second.end(); ++sit) {
                    if(_setStyle[sit.key()].line == TRUE) {
                        this_map[sit.key()] = sit.data();
                        if(last_map.contains(sit.key())) {
                            paint.setPen(getSetColor(sit.key()));
                            double old_val = last_map[sit.key()];
                            double new_val = sit.data();
                            int ly1;
                            if(old_val < 0.0) ly1 = (int)((old_val / minValue()) * (gy_org - gy_min));
                            else              ly1 = (int)((old_val / maxValue()) * (gy_org - gy_max));
                            ly1 = gy_org - ly1;
                            int lx1 = pos - refwidth_div_2;
                            int ly2;
                            if(new_val < 0.0) ly2 = (int)((new_val / minValue()) * (gy_org - gy_min));
                            else              ly2 = (int)((new_val / maxValue()) * (gy_org - gy_max));
                            ly2 = gy_org - ly2;
                            int lx2 = pos + refwidth_div_2;
                            paint.drawLine(lx1, ly1, lx2, ly2);
                        }
                    }
                }
                last_map = this_map;
            }
            if(drawPoints() == TRUE) {
                for(sit = ref.second.begin(); sit != ref.second.end(); ++sit) {
                    if(_setStyle[sit.key()].point == TRUE) {
                        paint.setBrush(getSetColor(sit.key()));
                        paint.setPen(QColor(0,0,0));
                        int ly1;
                        if(sit.data() < 0.0) ly1 = (int)((sit.data() / minValue()) * (gy_org - gy_min));
                        else                 ly1 = (int)((sit.data() / maxValue()) * (gy_org - gy_max));
                        ly1 = gy_org - ly1;
                        int lx1 = pos + refwidth_div_2;
                        paint.drawEllipse(lx1 - 2, ly1 - 2, 5, 5);
                    }
                }
            }
            paint.restore();
            pos += refwidth;
        }
        paint.restore();
    }

    paint.drawLine(gx1, gy_org, gx2 - 1, gy_org);
    paint.drawRect(gx1, gy1, gx2 - gx1, gy2 - gy1);


    // Now that we are done return the paint device back to the state
    // it was when we started to mess with it
    paint.restore();
}
Ejemplo n.º 10
0
QDomDocument ReportWindow::document() {
    QDomDocument doc = QDomDocument("openRPTDef");
    QDomElement root = doc.createElement("report");
    doc.appendChild(root);

    //title
    QDomElement title = doc.createElement("title");
    title.appendChild(doc.createTextNode(reportTitle()));
    root.appendChild(title);

    QDomElement rname = doc.createElement("name");
    rname.appendChild(doc.createTextNode(reportName()));
    root.appendChild(rname);

    QDomElement rdesc = doc.createElement("description");
    rdesc.appendChild(doc.createTextNode(reportDescription()));
    root.appendChild(rdesc);

    for(QMap<QString,QString>::iterator it = _definedParams.begin();
            it != _definedParams.end(); it++) {
        QDomElement param = doc.createElement("parameter");
        param.setAttribute("name", it.key());
        param.appendChild(doc.createTextNode(it.data()));
        root.appendChild(param);
    }

    if((watermarkUseStaticText() && !watermarkText().isEmpty()) || 
        (!watermarkUseStaticText() && !watermarkQuery().isEmpty() && !watermarkColumn().isEmpty())) {
        QDomElement wm = doc.createElement("watermark");
        if(watermarkUseStaticText()) {
            QDomElement wmtext = doc.createElement("text");
            wmtext.appendChild(doc.createTextNode(watermarkText()));
            wm.appendChild(wmtext);
        } else {
            QDomElement wmdata = doc.createElement("data");
            QDomElement wmdq = doc.createElement("query");
            wmdq.appendChild(doc.createTextNode(watermarkQuery()));
            wmdata.appendChild(wmdq);
            QDomElement wmdc = doc.createElement("column");
            wmdc.appendChild(doc.createTextNode(watermarkColumn()));
            wmdata.appendChild(wmdc);
            wm.appendChild(wmdata);
        }
        if(!watermarkUseDefaultFont()) {
            ReportEntity::buildXMLFont(doc,wm,watermarkFont());
        }
        QDomElement wmopac = doc.createElement("opacity");
        wmopac.appendChild(doc.createTextNode(QString::number(watermarkOpacity())));
        wm.appendChild(wmopac);
        root.appendChild(wm);
    }

    if(bgEnabled()) {
        QDomElement bg = doc.createElement("background");
        if(bgStatic()) {
            QDomElement bgimg = doc.createElement("image");
            bgimg.appendChild(doc.createTextNode(bgImage()));
            bg.appendChild(bgimg);
        } else {
            QDomElement bgdata = doc.createElement("data");
            QDomElement bgdq = doc.createElement("query");
            bgdq.appendChild(doc.createTextNode(bgQuery()));
            bgdata.appendChild(bgdq);
            QDomElement bgdc = doc.createElement("column");
            bgdc.appendChild(doc.createTextNode(bgColumn()));
            bgdata.appendChild(bgdc);
            bg.appendChild(bgdata);
        }
        QDomElement bgmode = doc.createElement("mode");
        bgmode.appendChild(doc.createTextNode(bgResizeMode()));
        bg.appendChild(bgmode);
        QDomElement bgopac = doc.createElement("opacity");
        bgopac.appendChild(doc.createTextNode(QString::number(bgOpacity())));
        bg.appendChild(bgopac);

        QDomElement bgrect = doc.createElement("rect");
        QDomElement bgrectx = doc.createElement("x");
        bgrectx.appendChild(doc.createTextNode(QString::number(bgBoundsX())));
        bgrect.appendChild(bgrectx);
        QDomElement bgrecty = doc.createElement("y");
        bgrecty.appendChild(doc.createTextNode(QString::number(bgBoundsY())));
        bgrect.appendChild(bgrecty);
        QDomElement bgrectw = doc.createElement("width");
        bgrectw.appendChild(doc.createTextNode(QString::number(bgBoundsWidth())));
        bgrect.appendChild(bgrectw);
        QDomElement bgrecth = doc.createElement("height");
        bgrecth.appendChild(doc.createTextNode(QString::number(bgBoundsHeight())));
        bgrect.appendChild(bgrecth);
        bg.appendChild(bgrect);

        int align = bgAlign();
        // horizontal
        if((align & Qt::AlignRight) == Qt::AlignRight)
            bg.appendChild(doc.createElement("right"));
        else if((align & Qt::AlignHCenter) == Qt::AlignHCenter)
            bg.appendChild(doc.createElement("hcenter"));
        else // Qt::AlignLeft
            bg.appendChild(doc.createElement("left"));
        // vertical
        if((align & Qt::AlignBottom) == Qt::AlignBottom)
            bg.appendChild(doc.createElement("bottom"));
        else if((align & Qt::AlignVCenter) == Qt::AlignVCenter)
            bg.appendChild(doc.createElement("vcenter"));
        else // Qt::AlignTop
            bg.appendChild(doc.createElement("top"));

        root.appendChild(bg);
    }

    // pageOptions
    // -- size
    QDomElement size = doc.createElement("size");
    if(pageOptions->getPageSize() == "Custom") {
        QDomElement page_width = doc.createElement("width");
        page_width.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getCustomWidth()*100))));
        size.appendChild(page_width);
        QDomElement page_height = doc.createElement("height");
        page_height.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getCustomHeight()*100))));
        size.appendChild(page_height);
    } else if(pageOptions->getPageSize() == "Labels") {
        size.appendChild(doc.createTextNode("Labels"));
        QDomElement labeltype = doc.createElement("labeltype");
        labeltype.appendChild(doc.createTextNode(pageOptions->getLabelType()));
        root.appendChild(labeltype);
    } else {
        size.appendChild(doc.createTextNode(pageOptions->getPageSize()));
    }
    root.appendChild(size);
    // -- orientation
    QString str_orientation;
    if(pageOptions->isPortrait()) {
        str_orientation = "portrait";
    } else {
        str_orientation = "landscape";
    }
    root.appendChild(doc.createElement(str_orientation));
    // -- margins
    QDomElement margin;
    margin = doc.createElement("topmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginTop()*100))));
    root.appendChild(margin);
    margin = doc.createElement("bottommargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginBottom()*100))));
    root.appendChild(margin);
    margin = doc.createElement("rightmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginRight()*100))));
    root.appendChild(margin);
    margin = doc.createElement("leftmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginLeft()*100))));
    root.appendChild(margin);

    // write out are Query Sources
    QDomElement qsource;
    QDomElement qname;
    QDomElement qsql;
    QuerySource * qs = NULL;
    for(unsigned int i = 0; i < qsList->size(); i++) {
        qs = qsList->get(i);
        qsource = doc.createElement("querysource");
        qname = doc.createElement("name");
        qname.appendChild(doc.createTextNode(qs->name()));
        qsource.appendChild(qname);
        qsql = doc.createElement("sql");
        qsql.appendChild(doc.createTextNode(qs->query()));
        qsource.appendChild(qsql);
        root.appendChild(qsource);
    }
    qs = NULL;

    QDomElement cdef;
    QDomElement cname;
    QDomElement ccomponent;
    QMapIterator<QString, QColor> cit;
    for(cit = _colorMap.begin(); cit != _colorMap.end(); ++cit) {
        cdef = doc.createElement("colordef");
        cname = doc.createElement("name");
        cname.appendChild(doc.createTextNode(cit.key()));
        cdef.appendChild(cname);
        ccomponent = doc.createElement("red");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().red())));
        cdef.appendChild(ccomponent);
        ccomponent = doc.createElement("green");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().green())));
        cdef.appendChild(ccomponent);
        ccomponent = doc.createElement("blue");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().blue())));
        cdef.appendChild(ccomponent);
        root.appendChild(cdef);
    }

    QDomElement section;

    // report head
    if(rptHead) {
        section = doc.createElement("rpthead");
        rptHead->buildXML(doc, section);
        root.appendChild(section);
    }

    // page head first
    if(pageHeadFirst) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("firstpage"));
        pageHeadFirst->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head odd
    if(pageHeadOdd) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("odd"));
        pageHeadOdd->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head even
    if(pageHeadEven) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("even"));
        pageHeadEven->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head last
    if(pageHeadLast) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("lastpage"));
        pageHeadLast->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head any
    if(pageHeadAny) {
        section = doc.createElement("pghead");
        pageHeadAny->buildXML(doc, section);
        root.appendChild(section);
    }

    // detail sections
    for(int ii = 0; ii < detailSectionCount(); ii++) {
        section = doc.createElement("section");
        getSection(ii)->buildXML(doc,section);
        root.appendChild(section);
    }

    // page foot first
    if(pageFootFirst) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("firstpage"));
        pageFootFirst->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot odd
    if(pageFootOdd) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("odd"));
        pageFootOdd->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot even
    if(pageFootEven) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("even"));
        pageFootEven->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot last
    if(pageFootLast) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("lastpage"));
        pageFootLast->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot any
    if(pageFootAny) {
        section = doc.createElement("pgfoot");
        pageFootAny->buildXML(doc, section);
        root.appendChild(section);
    }

    // report foot
    if(rptFoot) {
        section = doc.createElement("rptfoot");
        rptFoot->buildXML(doc, section);
        root.appendChild(section);
    }

    return doc;
}