void DataSetValues::OnNewData(DataClass* source)
{
   source;
   //NOTE: already in GUI thread
   if (m_dataSet) //paranoid check
   {
      bool rowsChanged = false;
      uint64_t rows = CalculateRows();
      if (rows != m_rows)
      {
         rowsChanged = true;
         m_rows = rows;
         AdjustVisibleRowStart();
      }
      m_requestedData = false;

      if (rowsChanged)
      {
         //force full refresh
         emit ModelStructureChanged();
      }
      else
      {
         //only new data
         emit ModelNewData();
      }
   }
}
Exemplo n.º 2
0
OpRect GridLayouter::GetLayoutRectForCell(unsigned col, unsigned row, unsigned colspan, unsigned rowspan)
{
    if (col + colspan > m_col_count || row + rowspan > m_row_count)
        return OpRect();

    CalculateColumns();
    CalculateRows();

    OpRect cell_rect;

    for (unsigned i = 0; i < colspan; i++)
    {
        cell_rect.width += m_column_info[col + i].size;
        if (i > 0)
            cell_rect.width += m_column_info[col + i - 1].margin;
    }

    for (unsigned i = 0; i < rowspan; i++)
    {
        cell_rect.height += m_row_info[row + i].size;
        if (i > 0)
            cell_rect.height += m_row_info[row + i - 1].margin;
    }

    cell_rect.x		 = m_column_info[col].position;
    cell_rect.y		 = m_row_info[row].position;

    // Why 2*m_grid_rect.x? Because the cells of a generic grid are not children of the grid(i.e via SetParentOpWidget etc)
    // Therefore, column positions are not calculated relative to the grid, a start_pos is given(look CalculatePositions
    // and CalculateSizes, where it is called). Hence, to even out the start_pos effect and actually give an offset, m_grid_rect.x
    // is added twice.
    if (UiDirection::Get() == UiDirection::RTL)
        cell_rect.x = m_grid_rect.width - m_column_info[col].position - cell_rect.width + 2*m_grid_rect.x ;

    return cell_rect;
}