Exemplo n.º 1
0
/**
 * struct SplitComponent
 */
SplitComponent::SplitComponent(const Sheet& sheet, const QString & title, const OutputAutoSplitColumn & ownerCol)
  : OutputColumn(sheet, ColId(QUuid(QString("%1.%2").arg(ownerCol.id().toString()).arg(title))), title)
  , m_amount(0.0)
  , m_pricePerUnit(0.0)
  , m_ownerCol(ownerCol)
{
}
Exemplo n.º 2
0
void Sheet::insertColumn(Column* newCol, const ColId& colId /*= ColId()*/)
{
  Q_ASSERT(newCol && !newCol->id().isNull());

  const int index = colId == ColId() ? m_columns.size() : findCol(colId);
  Q_ASSERT(index >= 0);

  if (index >= 0)
  {
    newCol->createCells(); //initialize column

    m_columns.insert(index, newCol);
  }
}
Exemplo n.º 3
0
Column::Column(const Sheet& sheet, const ColId & colId /*= ColId()*/, const QString & title /*= QString()*/)
  : m_sheet(sheet)
  , m_colId(colId.isNull() ? ColId(QUuid::createUuid()) : colId)
  , m_title(title)
{
}
Exemplo n.º 4
0
void Sheet::load(const SheetData& data)
{
  m_rows.clear();
  m_columns.clear();


  /* 1. add rows */
  foreach(const LodgerData & lodg, data.lodgers)
  {
    insertRow(lodg.id);
  }


  /* 2. add input columns */
  //StringColumn* pNamesCol = new StringColumn(*this, ColId(), "nume");
  //insertColumn(pNamesCol); //special column: name always comes first

  foreach(const ColumnData & col, data.columns)
  {
    if (col.type.startsWith("input."))
    {
      createColumn(col, data);
    }
  }

  /* 3. fill inputs: names... */
  int l = 0; //rows
  foreach(const LodgerData & lodg, data.lodgers)
  {
    //pNamesCol->cellAt(l)->setData(lodg.name);

    //inputs:
    for(int c = 0, n = m_columns.size(); c<n; ++c)
    {
      StringColumn* pInputTextColumn = dynamic_cast<StringColumn*>(m_columns[c]);
      if (pInputTextColumn)
      {
        const QString & val = lodg.inputText[pInputTextColumn->getTitle()];

        pInputTextColumn->cellAt(l)->setData(val);

        continue;
      }

      InputColumn* pInputCol = dynamic_cast<InputColumn*>(m_columns[c]);
      if (pInputCol)
      {
        const numeric_t & val = lodg.inputValues[pInputCol->getTitle()];

        pInputCol->cellAt(l)->setData(val);
      }
    }

    ++l;
  }

  /* 4. add output columns */
  foreach(const ColumnData & col, data.columns)
  {
    if (col.type.startsWith("output."))
    {
      createColumn(col, data);
    }
  }

  insertColumn(new TotalColumn(*this, ColId(), "TOTAL")); //special column: total always comes last

  /* 5. customize inputs */
  //see InputColumn::setCustomInputValue
}