scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

future::Table::Private Class Reference

#include <future_Table.h>

Collaboration diagram for future::Table::Private:

Public Member Functions

 Private (Table &owner)
void replaceColumns (int first, QList< Column * > new_cols)
 Replace columns completely. More...
void insertColumns (int before, QList< Column * > cols)
 Insert columns before column number 'before'. More...
void removeColumns (int first, int count)
 Remove Columns. More...
void appendColumns (QList< Column * > cols)
 Append columns to the table. More...
void moveColumn (int from, int to)
 Move a column to another position. More...
int columnCount () const
 Return the number of columns in the table. More...
int rowCount () const
 Return the number of rows in the table. More...
void setRowCount (int count)
 Set the number of rows of the table. More...
QString columnHeader (int col)
 Return the full column header string. More...
int numColsWithPD (SciDAVis::PlotDesignation pd)
 Return the number of columns with a given plot designation. More...
Columncolumn (int index) const
 Return column number 'index'. More...
int columnIndex (const Column *col) const
 Return the index of the given column in the table. More...
QString name () const
QVariant headerData (int section, Qt::Orientation orientation, int role) const
void updateVerticalHeader (int start_row)
 Update the vertical header labels. More...
void updateHorizontalHeader (int start_col, int end_col)
 Update the horizontal header labels. More...
void setColumnWidth (int col, int width)
int columnWidth (int col) const

Private Member Functions

void composeColumnHeader (int col, const QString &label)
 Internal function to put together the column header. More...

Private Attributes

 The owner aspect. More...
int d_column_count
 The number of columns. More...
int d_row_count
 The maximum number of rows of all columns. More...
QList< int > d_vertical_header_data
 Vertical header data. More...
QStringList d_horizontal_header_data
 Horizontal header data. More...
QList< Column * > d_columns
 List of pointers to the column data vectors. More...
QList< int > d_column_widths
 Columns widths. More...

Detailed Description

This private class manages column based data (i.e., 1D vector based data such as x-values and y-values for a plot) for a Table. Its API is to be called by Table and table commands only. Table may only call the reading functions to ensure that undo/redo is possible for all data changing operations.

Each column is represented by a Column object and can be directly accessed by the pointer returned by column(). Most of the column manipulation is done directly to the columns. The signals of the columns are connected to various handlers in Table which acts according to all changes made to the columns.

The Column objects are managed as child aspects by Table.

Every column has two filters as children: An input filter that can convert a string (e.g., entered by the user in a cell) to the column's data type and an output filter that delivers the correct string representation to display in a table.

The number of columns in the Table will always be equal to d_columns.size(). The number of rows is generally indepenent of the number of rows in the wrapped columns. It is however always adjusted to be large enough to display the longest column. When columns are inserted, resized etc., the table is resized automatically.

Definition at line 485 of file future_Table.h.

Constructor & Destructor Documentation

◆ Private()

future::Table::Private::Private ( Table owner)

Definition at line 488 of file future_Table.h.

488 : d_owner(owner), d_column_count(0), d_row_count(0) {}

Member Function Documentation

◆ appendColumns()

void future::Table::Private::appendColumns ( QList< Column * >  cols)

Append columns to the table.

See also

Definition at line 2532 of file future_Table.cpp.

2533 {
2535 }

References future::Table::insertColumns().

Here is the call graph for this function:

◆ column()

Column * future::Table::Private::column ( int  index) const

Return column number 'index'.

Definition at line 2453 of file future_Table.cpp.

2454 {
2455  return d_columns.value(index);
2456 }

References d_columns, and AbstractAspect::index().

Referenced by future::Table::column(), future::Table::insertRows(), future::Table::moveColumn(), future::Table::pasteIntoSelection(), future::Table::removeColumns(), future::Table::removeRows(), future::Table::setRowCount(), and TableMoveColumnCmd::TableMoveColumnCmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ columnCount()

int future::Table::Private::columnCount ( ) const

Return the number of columns in the table.

Definition at line 520 of file future_Table.h.

520 { return d_column_count; }

References d_column_count.

Referenced by future::Table::columnCount(), future::Table::insertRows(), future::Table::removeRows(), and future::Table::setRowCount().

Here is the caller graph for this function:

◆ columnHeader()

