Example #1
0
QDomElement OOoReportBuilder::parseRow(QDomNode row)
{
    QDomElement lastElement = row.toElement();

    if (reportBand(row) == Detail) {
        lastElement = processDetail(row.toElement());
    } else {
        QDomNode child = row.firstChild();

        while (!child.isNull()) {
            if (child.nodeName() == "table:table-cell") {
                QString str = processString(cellText(child.toElement()));
                bool ok;
                double value = str.toDouble(&ok);

                if (ok) {
                   setText(child.toElement(), value);
                } else
                    setText(child.toElement(), str);
            }

            child = child.nextSibling();
        }
    }

    return lastElement;
}
Example #2
0
ReportBands OOoReportBuilder::reportBand(QDomNode row)
{
    if (row.nodeName() != "table:table-row")
        return None;

    QString text = cellText(row.firstChild().toElement());
    QRegExp rx("\\{\\w+\\}");

    int pos = rx.indexIn(text);

    if (pos != -1) {
        text = text.mid(pos + 1,rx.matchedLength() - 2);

        if (!QString::compare(text,"rep_header",Qt::CaseInsensitive))
            return ReportHeader;
        else if (!QString::compare(text,"rep_footer",Qt::CaseInsensitive))
            return ReportFooter;
        else {

            text = text.remove(QRegExp("\\d+"));

            if (!QString::compare(text,"header",Qt::CaseInsensitive))
                return DetailHeader;
            else if (!QString::compare(text,"footer",Qt::CaseInsensitive))
                return DetailFooter;

            else if (!QString::compare(text,"detail",Qt::CaseInsensitive))
                return Detail;
        }
    }

    return None;
}
Example #3
0
void CLayerTypeGrid::OnDClicked(int col,long row, RECT *rect,POINT *point,BOOL processed)
{
   int lastColIndx = GetNumberCols() - 1;
   CString cellText(QuickGetText(lastColIndx, row));
   int layerType = atoi(cellText);

   // Edit color if a layerType row (not a group name row)
   // and double click was not in the layer type column.
   if (layerType > -1 && col > 0)
   {
      CUGCell cell;
      GetCell(col, row, &cell); 

      COLORREF color = cell.GetBackColor(); // current color

	   CPersistantColorDialog dialog(color);
	   if (dialog.DoModal() == IDOK)
      {
	      color = dialog.GetColor();
         cell.SetBackColor(color);
         SetCell(col, row, &cell);
         RedrawAll();
      }
   }
}
Example #4
0
	void MultiPlayerMenu::updateGrid() {
		m_grid->clearRows();
		for(int n = 0; n < (int)m_servers.size(); n++) {
			m_grid->addRow(n);
			for(int c = 0; c < m_grid->numColumns(); c++)
				m_grid->setCell(n, c, cellText(n, c));
		}
	}
Example #5
0
void MainWindow::buildTableDataModel(QStandardItemModel& model)
{
    QString cellText("cell(%1,%2)");
    for(int i=0; i<4; ++i)
    {
        QList<QStandardItem*> l;
        for(int j=0; j<4; ++j)
        {
            QStandardItem* cell = new QStandardItem(cellText.arg(i).arg(j));
            l.push_back(cell);
        }
        model.appendRow(l);
    }
}
Example #6
0
void CLayerTypeDlg::OnBnClickedExpandAll()
{
   int rowCnt = m_layerTypeGrid.GetNumberRows();

   int lastColIndx = m_layerTypeGrid.GetNumberCols() - 1;

   for (int rowIndx = 0; rowIndx < rowCnt; rowIndx++)
   {
      CString cellText(m_layerTypeGrid.QuickGetText(lastColIndx, rowIndx));
      int layerType = atoi(cellText);
      if (layerType < 0) // Is layer group name row
      {
         m_layerTypeGrid.ExpandLayerGroup(rowIndx);
      }
   }

   m_layerTypeGrid.RedrawAll();
}
Example #7
0
void CLayerTypeDlg::OnBnClickedCopyfrom()
{
	int curSel = m_layerSets.GetCurSel();

	if (curSel < 0)
		return;

	CSelectDlg dlg("Choose the colorset to copy", false, false);
	dlg.AddItem(new CSelItem("Standard", false));
	dlg.AddItem(new CSelItem("Top", false));
	dlg.AddItem(new CSelItem("Bottom", false));
	for (int i = 0; i < MAX_CUSTOM_COLORSETS; i++)
		dlg.AddItem(new CSelItem(pDoc->CustomLayersetNames[i], false));

	if (dlg.DoModal() == IDCANCEL)
		return;

	CSelItem* selItem = dlg.GetSelItemHead();
	int index = m_layerSets.FindString(0, selItem->GetName());
	int colFrom = index+1;
	int colTo = curSel+1;

   // Update the grid with copied values.
   int rowCnt = m_layerTypeGrid.GetNumberRows();
   int lastColIndx = m_layerTypeGrid.GetNumberCols() - 1;

   for (int rowIndx = 0; rowIndx < rowCnt; rowIndx++)
   {
      // Skip it if it is a layer group row
      CString cellText(m_layerTypeGrid.QuickGetText(lastColIndx, rowIndx));
      int layerType = atoi(cellText);
      if (layerType < 0)
         continue;

      // Copy entry
      CUGCell cellFrom;
      m_layerTypeGrid.GetCell(colFrom, rowIndx, &cellFrom);
      m_layerTypeGrid.SetCell(colTo, rowIndx, &cellFrom);
   }
   m_layerTypeGrid.RedrawAll();
}
Example #8
0
void CLayerTypeGrid::OnLClicked(int col,long row, int updn, RECT *rect, POINT *point, int processed) 
{
   // A click will get two event calls here, one for button down (updn = true) and one
   // for button up. We don't want to do this twice for a single click.
   // So react only to the button up, that is the end of the click event.
   if (updn)
      return;  // Ignore the button down.

   int lastColIndx = GetNumberCols() - 1;
   CString cellText(QuickGetText(lastColIndx, row));
   int layerType = atoi(cellText);

   // Toggle expand/collapse if layer type indicates this is a layer group row.
   // React only if cell was first column cell.
   if (layerType < 0 && col == 0)
   {
      int rowCnt = GetNumberRows();

      CUGCell cell;
      GetCell(col, row, &cell);

      // We use the "+" and "-" in name to track expanded/collapsed state.
      // The char shows the current state.
      CString groupNameText( cell.GetText() );
      bool isExpanded = (groupNameText.Left(1).Compare("-") == 0);

      if (isExpanded)
      {
         // Is expanded, perform collapse.
         CollapseLayerGroup(row);
         RedrawAll();
      }
      else
      {
         // Is collapsed, perform expand.
         ExpandLayerGroup(row);
         RedrawAll();
      }
   }
}
Example #9
0
void CLayerTypeGrid::ExpandLayerGroup(int groupNameRowIndx)
{
   int rowCnt = GetNumberRows();
   int lastColIndx = GetNumberCols() - 1;

   bool keepGoing = true;
   for (int rowIndx = groupNameRowIndx+1; rowIndx < rowCnt && keepGoing; rowIndx++)
   {
      CString cellText( QuickGetText(lastColIndx, rowIndx) );
      int layerType = atoi(cellText);
      if (layerType < 0)
      {
         keepGoing = false;
      }
      else
      {
         SetRowHeight(rowIndx, m_expandedRowHeight);
      }
   }

   CString groupNameText( QuickGetText(0, groupNameRowIndx) );
   groupNameText.SetAt(0, '-');  // Is now expanded, show operator to collapse.
   QuickSetText(0, groupNameRowIndx, groupNameText);
}
Example #10
0
QDomElement OOoReportBuilder::processDetail(const QDomElement &rowDetail)
{
    QDomElement lastElement = rowDetail;

    if (rowDetail.isNull() || reportBand(rowDetail) != Detail)
        return QDomElement();

    QString textCell = cellText(rowDetail.firstChild().toElement());
    textCell.remove(QRegExp("\\{|\\}|detail"));
    int modelId = textCell.toInt() - 1;

    if (modelId < m_models.count() - 1) {
        rowDetail.parentNode().removeChild(rowDetail);
        return lastElement.previousSibling().toElement();
    }

    QAbstractItemModel *model = m_models.at(modelId);

    for (int i = 0; i < model->rowCount(); i++) {
        QDomElement tmpRow = rowDetail.cloneNode(true).toElement();

        QDomElement cell = tmpRow.firstChild().toElement();
        cell = cell.nextSibling().toElement();

        while (!cell.isNull()) {
            QString str = cellText(cell);

            if (!str.isEmpty()) {
                str.remove(QRegExp("\\{|\\}"));

                if (!QString::compare(str,"rowno",Qt::CaseInsensitive)) {
                    setText(cell,QString::number(i));
                } else if (str[0] == 'P') {

                    QVariant var = processParams(str.mid(2));
                    if (var.type() == QVariant::Double) {
                        setText(cell,var.toDouble());
                    } else {
                        setText(cell,var.toString());
                    }
                } else {
                    QRegExp rx("col\\d{1,2}");

                    if (rx.indexIn(str) == 0) {
                        int colNo = str.remove(QRegExp("col")).toInt();
                        QVariant var = model->data(model->index(i,colNo));
                        if (colNo <= model->columnCount() - 1) {
                            if (var.type() == QVariant::Double) {
                                setText(cell, var.toDouble());
                            } else
                                setText(cell, var.toString());
                        } else
                            setText(cell,"Err");
                    } else
                        setText(cell,str);
                }
            }

            if (cell.attributes().contains("table:formula")) {
                QString formula = processFormula(cell.attribute("table:formula"), i);
                cell.setAttribute("table:formula",formula);
            }

            cell = cell.nextSibling().toElement();
        }

        lastElement = rowDetail.parentNode().insertBefore(tmpRow,rowDetail).toElement();
    }

    rowDetail.parentNode().removeChild(rowDetail);
    return lastElement;
}