QString future::Table::Private::columnHeader ( int  col)

Return the full column header string.

Definition at line 2573 of file future_Table.cpp.

2574 {
2575  return headerData(col, Qt::Horizontal, Qt::DisplayRole).toString();
2576 }

References future::Table::headerData().

Here is the call graph for this function:

◆ columnIndex()

int future::Table::Private::columnIndex ( const Column col) const

Return the index of the given column in the table.

the index or -1 if the column is not in the table

Definition at line 535 of file future_Table.h.

536  {
537  for(int i=0; i<d_columns.size(); i++)
538  if( == col) return i;
539  return -1;
540  }

References d_columns.

Referenced by future::Table::columnIndex().

Here is the caller graph for this function:

◆ columnWidth()

int future::Table::Private::columnWidth ( int  col) const

Definition at line 561 of file future_Table.h.

561 { return; }

References d_column_widths.

Referenced by future::Table::columnWidth().

Here is the caller graph for this function:

◆ composeColumnHeader()

void future::Table::Private::composeColumnHeader ( int  col,
const QString &  label 

Internal function to put together the column header.

Don't use this outside updateHorizontalHeader()

Definition at line 2666 of file future_Table.cpp.

2667 {
2668  if (col >= d_horizontal_header_data.size())
2669  d_horizontal_header_data << label;
2670  else
2671  d_horizontal_header_data.replace(col, label);
2672 }

◆ headerData()

QVariant future::Table::Private::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const

Definition at line 2674 of file future_Table.cpp.

2675 {
2676  switch(orientation) {
2677  case Qt::Horizontal:
2678  if (section >= d_horizontal_header_data.size())
2679  return QVariant();
2680  switch(role) {
2681  case Qt::DisplayRole:
2682  case Qt::ToolTipRole:
2683  case Qt::EditRole:
2684  return;
2685  case Qt::DecorationRole:
2686  return>icon();
2688  return>comment();
2689  }
2690  break;
2691  case Qt::Vertical:
2692  if (section >= d_vertical_header_data.size())
2693  return QVariant();
2694  switch(role) {
2695  case Qt::DisplayRole:
2696  case Qt::ToolTipRole:
2697  return;
2698  }
2699  break;
2700  }
2701  return QVariant();
2702 }

References TableModel::CommentRole.

Referenced by future::Table::headerData().

Here is the caller graph for this function:

◆ insertColumns()

void future::Table::Private::insertColumns ( int  before,
QList< Column * >  cols 

Insert columns before column number 'before'.

If 'first' is equal to the number of columns, the columns will be appended.

beforeindex of the column to insert before
colsa list of column data objects

Definition at line 2482 of file future_Table.cpp.

2483 {
2484  int count = cols.count();
2486  if( (count < 1) || (before > d_column_count) )
2487  return;
2489  Q_ASSERT(before >= 0);
2491  int i, rows;
2492  for(i=0; i<count; i++)
2493  {
2494  rows =>rowCount();
2495  if(rows > d_row_count)
2496  setRowCount(rows);
2497  }
2499  emit d_owner.columnsAboutToBeInserted(before, cols);
2500  for(int i=count-1; i>=0; i--)
2501  {
2502  d_columns.insert(before,;
2503  d_owner.connectColumn(;
2504  d_column_widths.insert(before, Table::defaultColumnWidth());
2505  }
2506  d_column_count += count;
2507  emit d_owner.columnsInserted(before, cols.count());
2508  updateHorizontalHeader(before, before+count-1);
2509 }

References future::Table::defaultColumnWidth(), and future::Table::setRowCount().

Referenced by TableInsertColumnsCmd::redo(), and TableRemoveColumnsCmd::undo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveColumn()

void future::Table::Private::moveColumn ( int  from,
int  to 

Move a column to another position.

Definition at line 2537 of file future_Table.cpp.

2538 {
2539  if( from < 0 || from >= d_column_count) return;
2540  if( to < 0 || to >= d_column_count) return;
2542  d_columns.move(from, to);
2544  d_column_widths.move(from, to);
2545  updateHorizontalHeader(qMin(from, to), qMax(from, to));
2546  emit d_owner.dataChanged(0, from, d_row_count-1, from);
2547  emit d_owner.dataChanged(0, to, d_row_count-1, to);
2548  if (d_owner.d_view) d_owner.d_view->rereadSectionSizes();
2549 }

Referenced by TableMoveColumnCmd::redo(), and TableMoveColumnCmd::undo().

Here is the caller graph for this function:

◆ name()

QString future::Table::Private::name ( ) const

Definition at line 541 of file future_Table.h.

541 { return; }

References d_owner, and AbstractAspect::name().

Referenced by TableInsertColumnsCmd::TableInsertColumnsCmd(), TableMoveColumnCmd::TableMoveColumnCmd(), TableRemoveColumnsCmd::TableRemoveColumnsCmd(), and TableSetNumberOfRowsCmd::TableSetNumberOfRowsCmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numColsWithPD()

int future::Table::Private::numColsWithPD ( SciDAVis::PlotDesignation  pd)

Return the number of columns with a given plot designation.

Definition at line 2578 of file future_Table.cpp.

2579 {
2580  int count = 0;
2582  for (int i=0; i<d_column_count; i++)
2583  if(>plotDesignation() == pd)
2584  count++;
2586  return count;
2587 }

◆ removeColumns()

void future::Table::Private::removeColumns ( int  first,
int  count 

Remove Columns.

This does not delete the removed columns because this must be handled by the undo/redo system.

firstindex of the first column to be removed
countnumber of columns to remove

Definition at line 2511 of file future_Table.cpp.

2512 {
2513  if( (count < 1) || (first >= d_column_count) )
2514  return;
2516  Q_ASSERT(first >= 0);
2518  Q_ASSERT(first+count <= d_column_count);
2520  emit d_owner.columnsAboutToBeRemoved(first, count);
2521  for(int i=count-1; i>=0; i--)
2522  {
2523  d_owner.disconnectColumn(;
2524  d_columns.removeAt(first);
2525  d_column_widths.removeAt(first);
2526  }
2527  d_column_count -= count;
2528  emit d_owner.columnsRemoved(first, count);
2530 }

Referenced by TableRemoveColumnsCmd::redo(), and TableInsertColumnsCmd::undo().

Here is the caller graph for this function:

◆ replaceColumns()

void future::Table::Private::replaceColumns ( int  first,
QList< Column * >  new_cols 

Replace columns completely.

firstthe first column to be replaced
new_colslist of the columns that replace the old ones This does not delete the replaced columns.

Definition at line 2458 of file future_Table.cpp.

2459 {
2460  if( (first < 0) || (first + new_cols.size() > d_column_count) )
2461  return;
2463  int count = new_cols.size();
2464  emit d_owner.columnsAboutToBeReplaced(first, new_cols.count());
2465  for(int i=0; i<count; i++)
2466  {
2467  int rows =>rowCount();
2468  if(rows > d_row_count)
2469  setRowCount(rows);
2471  if(
2474  d_columns[first+i] =;
2475  d_owner.connectColumn(;
2476  }
2477  updateHorizontalHeader(first, first+count-1);
2478  emit d_owner.columnsReplaced(first, new_cols.count());
2479  emit d_owner.dataChanged(0, first, d_row_count-1, first+count-1);
2480 }

References future::Table::setRowCount().

Here is the call graph for this function:

◆ rowCount()

int future::Table::Private::rowCount ( ) const

Return the number of rows in the table.

Definition at line 522 of file future_Table.h.

522 { return d_row_count; }

References d_row_count.

Referenced by TableInsertColumnsCmd::redo(), TableSetNumberOfRowsCmd::redo(), future::Table::removeRows(), future::Table::rowCount(), and future::Table::setRowCount().

Here is the caller graph for this function:

◆ setColumnWidth()

void future::Table::Private::setColumnWidth ( int  col,
int  width 

Definition at line 560 of file future_Table.h.

560 { d_column_widths[col] = width; }

References d_column_widths.

Referenced by future::Table::setColumnWidth().

Here is the caller graph for this function:

◆ setRowCount()

void future::Table::Private::setRowCount ( int  count)

Set the number of rows of the table.

Definition at line 2551 of file future_Table.cpp.

2552 {
2553  int diff = rows - d_row_count;
2554  int old_row_count = d_row_count;
2555  if(diff == 0)
2556  return;
2558  if(diff > 0)
2559  {
2561  d_row_count = rows;
2563  emit d_owner.rowsInserted(old_row_count, diff);
2564  }
2565  else
2566  {
2567  emit d_owner.rowsAboutToBeRemoved(rows, -diff);
2568  d_row_count = rows;
2569  emit d_owner.rowsRemoved(rows, -diff);
2570  }
2571 }

Referenced by TableSetNumberOfRowsCmd::redo(), TableInsertColumnsCmd::undo(), and TableSetNumberOfRowsCmd::undo().

Here is the caller graph for this function:

◆ updateHorizontalHeader()

void future::Table::Private::updateHorizontalHeader ( int  start_col,
int  end_col 

Update the horizontal header labels.

This must be called whenever columns are added or removed and when comments, labels, and column types change.

start_colfirst column that needs to be updated
end_collast column that needs to be updated

Definition at line 2599 of file future_Table.cpp.

2600 {
2601  if (start_col > end_col) return;
2604  d_horizontal_header_data << QString();
2606  if(numColsWithPD(SciDAVis::X)>1)
2607  {
2608  int x_cols = 0;
2609  for (int i=0; i<d_column_count; i++)
2610  {
2611  if (>plotDesignation() == SciDAVis::X)
2612  composeColumnHeader(i,>name()+"[X" + QString::number(++x_cols) +"]");
2613  else if (>plotDesignation() == SciDAVis::Y)
2614  {
2615  if(x_cols>0)
2616  composeColumnHeader(i,>name()+"[Y"+ QString::number(x_cols) +"]");
2617  else
2618  composeColumnHeader(i,>name()+"[Y]");
2619  }
2620  else if (>plotDesignation() == SciDAVis::Z)
2621  {
2622  if(x_cols>0)
2623  composeColumnHeader(i,>name()+"[Z"+ QString::number(x_cols) +"]");
2624  else
2625  composeColumnHeader(i,>name()+"[Z]");
2626  }
2627  else if (>plotDesignation() == SciDAVis::xErr)
2628  {
2629  if(x_cols>0)
2630  composeColumnHeader(i,>name()+"[xEr"+ QString::number(x_cols) +"]");
2631  else
2632  composeColumnHeader(i,>name()+"[xEr]");
2633  }
2634  else if (>plotDesignation() == SciDAVis::yErr)
2635  {
2636  if(x_cols>0)
2637  composeColumnHeader(i,>name()+"[yEr"+ QString::number(x_cols) +"]");
2638  else
2639  composeColumnHeader(i,>name()+"[yEr]");
2640  }
2641  else
2642  composeColumnHeader(i,>name());
2643  }
2644  }
2645  else
2646  {
2647  for (int i=0; i<d_column_count; i++)
2648  {
2649  if (>plotDesignation() == SciDAVis::X)
2650  composeColumnHeader(i,>name()+"[X]");
2651  else if(>plotDesignation() == SciDAVis::Y)
2652  composeColumnHeader(i,>name()+"[Y]");
2653  else if(>plotDesignation() == SciDAVis::Z)
2654  composeColumnHeader(i,>name()+"[Z]");
2655  else if(>plotDesignation() == SciDAVis::xErr)
2656  composeColumnHeader(i,>name()+"[xEr]");
2657  else if(>plotDesignation() == SciDAVis::yErr)
2658  composeColumnHeader(i,>name()+"[yEr]");
2659  else
2660  composeColumnHeader(i,>name());
2661  }
2662  }
2663  emit d_owner.headerDataChanged(Qt::Horizontal, start_col, end_col);
2664 }

References SciDAVis::X, SciDAVis::xErr, SciDAVis::Y, SciDAVis::yErr, and SciDAVis::Z.

Referenced by future::Table::handleDescriptionChange(), future::Table::handleModeChange(), and future::Table::handlePlotDesignationChange().

Here is the caller graph for this function:

◆ updateVerticalHeader()

void future::Table::Private::updateVerticalHeader ( int  start_row)

Update the vertical header labels.

This must be called whenever rows are added or removed.

start_rowfirst row that needs to be updated

Definition at line 2589 of file future_Table.cpp.

2590 {
2591  int current_size = d_vertical_header_data.size(), i;
2592  for(i=start_row; i<current_size; i++)
2593  d_vertical_header_data.replace(i, i+1);
2594  for(; i<d_row_count; i++)
2595  d_vertical_header_data << i+1;
2596  emit d_owner.headerDataChanged(Qt::Vertical, start_row, d_row_count -1);
2597 }

Member Data Documentation

◆ d_column_count

int future::Table::Private::d_column_count

The number of columns.

Definition at line 567 of file future_Table.h.

Referenced by columnCount().

◆ d_column_widths

QList<int> future::Table::Private::d_column_widths

Columns widths.

Definition at line 582 of file future_Table.h.

Referenced by columnWidth(), and setColumnWidth().

◆ d_columns

QList<Column *> future::Table::Private::d_columns

List of pointers to the column data vectors.

Definition at line 575 of file future_Table.h.

Referenced by column(), and columnIndex().

◆ d_horizontal_header_data

QStringList future::Table::Private::d_horizontal_header_data

Horizontal header data.

Definition at line 573 of file future_Table.h.

◆ d_owner

Table& future::Table::Private::d_owner

The owner aspect.

Definition at line 565 of file future_Table.h.

Referenced by name().

◆ d_row_count

int future::Table::Private::d_row_count

The maximum number of rows of all columns.

Definition at line 569 of file future_Table.h.

Referenced by rowCount().

◆ d_vertical_header_data

QList<int> future::Table::Private::d_vertical_header_data

Vertical header data.

Definition at line 571 of file future_Table.h.

The documentation for this class was generated from the following files:
void setRowCount(int count)
Set the number of rows of the table.
Definition: future_Table.cpp:2551
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: future_Table.cpp:2674
int d_column_count
The number of columns.
Definition: future_Table.h:567
@ yErr
y errors
Definition: globals.h:61
void columnsAboutToBeInserted(int before, QList< Column * > new_cols)
@ xErr
x errors
Definition: globals.h:60
int d_row_count
The maximum number of rows of all columns.
Definition: future_Table.h:569
@ Y
y values
Definition: globals.h:58
void updateVerticalHeader(int start_row)
Update the vertical header labels.
Definition: future_Table.cpp:2589
void columnsAboutToBeReplaced(int first, int count)
void rowsAboutToBeInserted(int before, int count)
void rowsAboutToBeRemoved(int first, int count)
void columnsAboutToBeRemoved(int first, int count)
int index() const
Return my position in my parent's list of children.
Definition: AbstractAspect.h:137
void columnsInserted(int first, int count)
void insertColumns(int before, QList< Column * > cols)
Insert columns before column number 'before'.
Definition: future_Table.cpp:2482
Table & d_owner
The owner aspect.
Definition: future_Table.h:565
void rowsRemoved(int first, int count)
static int defaultColumnWidth()
Definition: future_Table.h:232
void columnsReplaced(int first, int count)
void composeColumnHeader(int col, const QString &label)
Internal function to put together the column header.
Definition: future_Table.cpp:2666
QPointer< TableView > d_view
Definition: future_Table.h:455
QStringList d_horizontal_header_data
Horizontal header data.
Definition: future_Table.h:573
void updateHorizontalHeader(int start_col, int end_col)
Update the horizontal header labels.
Definition: future_Table.cpp:2599
void dataChanged(int top, int left, int bottom, int right)
void disconnectColumn(const Column *col)
Internal function to disconnect a column.
Definition: future_Table.cpp:2259
QList< Column * > d_columns
List of pointers to the column data vectors.
Definition: future_Table.h:575
void columnsRemoved(int first, int count)
QString name() const
Definition: AbstractAspect.cpp:229
void rowsInserted(int first, int count)
@ CommentRole
the column comment (for headerData())
Definition: TableModel.h:67
void headerDataChanged(Qt::Orientation orientation, int first, int last)
QList< int > d_vertical_header_data
Vertical header data.
Definition: future_Table.h:571
int numColsWithPD(SciDAVis::PlotDesignation pd)
Return the number of columns with a given plot designation.
Definition: future_Table.cpp:2578
@ Z
z values
Definition: globals.h:59
@ X
x values
Definition: globals.h:57
void connectColumn(const Column *col)
Internal function to connect all column signals.
Definition: future_Table.cpp:2235
QList< int > d_column_widths
Columns widths.
Definition: future_Table.h:582