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.cpp
Go to the documentation of this file.
1 
13 
31 #include "table/future_Table.h"
32 #include "core/Project.h"
33 #include "lib/ActionManager.h"
34 
35 #include <QItemSelectionModel>
36 #include <QTime>
37 #include <QtGlobal>
38 #include <QHBoxLayout>
39 #include <QShortcut>
40 #include <QApplication>
41 #include <QContextMenuEvent>
42 #include <climits> // for RAND_MAX
43 #include <QMenu>
44 #include <QItemSelection>
45 #include <QModelIndex>
46 #include <QModelIndexList>
47 #include <QInputDialog>
48 #include <QMapIterator>
49 #include <QDialog>
50 #include <QMenuBar>
51 #include <QClipboard>
52 #include <QToolBar>
53 #include <QtDebug>
54 #include <QMimeData>
55 
56 #include "table/TableModel.h"
57 #include "table/TableView.h"
58 #include "table/tablecommands.h"
60 #include "core/column/Column.h"
61 #include "core/AbstractFilter.h"
73 #include "TeXTableExportDialog.h"
74 #include "TeXTableSettings.h"
75 
76 
77 #include "ui_DimensionsDialog.h"
78 
79 #define WAIT_CURSOR QApplication::setOverrideCursor(QCursor(Qt::WaitCursor))
80 #define RESET_CURSOR QApplication::restoreOverrideCursor()
81 
82 namespace future
83 {
84 
87 
88 // TODO: move all selection related stuff to the primary view ?
89 
90 #ifndef LEGACY_CODE_0_2_x
91 Table::Table(AbstractScriptingEngine *engine, int rows, int columns, const QString& name)
92  : AbstractPart(name), d_plot_menu(0), scripted(engine), d_table_private(*this)
93 #else
94 Table::Table(int rows, int columns, const QString& name)
95  : AbstractPart(name), d_plot_menu(0), d_table_private(*this)
96 #endif
97 {
98  // set initial number of rows and columns
99  QList<Column*> cols;
100  for(int i=0; i<columns; i++)
101  {
102  Column * new_col = new Column(QString::number(i+1), SciDAVis::Numeric);
103  new_col->setPlotDesignation(i == 0 ? SciDAVis::X : SciDAVis::Y);
104  cols << new_col;
105  }
106  appendColumns(cols);
107  setRowCount(rows);
108 
109  d_view = NULL;
110  createActions();
111  connectActions();
112 }
113 
114 #ifndef LEGACY_CODE_0_2_x
116  : AbstractPart("temp"), scripted(0)
117 #else
118 Table::Table()
119  : AbstractPart("temp"), d_table_private(*this)
120 #endif
121 {
122  d_view = NULL;
123  createActions();
124 }
125 
127 {}
128 
129 Column * Table::column(int index) const
130 {
131  return d_table_private.column(index);
132 }
133 
134 Column * Table::column(const QString & name, bool legacy_kludge) const
135 {
136  // TODO for 0.3.0: remove all name concatenation with _ in favor of Column * pointers
137  int pos=name.indexOf("_",Qt::CaseInsensitive);
138  QString label=name.right(name.length()-pos-1);
139  for (int i=0; i<columnCount(); i++)
140  {
141  Column *col = d_table_private.column(i);
142  if (col->name() == name || (legacy_kludge && col->name() == label))
143  return col;
144  }
145 
146  return NULL;
147 }
148 
150 {
151  d_view = view;
153  if (d_view)
154  d_view->showComments(d_default_comment_visibility);
155 }
156 
157 QWidget *Table::view()
158 {
159 #ifndef LEGACY_CODE_0_2_x
160  if (!d_view)
161  setView(new TableView(this));
162 #else
163  Q_ASSERT(d_view != NULL);
164 #endif
165  return d_view;
166 }
167 
168 void Table::insertColumns(int before, QList<Column*> new_cols)
169 {
170  if( new_cols.size() < 1 || before < 0 || before > columnCount()) return;
171  WAIT_CURSOR;
172  beginMacro(QObject::tr("%1: insert %2 column(s)").arg(name()).arg(new_cols.size()));
173  int pos=before;
174  foreach(Column* col, new_cols)
175  insertChild(col, pos++);
176  // remark: the TableInsertColumnsCmd will be created in completeAspectInsertion()
177  endMacro();
178  RESET_CURSOR;
179 }
180 
181 void Table::removeColumns(int first, int count)
182 {
183  if( count < 1 || first < 0 || first+count > columnCount()) return;
184  WAIT_CURSOR;
185  beginMacro(QObject::tr("%1: remove %2 column(s)").arg(name()).arg(count));
186  QList<Column*> cols;
187  for(int i=first; i<(first+count); i++)
188  cols.append(d_table_private.column(i));
189  // remark: the TableRemoveColumnsCmd will be created in prepareAspectRemoval()
190  foreach(Column* col, cols)
191  removeChild(col);
192  endMacro();
193  RESET_CURSOR;
194 }
195 
197 {
198  removeColumns(columnIndex(col), 1);
199 }
200 
201 void Table::removeRows(int first, int count)
202 {
203  if( count < 1 || first < 0 || first+count > rowCount()) return;
204  WAIT_CURSOR;
205  beginMacro(QObject::tr("%1: remove %2 row(s)").arg(name()).arg(count));
206  int end = d_table_private.columnCount();
207  for(int col=0; col<end; col++)
208  d_table_private.column(col)->removeRows(first, count);
210  endMacro();
211  RESET_CURSOR;
212 }
213 
214 void Table::insertRows(int before, int count)
215 {
216  if( count < 1 || before < 0 || before > rowCount()) return;
217  WAIT_CURSOR;
218  int new_row_count = rowCount() + count;
219  beginMacro(QObject::tr("%1: insert %2 row(s)").arg(name()).arg(count));
220  int end = d_table_private.columnCount();
221  for(int col=0; col<end; col++)
222  d_table_private.column(col)->insertRows(before, count);
223  setRowCount(new_row_count);
224  endMacro();
225  RESET_CURSOR;
226 }
227 
228 void Table::setRowCount(int new_size)
229 {
230  if( (new_size < 0) || (new_size == d_table_private.rowCount()) ) return;
231  WAIT_CURSOR;
232  beginMacro(QObject::tr("%1: set the number of rows to %2").arg(name()).arg(new_size));
233  if (new_size < d_table_private.rowCount())
234  {
235  int end = d_table_private.columnCount();
236  for(int col=0; col<end; col++)
237  {
238  Column *col_ptr = d_table_private.column(col);
239  if (col_ptr->rowCount() > new_size)
240  col_ptr->removeRows(new_size, col_ptr->rowCount() - new_size);
241  }
242  }
244  endMacro();
245  RESET_CURSOR;
246 }
247 
249 {
250  return d_table_private.columnCount();
251 }
252 
253 int Table::rowCount() const
254 {
255  return d_table_private.rowCount();
256 }
257 
259 {
260  int count = 0;
261  int cols = columnCount();
262  for(int i=0; i<cols; i++)
263  if(column(i)->plotDesignation() == pd) count++;
264 
265  return count;
266 }
267 
268 void Table::setColumnCount(int new_size)
269 {
270  int old_size = columnCount();
271  if ( old_size == new_size || new_size < 0 )
272  return;
273 
274  WAIT_CURSOR;
275  if (new_size < old_size)
276  removeColumns(new_size, old_size-new_size);
277  else
278  {
279  QList<Column*> cols;
280  for(int i=0; i<new_size-old_size; i++)
281  {
282  Column * new_col = new Column(QString::number(i+1), SciDAVis::Numeric);
284  cols << new_col;
285  }
286  appendColumns(cols);
287  }
288  RESET_CURSOR;
289 }
290 
291 int Table::columnIndex(const Column * col) const
292 {
293  return d_table_private.columnIndex(col);
294 }
295 
297 {
298  WAIT_CURSOR;
299  beginMacro(QObject::tr("%1: clear").arg(name()));
300  int cols = columnCount();
301  for(int i=0; i<cols; i++)
302  column(i)->clear();
303  endMacro();
304  RESET_CURSOR;
305 }
306 
307 #ifndef LEGACY_CODE_0_2_x
309 {
310  WAIT_CURSOR;
311  beginMacro(QObject::tr("%1: clear all masks").arg(name()));
312  int cols = columnCount();
313  for(int i=0; i<cols; i++)
314  column(i)->clearMasks();
315  endMacro();
316  RESET_CURSOR;
317 }
318 #endif
319 
321 {
322  WAIT_CURSOR;
323  beginMacro(QObject::tr("%1: add column").arg(name()));
325  endMacro();
326  RESET_CURSOR;
327 }
328 
330 {
331  if (!d_view) return;
332  WAIT_CURSOR;
333  int count = d_view->selectedColumnCount(false);
334  beginMacro(QObject::tr("%1: add %2 column(s)").arg(name()).arg(count));
335  setColumnCount(columnCount() + count);
336  endMacro();
337  RESET_CURSOR;
338 }
339 
341 {
342  if (!d_view) return;
343  int first = d_view->firstSelectedRow();
344  if( first < 0 ) return;
345 
346  WAIT_CURSOR;
347  beginMacro(tr("%1: cut selected cell(s)").arg(name()));
348  copySelection();
350  endMacro();
351  RESET_CURSOR;
352 }
353 
355 {
356  if (!d_view) return;
357  int first_col = d_view->firstSelectedColumn(false);
358  if(first_col == -1) return;
359  int last_col = d_view->lastSelectedColumn(false);
360  if(last_col == -2) return;
361  int first_row = d_view->firstSelectedRow(false);
362  if(first_row == -1) return;
363  int last_row = d_view->lastSelectedRow(false);
364  if(last_row == -2) return;
365  int cols = last_col - first_col +1;
366  int rows = last_row - first_row +1;
367 
368  WAIT_CURSOR;
369  QString output_str;
370 
371  for(int r=0; r<rows; r++)
372  {
373  for(int c=0; c<cols; c++)
374  {
375  Column *col_ptr = column(first_col + c);
376  if(d_view->isCellSelected(first_row + r, first_col + c))
377  {
378  if (d_view->formulaModeActive())
379  {
380  output_str += col_ptr->formula(first_row + r);
381  }
382  else if (col_ptr->dataType() == SciDAVis::TypeDouble)
383  {
384  Double2StringFilter * out_fltr = static_cast<Double2StringFilter *>(col_ptr->outputFilter());
385  output_str += QLocale().toString(col_ptr->valueAt(first_row + r),
386  out_fltr->numericFormat(), 16); // copy with max. precision
387  }
388  else
389  {
390  output_str += text(first_row + r, first_col + c);
391  }
392  }
393  if(c < cols-1)
394  output_str += "\t";
395  }
396  if(r < rows-1)
397  output_str += "\n";
398  }
399  QApplication::clipboard()->setText(output_str);
400  RESET_CURSOR;
401 }
402 
404 {
405  if (!d_view) return;
406  if(columnCount() < 1 || rowCount() < 1) return;
407 
408  WAIT_CURSOR;
409  beginMacro(tr("%1: paste from clipboard").arg(name()));
410 
411  int first_col = d_view->firstSelectedColumn(false);
412  int last_col = d_view->lastSelectedColumn(false);
413  int first_row = d_view->firstSelectedRow(false);
414  int last_row = d_view->lastSelectedRow(false);
415  int input_row_count = 0;
416  int input_col_count = 0;
417  int rows, cols;
418 
419  const QClipboard *clipboard = QApplication::clipboard();
420  const QMimeData *mimeData = clipboard->mimeData();;
421  if(mimeData->hasText())
422  {
423  QString input_str = clipboard->text().trimmed();
424  QList< QStringList > cell_texts;
425  QStringList input_rows(input_str.split(QRegExp("\\n|\\r\\n|\\r")));
426  input_row_count = input_rows.count();
427  input_col_count = 0;
428  for(int i=0; i<input_row_count; i++)
429  {
430  cell_texts.append(input_rows.at(i).trimmed().split(QRegExp("( +|\\s)"),QString::KeepEmptyParts));
431  if(cell_texts.at(i).count() > input_col_count) input_col_count = cell_texts.at(i).count();
432  }
433 
434  if( (first_col == -1 || first_row == -1) ||
435  (last_row == first_row && last_col == first_col) )
436  // if the is no selection or only one cell selected, the
437  // selection will be expanded to the needed size from the current cell
438  {
439  int current_row, current_col;
440  d_view->getCurrentCell(&current_row, &current_col);
441  if(current_row == -1) current_row = 0;
442  if(current_col == -1) current_col = 0;
443  d_view->setCellSelected(current_row, current_col);
444  first_col = current_col;
445  first_row = current_row;
446  last_row = first_row + input_row_count -1;
447  last_col = first_col + input_col_count -1;
448  // resize the table if necessary
449  if(last_col >= columnCount())
450  {
451  QList<Column*> cols;
452  for(int i=0; i<last_col+1-columnCount(); i++)
453  {
454  Column * new_col = new Column(QString::number(i+1), SciDAVis::Numeric);
456  cols << new_col;
457  }
458  appendColumns(cols);
459  }
460  if(last_row >= rowCount())
461  appendRows(last_row+1-rowCount());
462  // select the rectangle to be pasted in
463  d_view->setCellsSelected(first_row, first_col, last_row, last_col);
464  }
465 
466  rows = last_row - first_row + 1;
467  cols = last_col - first_col + 1;
468  if ((d_view->formulaModeActive()) || (d_view->hasMultiSelection()))
469  {
470  for(int r=0; r<rows && r<input_row_count; r++)
471  {
472  for(int c=0; c<cols && c<input_col_count; c++)
473  {
474  if(d_view->isCellSelected(first_row + r, first_col + c) && (c < cell_texts.at(r).count()) )
475  {
476  Column * col_ptr = d_table_private.column(first_col + c);
477  col_ptr->setFormula(first_row + r, cell_texts.at(r).at(c));
478  col_ptr->setInvalid(first_row + r, false);
479  }
480  }
481  }
482  }
483  else
484  {
485  QList< QStringList > cols_texts;
486  // transpose clipboard data to use replaceTexts
487  for (int c=0; c<input_col_count; c++)
488  {
489  QStringList cur_column;
490  for (int r=0; r<input_row_count; r++)
491  {
492  if (c < cell_texts.at(r).size()) {
493  cur_column << cell_texts.at(r).at(c);
494  } else {
495  cur_column << QString();
496  }
497  }
498  cols_texts << cur_column;
499  }
500 
501  // regular expression for numeric data
502  QRegExp floatorintrx = QRegExp("^[-+]?(?=[^eE]*\\d)\\d*\\.?\\d*([eE][-+]?\\d+)?$");
503  for (int c=0; c<cols && c<input_col_count; c++)
504  {
505  Column * col_ptr = d_table_private.column(first_col + c);
506  if (col_ptr->columnMode() == SciDAVis::Numeric) {
507  if (cols_texts.at(c).size() != cols_texts.at(c).filter(floatorintrx).size())
508  col_ptr->setColumnMode(SciDAVis::Text);
509  }
510  col_ptr->asStringColumn()->replaceTexts(first_row, cols_texts.at(c).mid(0,rows));
511  }
512  }
513 
515  }
516  endMacro();
517  RESET_CURSOR;
518 }
519 
520 #ifndef LEGACY_CODE_0_2_x
522 {
523  if (!d_view) return;
524  int first = d_view->firstSelectedRow();
525  int last = d_view->lastSelectedRow();
526  if( first < 0 ) return;
527 
528  WAIT_CURSOR;
529  beginMacro(tr("%1: mask selected cell(s)").arg(name()));
530  QList<Column*> list = d_view->selectedColumns();
531  foreach(Column * col_ptr, list)
532  {
533  int col = columnIndex(col_ptr);
534  for(int row=first; row<=last; row++)
535  if(d_view->isCellSelected(row, col)) col_ptr->setMasked(row);
536  }
537  endMacro();
538  RESET_CURSOR;
539 }
540 
542 {
543  if (!d_view) return;
544  int first = d_view->firstSelectedRow();
545  int last = d_view->lastSelectedRow();
546  if( first < 0 ) return;
547 
548  WAIT_CURSOR;
549  beginMacro(tr("%1: unmask selected cell(s)").arg(name()));
550  QList<Column*> list = d_view->selectedColumns();
551  foreach(Column * col_ptr, list)
552  {
553  int col = columnIndex(col_ptr);
554  for(int row=first; row<=last; row++)
555  if(d_view->isCellSelected(row, col)) col_ptr->setMasked(row, false);
556  }
557  endMacro();
558  RESET_CURSOR;
559 }
560 #endif
561 
563 {
564  if (!d_view) return;
565  d_view->showControlFormulaTab();
566 }
567 
569 {
570  if (!d_view) return;
571 #ifdef LEGACY_CODE_0_2_x
572  WAIT_CURSOR;
573  beginMacro(tr("%1: apply formula to selection").arg(name()));
574  emit recalculate();
575  endMacro();
576  RESET_CURSOR;
577 #endif
578 }
579 
581 {
582  if (!d_view) return;
583  if(d_view->selectedColumnCount() < 1) return;
584  int first = d_view->firstSelectedRow();
585  int last = d_view->lastSelectedRow();
586  if( first < 0 ) return;
587 
588  WAIT_CURSOR;
589  beginMacro(tr("%1: fill cells with row numbers").arg(name()));
590  foreach(Column *col_ptr, d_view->selectedColumns()) {
591  int col = columnIndex(col_ptr);
592  switch (col_ptr->columnMode()) {
593  case SciDAVis::Numeric:
594  {
595  QVector<qreal> results(last-first+1);
596  for (int row=first; row<=last; row++)
597  if(d_view->isCellSelected(row, col))
598  results[row-first] = row+1;
599  else
600  results[row-first] = col_ptr->valueAt(row);
601  col_ptr->replaceValues(first, results);
602  break;
603  }
604  case SciDAVis::Text:
605  {
606  QStringList results;
607  for (int row=first; row<=last; row++)
608  if (d_view->isCellSelected(row, col))
609  results << QString::number(row+1);
610  else
611  results << col_ptr->textAt(row);
612  col_ptr->replaceTexts(first, results);
613  break;
614  }
615  default:
616  break;
617  }
618  }
619  endMacro();
620  RESET_CURSOR;
621 }
622 
624 {
625  if (!d_view) return;
626  if(d_view->selectedColumnCount() < 1) return;
627  int first = d_view->firstSelectedRow();
628  int last = d_view->lastSelectedRow();
629  if( first < 0 ) return;
630 
631  WAIT_CURSOR;
632  beginMacro(tr("%1: fill cells with random values").arg(name()));
633  qsrand(QTime::currentTime().msec());
634  foreach(Column *col_ptr, d_view->selectedColumns()) {
635  int col = columnIndex(col_ptr);
636  switch (col_ptr->columnMode()) {
637  case SciDAVis::Numeric:
638  {
639  QVector<qreal> results(last-first+1);
640  for (int row=first; row<=last; row++)
641  if (d_view->isCellSelected(row, col))
642  results[row-first] = double(qrand())/double(RAND_MAX);
643  else
644  results[row-first] = col_ptr->valueAt(row);
645  col_ptr->replaceValues(first, results);
646  break;
647  }
648  case SciDAVis::Text:
649  {
650  QStringList results;
651  for (int row=first; row<=last; row++)
652  if (d_view->isCellSelected(row, col))
653  results << QString::number(double(qrand())/double(RAND_MAX));
654  else
655  results << col_ptr->textAt(row);
656  col_ptr->replaceTexts(first, results);
657  break;
658  }
659  case SciDAVis::DateTime:
660  case SciDAVis::Month:
661  case SciDAVis::Day:
662  {
663  QList<QDateTime> results;
664  QDate earliestDate(1,1,1);
665  QDate latestDate(2999,12,31);
666  QTime midnight(0,0,0,0);
667  for (int row=first; row<=last; row++)
668  if (d_view->isCellSelected(row, col))
669  results << QDateTime(
670  earliestDate.addDays(((double)qrand())*((double)earliestDate.daysTo(latestDate))/((double)RAND_MAX)),
671  midnight.addMSecs(((qint64)qrand())*1000*60*60*24/RAND_MAX));
672  else
673  results << col_ptr->dateTimeAt(row);
674  col_ptr->replaceDateTimes(first, results);
675  break;
676  }
677  }
678  }
679  endMacro();
680  RESET_CURSOR;
681 }
682 
684 {
685  QList<Column*> cols;
686 
687  for(int i=0; i<columnCount(); i++)
688  cols.append(column(i));
689 
690  sortDialog(cols);
691 }
692 
694 {
695  if (!d_view) return;
696  int first = d_view->firstSelectedColumn();
697  int last = d_view->lastSelectedColumn();
698  if( first < 0 ) return;
699  int count, current = first;
700  QList<Column*> cols;
701 
702  WAIT_CURSOR;
703  beginMacro(QObject::tr("%1: insert empty column(s)").arg(name()));
704  while( current <= last )
705  {
706  current = first+1;
707  while( current <= last && d_view->isColumnSelected(current) ) current++;
708  count = current-first;
709  for(int i=0; i<count; i++)
710  {
711  Column * new_col = new Column(QString::number(i+1), SciDAVis::Numeric);
713  cols << new_col;
714  }
715  insertColumns(first, cols);
716  cols.clear();
717  current += count;
718  last += count;
719  while( current <= last && !d_view->isColumnSelected(current) ) current++;
720  first = current;
721  }
722  endMacro();
723  RESET_CURSOR;
724 }
725 
727 {
728  if (!d_view) return;
729  WAIT_CURSOR;
730  beginMacro(QObject::tr("%1: remove selected column(s)").arg(name()));
731 
732  QList< Column* > list = d_view->selectedColumns();
733  foreach(Column* ptr, list)
734  removeColumn(ptr);
735 
736  endMacro();
737  RESET_CURSOR;
738 }
739 
741 {
742  if (!d_view) return;
743  WAIT_CURSOR;
744  beginMacro(QObject::tr("%1: clear selected column(s)").arg(name()));
745 
746  QList< Column* > list = d_view->selectedColumns();
747  if (d_view->formulaModeActive())
748  {
749  foreach(Column* ptr, list)
750  ptr->clearFormulas();
751  }
752  else
753  {
754  foreach(Column* ptr, list)
755  ptr->clear();
756  }
757 
758  endMacro();
759  RESET_CURSOR;
760 }
761 
763 {
764  if (!d_view) return;
765  WAIT_CURSOR;
766  beginMacro(QObject::tr("%1: set plot designation(s)").arg(name()));
767 
768  QList< Column* > list = d_view->selectedColumns();
769  foreach(Column* ptr, list)
770  ptr->setPlotDesignation(pd);
771 
772  endMacro();
773  RESET_CURSOR;
774 }
775 
777 {
779 }
780 
782 {
784 }
785 
787 {
789 }
790 
792 {
794 }
795 
797 {
799 }
800 
802 {
804 }
805 
806 void Table::normalizeColumns(QList< Column* > cols)
807 {
808  if (!d_view) return;
809 
810  WAIT_CURSOR;
811  beginMacro(QObject::tr("%1: normalize column(s)").arg(name()));
812  foreach(Column * col, cols)
813  {
814  if (col->dataType() == SciDAVis::TypeDouble)
815  {
816  double max = 0.0;
817  for (int row=0; row<col->rowCount(); row++)
818  {
819  if (col->valueAt(row) > max)
820  max = col->valueAt(row);
821  }
822  QVector<qreal> results(col->rowCount());
823  if (max != 0.0) // avoid division by zero
824  for (int row=0; row<col->rowCount(); row++)
825  results[row] = col->valueAt(row) / max;
826  col->replaceValues(0, results);
827  }
828  }
829  endMacro();
830  RESET_CURSOR;
831 }
832 
834 {
835  normalizeColumns(d_view->selectedColumns());
836 }
837 
839 {
840  if (!d_view) return;
841 
842  WAIT_CURSOR;
843  beginMacro(QObject::tr("%1: normalize selection").arg(name()));
844  double max = 0.0;
845  foreach(Column *col_ptr, d_view->selectedColumns()) {
846  int col = columnIndex(col_ptr);
847  if (col_ptr->dataType() == SciDAVis::TypeDouble)
848  for (int row=0; row<col_ptr->rowCount(); row++)
849  if (d_view->isCellSelected(row, col) && col_ptr->valueAt(row) > max)
850  max = col_ptr->valueAt(row);
851  }
852 
853  if (max != 0.0) // avoid division by zero
854  {
855  foreach(Column *col_ptr, d_view->selectedColumns()) {
856  int col = columnIndex(col_ptr);
857  if (col_ptr->dataType() == SciDAVis::TypeDouble) {
858  QVector<qreal> results(rowCount());
859  for (int row=0; row<col_ptr->rowCount(); row++)
860  if (d_view->isCellSelected(row, col))
861  results[row] = col_ptr->valueAt(row) / max;
862  else
863  results[row] = col_ptr->valueAt(row);
864  col_ptr->replaceValues(0, results);
865  }
866  }
867  }
868  endMacro();
869  RESET_CURSOR;
870 }
871 
873 {
874  if (!d_view) return;
875  QList< Column* > cols = d_view->selectedColumns();
876  sortDialog(cols);
877 }
878 
880 {
881 #ifdef LEGACY_CODE_0_2_x
882  // TODO: this is only an ugly hack for 0.2.0
883  emit requestColumnStatistics();
884 #endif
885 }
886 
888 {
889 #ifdef LEGACY_CODE_0_2_x
890  // TODO: this is only an ugly hack for 0.2.0
891  emit requestRowStatistics();
892 #endif
893 }
894 
896 {
897  if (!d_view) return;
898  int first = d_view->firstSelectedRow();
899  int last = d_view->lastSelectedRow();
900  int count, current = first;
901 
902  if( first < 0 ) return;
903 
904  WAIT_CURSOR;
905  beginMacro(QObject::tr("%1: insert empty rows(s)").arg(name()));
906  while( current <= last )
907  {
908  current = first+1;
909  while( current <= last && d_view->isRowSelected(current) ) current++;
910  count = current-first;
911  insertRows(first, count);
912  current += count;
913  last += count;
914  while( current <= last && !d_view->isRowSelected(current) ) current++;
915  first = current;
916  }
917  endMacro();
918  RESET_CURSOR;
919 }
920 
922 {
923  if (!d_view) return;
924 
925  WAIT_CURSOR;
926  beginMacro(QObject::tr("%1: remove selected rows(s)").arg(name()));
927  foreach(Interval<int> i, d_view->selectedRows().intervals())
928  removeRows(i.start(), i.size());
929  endMacro();
930  RESET_CURSOR;
931 }
932 
934 {
935  if (!d_view) return;
936  int first = d_view->firstSelectedRow();
937  // because this is not marked constant, we'd better call it.
938  d_view->lastSelectedRow();
939  if( first < 0 ) return;
940 
941  WAIT_CURSOR;
942  beginMacro(QObject::tr("%1: clear selected cell(s)").arg(name()));
943  QList<Column*> list = d_view->selectedColumns();
944  foreach(Column * col_ptr, list)
945  {
946  if (d_view->formulaModeActive())
947  foreach(Interval<int> i, d_view->selectedRows().intervals())
948  col_ptr->setFormula(i, "");
949  else
950  foreach(Interval<int> i, d_view->selectedRows().intervals())
951  if (i.end() == col_ptr->rowCount()-1)
952  col_ptr->removeRows(i.start(), i.size());
953  else {
954  QStringList empties;
955  for (int j=0; j<i.size(); j++)
956  empties << QString();
957  col_ptr->asStringColumn()->replaceTexts(i.start(), empties);
958  }
959  }
960  endMacro();
961  RESET_CURSOR;
962 }
963 
965 {
966  if (!d_view) return;
967  d_view->showControlTypeTab();
968 }
969 
971 {
972  if (!d_view) return;
973  d_view->showControlDescriptionTab();
974 }
975 
977 {
978  if (!d_view) return;
979  WAIT_CURSOR;
980  int count = d_view->selectedRowCount(false);
981  beginMacro(QObject::tr("%1: add %2 rows(s)").arg(name()).arg(count));
983  endMacro();
984  RESET_CURSOR;
985 }
986 
987 bool Table::fillProjectMenu(QMenu * menu)
988 {
989  menu->setTitle(tr("&Table"));
990 
991  QMenu * submenu = new QMenu(tr("S&et Column(s) As"));
992  submenu->addAction(action_set_as_x);
993  submenu->addAction(action_set_as_y);
994  submenu->addAction(action_set_as_z);
995  submenu->addSeparator();
996  submenu->addAction(action_set_as_xerr);
997  submenu->addAction(action_set_as_yerr);
998  submenu->addSeparator();
999  submenu->addAction(action_set_as_none);
1000  menu->addMenu(submenu);
1001  menu->addSeparator();
1002 
1003  submenu = new QMenu(tr("Fi&ll Selection with"));
1004  submenu->addAction(action_fill_row_numbers);
1005  submenu->addAction(action_fill_random);
1006  menu->addMenu(submenu);
1007  menu->addSeparator();
1008 
1009  connect(menu, SIGNAL(aboutToShow()), this, SLOT(adjustActionNames()));
1010  menu->addAction(action_toggle_comments);
1011  menu->addAction(action_toggle_tabbar);
1012  menu->addAction(action_formula_mode);
1013  menu->addAction(action_edit_description);
1014  menu->addAction(action_type_format);
1015  menu->addSeparator();
1016  menu->addAction(action_clear_table);
1017 #ifndef LEGACY_CODE_0_2_x
1018  menu->addAction(action_clear_masks);
1019 #endif
1020  menu->addAction(action_sort_table);
1021  menu->addSeparator();
1022  menu->addAction(action_set_formula);
1023  menu->addAction(action_recalculate);
1024  menu->addSeparator();
1025  menu->addAction(action_add_column);
1026  menu->addAction(action_dimensions_dialog);
1027  menu->addSeparator();
1028  menu->addAction(action_go_to_cell);
1029  if (action_edit_description->text() != tr("Edit Column &Description"))
1031 
1032  return true;
1033 
1034  // TODO:
1035  // Convert to Matrix
1036  // Export
1037 }
1038 
1039 bool Table::fillProjectToolBar(QToolBar * bar)
1040 {
1041  bar->addAction(action_dimensions_dialog);
1042  bar->addAction(action_add_column);
1043  bar->addAction(action_statistics_columns);
1044  bar->addAction(action_statistics_rows);
1045 
1046  return true;
1047 }
1048 
1050 {
1051  QMenu *menu = AbstractPart::createContextMenu();
1052  Q_ASSERT(menu);
1053  menu->addSeparator();
1054 
1055  // TODO
1056  // Export to ASCII
1057  // Print --> maybe should go to AbstractPart::createContextMenu()
1058  // ----
1059  // Rename --> AbstractAspect::createContextMenu(); maybe call this "Properties" and include changing comment/caption spec
1060  // Duplicate --> AbstractPart::createContextMenu()
1061  // Hide/Show --> Do we need hiding of views (in addition to minimizing)? How do we avoid confusion with hiding of Aspects?
1062  // Activate ?
1063  // Resize --> AbstractPart::createContextMenu()
1064 
1065  return menu;
1066 }
1067 
1068 
1070 {
1071  QIcon * icon_temp;
1072 
1073  // selection related actions
1074  action_cut_selection = new QAction(QIcon(QPixmap(":/cut.xpm")), tr("Cu&t"), this);
1075  actionManager()->addAction(action_cut_selection, "cut_selection");
1076 
1077  action_copy_selection = new QAction(QIcon(QPixmap(":/copy.xpm")), tr("&Copy"), this);
1078  actionManager()->addAction(action_copy_selection, "copy_selection");
1079 
1080  action_paste_into_selection = new QAction(QIcon(QPixmap(":/paste.xpm")), tr("Past&e"), this);
1081  actionManager()->addAction(action_paste_into_selection, "paste_into_selection");
1082 
1083 #ifndef LEGACY_CODE_0_2_x
1084  action_mask_selection = new QAction(QIcon(QPixmap(":/mask.xpm")), tr("&Mask","mask selection"), this);
1085  actionManager()->addAction(action_mask_selection, "mask_selection");
1086 
1087  action_unmask_selection = new QAction(QIcon(QPixmap(":/unmask.xpm")), tr("&Unmask","unmask selection"), this);
1088  actionManager()->addAction(action_unmask_selection, "unmask_selection");
1089 #endif
1090 
1091  icon_temp = new QIcon();
1092  icon_temp->addPixmap(QPixmap(":/16x16/fx.png"));
1093  icon_temp->addPixmap(QPixmap(":/32x32/fx.png"));
1094  action_set_formula = new QAction(*icon_temp, tr("Assign &Formula"), this);
1095  action_set_formula->setShortcut(tr("Alt+Q"));
1096  actionManager()->addAction(action_set_formula, "set_formula");
1097  delete icon_temp;
1098 
1099  icon_temp = new QIcon();
1100  icon_temp->addPixmap(QPixmap(":/16x16/clear.png"));
1101  icon_temp->addPixmap(QPixmap(":/32x32/clear.png"));
1102  action_clear_selection = new QAction(*icon_temp, tr("Clea&r","clear selection"), this);
1103  actionManager()->addAction(action_clear_selection, "clear_selection");
1104  delete icon_temp;
1105 
1106  icon_temp = new QIcon();
1107  icon_temp->addPixmap(QPixmap(":/16x16/recalculate.png"));
1108  icon_temp->addPixmap(QPixmap(":/32x32/recalculate.png"));
1109  action_recalculate = new QAction(*icon_temp, tr("Recalculate"), this);
1110  action_recalculate->setShortcut(tr("Ctrl+Return"));
1111  actionManager()->addAction(action_recalculate, "recalculate");
1112  delete icon_temp;
1113 
1114  action_fill_row_numbers = new QAction(QIcon(QPixmap(":/rowNumbers.xpm")), tr("Row Numbers"), this);
1115  actionManager()->addAction(action_fill_row_numbers, "fill_row_numbers");
1116 
1117  action_fill_random = new QAction(QIcon(QPixmap(":/randomNumbers.xpm")), tr("Random Values"), this);
1118  actionManager()->addAction(action_fill_random, "fill_random");
1119 
1120  //table related actions
1121  icon_temp = new QIcon();
1122  icon_temp->addPixmap(QPixmap(":/16x16/table_header.png"));
1123  icon_temp->addPixmap(QPixmap(":/32x32/table_header.png"));
1124  action_toggle_comments = new QAction(*icon_temp, QString("Show/Hide comments"), this); // show/hide column comments
1125  actionManager()->addAction(action_toggle_comments, "toggle_comments");
1126  delete icon_temp;
1127 
1128  icon_temp = new QIcon();
1129  icon_temp->addPixmap(QPixmap(":/16x16/table_options.png"));
1130  icon_temp->addPixmap(QPixmap(":/32x32/table_options.png"));
1131  action_toggle_tabbar = new QAction(*icon_temp, QString("Show/Hide Controls"), this); // show/hide control tabs
1132  action_toggle_tabbar->setShortcut(tr("F12"));
1133  actionManager()->addAction(action_toggle_tabbar, "toggle_tabbar");
1134  delete icon_temp;
1135 
1136  action_formula_mode = new QAction(tr("Formula Edit Mode"), this);
1137  action_formula_mode->setCheckable(true);
1138  actionManager()->addAction(action_formula_mode, "formula_mode");
1139 
1140  icon_temp = new QIcon();
1141  icon_temp->addPixmap(QPixmap(":/16x16/select_all.png"));
1142  icon_temp->addPixmap(QPixmap(":/32x32/select_all.png"));
1143  action_select_all = new QAction(*icon_temp, tr("Select All"), this);
1144  actionManager()->addAction(action_select_all, "select_all");
1145  delete icon_temp;
1146 
1147  icon_temp = new QIcon();
1148  icon_temp->addPixmap(QPixmap(":/16x16/add_column.png"));
1149  icon_temp->addPixmap(QPixmap(":/32x32/add_column.png"));
1150  action_add_column = new QAction(*icon_temp, tr("&Add Column"), this);
1151  action_add_column->setToolTip(tr("append a new column to the table"));
1152  actionManager()->addAction(action_add_column, "add_column");
1153  delete icon_temp;
1154 
1155  icon_temp = new QIcon();
1156  icon_temp->addPixmap(QPixmap(":/16x16/clear_table.png"));
1157  icon_temp->addPixmap(QPixmap(":/32x32/clear_table.png"));
1158  action_clear_table = new QAction(*icon_temp, tr("Clear Table"), this);
1159  actionManager()->addAction(action_clear_table, "clear_table");
1160  delete icon_temp;
1161 
1162  icon_temp = new QIcon();
1163  icon_temp->addPixmap(QPixmap(":/16x16/TeX.png"));
1164  icon_temp->addPixmap(QPixmap(":/32x32/TeX.png"));
1165  action_export_to_TeX = new QAction(*icon_temp, tr("Export to TeX..."), this);
1166  actionManager()->addAction(action_export_to_TeX, "export_to_TeX");
1167  delete icon_temp;
1168 
1169 
1170 #ifndef LEGACY_CODE_0_2_x
1171  action_clear_masks = new QAction(QIcon(QPixmap(":/unmask.xpm")), tr("Clear Masks"), this);
1172  actionManager()->addAction(action_clear_masks, "clear_masks");
1173 #endif
1174 
1175  icon_temp = new QIcon();
1176  icon_temp->addPixmap(QPixmap(":/16x16/sort.png"));
1177  icon_temp->addPixmap(QPixmap(":/32x32/sort.png"));
1178  action_sort_table = new QAction(*icon_temp, tr("&Sort Table"), this);
1179  actionManager()->addAction(action_sort_table, "sort_table");
1180  delete icon_temp;
1181 
1182  icon_temp = new QIcon();
1183  icon_temp->addPixmap(QPixmap(":/16x16/go_to_cell.png"));
1184  icon_temp->addPixmap(QPixmap(":/32x32/go_to_cell.png"));
1185  action_go_to_cell = new QAction(*icon_temp, tr("&Go to Cell"), this);
1186  action_go_to_cell->setShortcut(tr("Ctrl+Alt+G"));
1187  actionManager()->addAction(action_go_to_cell, "go_to_cell");
1188  delete icon_temp;
1189 
1190  action_dimensions_dialog = new QAction(QIcon(QPixmap(":/resize.xpm")), tr("&Dimensions", "table size"), this);
1191  action_dimensions_dialog->setToolTip(tr("change the table size"));
1192  actionManager()->addAction(action_dimensions_dialog, "dimensions_dialog");
1193 
1194  // column related actions
1195  icon_temp = new QIcon();
1196  icon_temp->addPixmap(QPixmap(":/16x16/insert_column.png"));
1197  icon_temp->addPixmap(QPixmap(":/32x32/insert_column.png"));
1198  action_insert_columns = new QAction(*icon_temp, tr("&Insert Empty Columns"), this);
1199  actionManager()->addAction(action_insert_columns, "insert_columns");
1200  delete icon_temp;
1201 
1202  icon_temp = new QIcon();
1203  icon_temp->addPixmap(QPixmap(":/16x16/remove_column.png"));
1204  icon_temp->addPixmap(QPixmap(":/32x32/remove_column.png"));
1205  action_remove_columns = new QAction(*icon_temp, tr("Remo&ve Columns"), this);
1206  actionManager()->addAction(action_remove_columns, "remove_columns");
1207  delete icon_temp;
1208 
1209  icon_temp = new QIcon();
1210  icon_temp->addPixmap(QPixmap(":/16x16/clear_column.png"));
1211  icon_temp->addPixmap(QPixmap(":/32x32/clear_column.png"));
1212  action_clear_columns = new QAction(*icon_temp, tr("Clea&r Columns"), this);
1213  actionManager()->addAction(action_clear_columns, "clear_columns");
1214  delete icon_temp;
1215 
1216  icon_temp = new QIcon();
1217  icon_temp->addPixmap(QPixmap(":/16x16/add_columns.png"));
1218  icon_temp->addPixmap(QPixmap(":/32x32/add_columns.png"));
1219  action_add_columns = new QAction(*icon_temp, tr("&Add Columns"), this);
1220  actionManager()->addAction(action_add_columns, "add_columns");
1221  delete icon_temp;
1222 
1223  action_set_as_x = new QAction(QIcon(QPixmap()), tr("X","plot designation"), this);
1224  actionManager()->addAction(action_set_as_x, "set_as_x");
1225 
1226  action_set_as_y = new QAction(QIcon(QPixmap()), tr("Y","plot designation"), this);
1227  actionManager()->addAction(action_set_as_y, "set_as_y");
1228 
1229  action_set_as_z = new QAction(QIcon(QPixmap()), tr("Z","plot designation"), this);
1230  actionManager()->addAction(action_set_as_z, "set_as_z");
1231 
1232  icon_temp = new QIcon();
1233  icon_temp->addPixmap(QPixmap(":/16x16/x_error.png"));
1234  icon_temp->addPixmap(QPixmap(":/32x32/x_error.png"));
1235  action_set_as_xerr = new QAction(*icon_temp, tr("X Error","plot designation"), this);
1236  actionManager()->addAction(action_set_as_xerr, "set_as_xerr");
1237  delete icon_temp;
1238 
1239  icon_temp = new QIcon();
1240  icon_temp->addPixmap(QPixmap(":/16x16/y_error.png"));
1241  icon_temp->addPixmap(QPixmap(":/32x32/y_error.png"));
1242  action_set_as_yerr = new QAction(*icon_temp, tr("Y Error","plot designation"), this);
1243  actionManager()->addAction(action_set_as_yerr, "set_as_yerr");
1244  delete icon_temp;
1245 
1246  action_set_as_none = new QAction(QIcon(QPixmap()), tr("None","plot designation"), this);
1247  actionManager()->addAction(action_set_as_none, "set_as_none");
1248 
1249  icon_temp = new QIcon();
1250  icon_temp->addPixmap(QPixmap(":/16x16/normalize.png"));
1251  icon_temp->addPixmap(QPixmap(":/32x32/normalize.png"));
1252  action_normalize_columns = new QAction(*icon_temp, tr("&Normalize Columns"), this);
1253  actionManager()->addAction(action_normalize_columns, "normalize_columns");
1254  delete icon_temp;
1255 
1256  icon_temp = new QIcon();
1257  icon_temp->addPixmap(QPixmap(":/16x16/normalize.png"));
1258  icon_temp->addPixmap(QPixmap(":/32x32/normalize.png"));
1259  action_normalize_selection = new QAction(*icon_temp, tr("&Normalize Selection"), this);
1260  actionManager()->addAction(action_normalize_selection, "normalize_selection");
1261  delete icon_temp;
1262 
1263  icon_temp = new QIcon();
1264  icon_temp->addPixmap(QPixmap(":/16x16/sort.png"));
1265  icon_temp->addPixmap(QPixmap(":/32x32/sort.png"));
1266  action_sort_columns = new QAction(*icon_temp, tr("&Sort Columns"), this);
1267  actionManager()->addAction(action_sort_columns, "sort_columns");
1268  delete icon_temp;
1269 
1270  action_statistics_columns = new QAction(QIcon(QPixmap(":/col_stat.xpm")), tr("Column Statisti&cs"), this);
1271  action_statistics_columns->setToolTip(tr("statistics on columns"));
1272  actionManager()->addAction(action_statistics_columns, "statistics_columns");
1273 
1274  icon_temp = new QIcon();
1275  icon_temp->addPixmap(QPixmap(":/16x16/column_format_type.png"));
1276  icon_temp->addPixmap(QPixmap(":/32x32/column_format_type.png"));
1277  action_type_format = new QAction(*icon_temp, tr("Change &Type && Format"), this);
1278  action_type_format->setShortcut(tr("Ctrl+Alt+O"));
1279  actionManager()->addAction(action_type_format, "type_format");
1280  delete icon_temp;
1281 
1282  icon_temp = new QIcon();
1283  icon_temp->addPixmap(QPixmap(":/16x16/column_description.png"));
1284  icon_temp->addPixmap(QPixmap(":/32x32/column_description.png"));
1285  action_edit_description = new QAction(*icon_temp, tr("Edit Column &Description"), this);
1286  actionManager()->addAction(action_edit_description, "edit_description");
1287  delete icon_temp;
1288 
1289  // row related actions
1290  icon_temp = new QIcon();
1291  icon_temp->addPixmap(QPixmap(":/16x16/insert_row.png"));
1292  icon_temp->addPixmap(QPixmap(":/32x32/insert_row.png"));
1293  action_insert_rows = new QAction(*icon_temp ,tr("&Insert Empty Rows"), this);
1294  actionManager()->addAction(action_insert_rows, "insert_rows");
1295  delete icon_temp;
1296 
1297  icon_temp = new QIcon();
1298  icon_temp->addPixmap(QPixmap(":/16x16/remove_row.png"));
1299  icon_temp->addPixmap(QPixmap(":/32x32/remove_row.png"));
1300  action_remove_rows = new QAction(*icon_temp, tr("Remo&ve Rows"), this);
1301  actionManager()->addAction(action_remove_rows, "remove_rows");
1302  delete icon_temp;
1303 
1304  icon_temp = new QIcon();
1305  icon_temp->addPixmap(QPixmap(":/16x16/clear_row.png"));
1306  icon_temp->addPixmap(QPixmap(":/32x32/clear_row.png"));
1307  action_clear_rows = new QAction(*icon_temp, tr("Clea&r Rows"), this);
1308  actionManager()->addAction(action_clear_rows, "clear_rows");
1309  delete icon_temp;
1310 
1311  icon_temp = new QIcon();
1312  icon_temp->addPixmap(QPixmap(":/16x16/add_rows.png"));
1313  icon_temp->addPixmap(QPixmap(":/32x32/add_rows.png"));
1314  action_add_rows = new QAction(*icon_temp, tr("&Add Rows"), this);
1315  actionManager()->addAction(action_add_rows, "add_rows");
1316  delete icon_temp;
1317 
1318  action_statistics_rows = new QAction(QIcon(QPixmap(":/stat_rows.xpm")), tr("Row Statisti&cs"), this);
1319  action_statistics_rows->setToolTip(tr("statistics on rows"));
1320  actionManager()->addAction(action_statistics_rows, "statistics_rows");
1321 }
1322 
1324 {
1325  connect(action_cut_selection, SIGNAL(triggered()), this, SLOT(cutSelection()));
1326  connect(action_copy_selection, SIGNAL(triggered()), this, SLOT(copySelection()));
1327  connect(action_paste_into_selection, SIGNAL(triggered()), this, SLOT(pasteIntoSelection()));
1328 #ifndef LEGACY_CODE_0_2_x
1329  connect(action_mask_selection, SIGNAL(triggered()), this, SLOT(maskSelection()));
1330  connect(action_unmask_selection, SIGNAL(triggered()), this, SLOT(unmaskSelection()));
1331 #endif
1332  connect(action_set_formula, SIGNAL(triggered()), this, SLOT(setFormulaForSelection()));
1333  connect(action_clear_selection, SIGNAL(triggered()), this, SLOT(clearSelectedCells()));
1334  connect(action_recalculate, SIGNAL(triggered()), this, SLOT(recalculateSelectedCells()));
1335  connect(action_fill_row_numbers, SIGNAL(triggered()), this, SLOT(fillSelectedCellsWithRowNumbers()));
1336  connect(action_fill_random, SIGNAL(triggered()), this, SLOT(fillSelectedCellsWithRandomNumbers()));
1337  connect(action_select_all, SIGNAL(triggered()), this, SLOT(selectAll()));
1338  connect(action_add_column, SIGNAL(triggered()), this, SLOT(addColumn()));
1339  connect(action_clear_table, SIGNAL(triggered()), this, SLOT(clear()));
1340 
1341  //Export to TeX
1342  connect(action_export_to_TeX, SIGNAL( triggered() ), this, SLOT( showTeXTableExportDialog() ) );
1343 
1344 #ifndef LEGACY_CODE_0_2_x
1345  connect(action_clear_masks, SIGNAL(triggered()), this, SLOT(clearMasks()));
1346 #endif
1347  connect(action_sort_table, SIGNAL(triggered()), this, SLOT(sortTable()));
1348  connect(action_go_to_cell, SIGNAL(triggered()), this, SLOT(goToCell()));
1349  connect(action_dimensions_dialog, SIGNAL(triggered()), this, SLOT(dimensionsDialog()));
1350  connect(action_insert_columns, SIGNAL(triggered()), this, SLOT(insertEmptyColumns()));
1351  connect(action_remove_columns, SIGNAL(triggered()), this, SLOT(removeSelectedColumns()));
1352  connect(action_clear_columns, SIGNAL(triggered()), this, SLOT(clearSelectedColumns()));
1353  connect(action_add_columns, SIGNAL(triggered()), this, SLOT(addColumns()));
1354  connect(action_set_as_x, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsX()));
1355  connect(action_set_as_y, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsY()));
1356  connect(action_set_as_z, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsZ()));
1357  connect(action_set_as_xerr, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsXError()));
1358  connect(action_set_as_yerr, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsYError()));
1359  connect(action_set_as_none, SIGNAL(triggered()), this, SLOT(setSelectedColumnsAsNone()));
1360  connect(action_normalize_columns, SIGNAL(triggered()), this, SLOT(normalizeSelectedColumns()));
1361  connect(action_normalize_selection, SIGNAL(triggered()), this, SLOT(normalizeSelection()));
1362  connect(action_sort_columns, SIGNAL(triggered()), this, SLOT(sortSelectedColumns()));
1363  connect(action_statistics_columns, SIGNAL(triggered()), this, SLOT(statisticsOnSelectedColumns()));
1364  connect(action_type_format, SIGNAL(triggered()), this, SLOT(editTypeAndFormatOfSelectedColumns()));
1365  connect(action_edit_description, SIGNAL(triggered()), this, SLOT(editDescriptionOfCurrentColumn()));
1366  connect(action_insert_rows, SIGNAL(triggered()), this, SLOT(insertEmptyRows()));
1367  connect(action_remove_rows, SIGNAL(triggered()), this, SLOT(removeSelectedRows()));
1368  connect(action_clear_rows, SIGNAL(triggered()), this, SLOT(clearSelectedCells()));
1369  connect(action_add_rows, SIGNAL(triggered()), this, SLOT(addRows()));
1370  connect(action_statistics_rows, SIGNAL(triggered()), this, SLOT(statisticsOnSelectedRows()));
1371 }
1372 
1374 {
1375  connect(action_toggle_comments, SIGNAL(triggered()), d_view, SLOT(toggleComments()));
1376  connect(action_toggle_tabbar, SIGNAL(triggered()), d_view, SLOT(toggleControlTabBar()));
1377  connect(action_formula_mode, SIGNAL(toggled(bool)), d_view, SLOT(activateFormulaMode(bool)));
1378 
1379  d_view->addAction(action_cut_selection);
1380  d_view->addAction(action_copy_selection);
1381  d_view->addAction(action_paste_into_selection);
1382 #ifndef LEGACY_CODE_0_2_x
1383  d_view->addAction(action_mask_selection);
1384  d_view->addAction(action_unmask_selection);
1385 #endif
1386  d_view->addAction(action_set_formula);
1387  d_view->addAction(action_clear_selection);
1388  d_view->addAction(action_recalculate);
1389  d_view->addAction(action_fill_row_numbers);
1390  d_view->addAction(action_fill_random);
1391  d_view->addAction(action_toggle_comments);
1392  d_view->addAction(action_toggle_tabbar);
1393  d_view->addAction(action_formula_mode);
1394  d_view->addAction(action_select_all);
1395  d_view->addAction(action_add_column);
1396  d_view->addAction(action_clear_table);
1397  d_view->addAction(action_export_to_TeX);
1398 #ifndef LEGACY_CODE_0_2_x
1399  d_view->addAction(action_clear_masks);
1400 #endif
1401  d_view->addAction(action_sort_table);
1402  d_view->addAction(action_go_to_cell);
1403  d_view->addAction(action_dimensions_dialog);
1404  d_view->addAction(action_insert_columns);
1405  d_view->addAction(action_remove_columns);
1406  d_view->addAction(action_clear_columns);
1407  d_view->addAction(action_add_columns);
1408  d_view->addAction(action_set_as_x);
1409  d_view->addAction(action_set_as_y);
1410  d_view->addAction(action_set_as_z);
1411  d_view->addAction(action_set_as_xerr);
1412  d_view->addAction(action_set_as_yerr);
1413  d_view->addAction(action_set_as_none);
1414  d_view->addAction(action_normalize_columns);
1415  d_view->addAction(action_normalize_selection);
1416  d_view->addAction(action_sort_columns);
1417  d_view->addAction(action_statistics_columns);
1418  d_view->addAction(action_type_format);
1419  d_view->addAction(action_edit_description);
1420  d_view->addAction(action_insert_rows);
1421  d_view->addAction(action_remove_rows);
1422  d_view->addAction(action_clear_rows);
1423  d_view->addAction(action_add_rows);
1424  d_view->addAction(action_statistics_rows);
1425 }
1426 
1428 {
1429  action_cut_selection->setText(tr("Cu&t"));
1430  action_copy_selection->setText(tr("&Copy"));
1431  action_paste_into_selection->setText(tr("Past&e"));
1432 #ifndef LEGACY_CODE_0_2_x
1433  action_mask_selection->setText(tr("&Mask","mask selection"));
1434  action_unmask_selection->setText(tr("&Unmask","unmask selection"));
1435  action_clear_masks->setText(tr("Clear Masks"));
1436 #endif
1437  action_set_formula->setText(tr("Assign &Formula"));
1438  action_clear_selection->setText(tr("Clea&r","clear selection"));
1439  action_recalculate->setText(tr("Recalculate"));
1440  action_fill_row_numbers->setText(tr("Row Numbers"));
1441  action_fill_random->setText(tr("Random Values"));
1442  action_formula_mode->setText(tr("Formula Edit Mode"));
1443  action_select_all->setText(tr("Select All"));
1444  action_add_column->setText(tr("&Add Column"));
1445  action_clear_table->setText(tr("Clear Table"));
1446  action_export_to_TeX->setText(tr("Export to TeX..."));
1447  action_sort_table->setText(tr("&Sort Table"));
1448  action_go_to_cell->setText(tr("&Go to Cell"));
1449  action_dimensions_dialog->setText(tr("&Dimensions", "table size"));
1450  action_insert_columns->setText(tr("&Insert Empty Columns"));
1451  action_remove_columns->setText(tr("Remo&ve Columns"));
1452  action_clear_columns->setText(tr("Clea&r Columns"));
1453  action_add_columns->setText(tr("&Add Columns"));
1454  action_set_as_x->setText(tr("X","plot designation"));
1455  action_set_as_y->setText(tr("Y","plot designation"));
1456  action_set_as_z->setText(tr("Z","plot designation"));
1457  action_set_as_xerr->setText(tr("X Error","plot designation"));
1458  action_set_as_yerr->setText(tr("Y Error","plot designation"));
1459  action_set_as_none->setText(tr("None","plot designation"));
1460  action_normalize_columns->setText(tr("&Normalize Columns"));
1461  action_normalize_selection->setText(tr("&Normalize Selection"));
1462  action_sort_columns->setText(tr("&Sort Columns"));
1463  action_statistics_columns->setText(tr("Column Statisti&cs"));
1464  action_type_format->setText(tr("Change &Type && Format"));
1465  action_edit_description->setText(tr("Edit Column &Description"));
1466  action_insert_rows->setText(tr("&Insert Empty Rows"));
1467  action_remove_rows->setText(tr("Remo&ve Rows"));
1468  action_clear_rows->setText(tr("Clea&r Rows"));
1469  action_add_rows->setText(tr("&Add Rows"));
1470  action_statistics_rows->setText(tr("Row Statisti&cs"));
1471 }
1472 void Table::showTableViewContextMenu(const QPoint& pos)
1473 {
1474  if (!d_view) return;
1475  QMenu context_menu;
1476 
1477 // TODO: Does undo/redo really be belong into a context menu?
1478 // context_menu.addAction(undoAction(&context_menu));
1479 // context_menu.addAction(redoAction(&context_menu));
1480 
1481  if(d_plot_menu)
1482  {
1483  context_menu.addMenu(d_plot_menu);
1484  context_menu.addSeparator();
1485  }
1486 
1487  createSelectionMenu(&context_menu);
1488  context_menu.addSeparator();
1489  createTableMenu(&context_menu);
1490  context_menu.addSeparator();
1491 
1492  context_menu.exec(pos);
1493 }
1494 
1496 {
1497  if (!d_view) return;
1498  QMenu context_menu;
1499 
1500 // TODO: Does undo/redo really be belong into a context menu?
1501 // context_menu.addAction(undoAction(&context_menu));
1502 // context_menu.addAction(redoAction(&context_menu));
1503 
1504  if(d_plot_menu)
1505  {
1506  context_menu.addMenu(d_plot_menu);
1507  context_menu.addSeparator();
1508  }
1509 
1510  createColumnMenu(&context_menu);
1511  context_menu.addSeparator();
1512 
1513  context_menu.exec(pos);
1514 }
1515 
1516 void Table::showTableViewRowContextMenu(const QPoint& pos)
1517 {
1518  if (!d_view) return;
1519  QMenu context_menu;
1520 
1521 // TODO: Does undo/redo really be belong into a context menu?
1522 // context_menu.addAction(undoAction(&context_menu));
1523 // context_menu.addAction(redoAction(&context_menu));
1524 
1525  createRowMenu(&context_menu);
1526 
1527  context_menu.exec(pos);
1528 }
1529 
1531 {
1532  TeXTableExportDialog export_Dialog;
1533 
1534  export_Dialog.setFileMode(QFileDialog::AnyFile);
1535  export_Dialog.setNameFilter("*.tex");
1536 
1537  //Set the default file name by the name of the table
1538  export_Dialog.selectFile( name() );
1539 
1540  export_Dialog.exec();
1541 
1542  if (export_Dialog.result() == QDialog::Accepted)
1543  {
1544  // Get file name
1545  QString fileName = export_Dialog.selectedFiles().first();
1546 
1547  //Add file extention
1548  fileName += export_Dialog.selectedNameFilter().remove( 0, 1 );
1549 
1550  //Get TeX table settings
1551  TeXTableSettings tex_settings = export_Dialog.tex_TableSettings();
1552 
1553  //Export to TeX table
1554  export_to_TeX( fileName, tex_settings );
1555  }
1556 
1557 }
1558 
1559 bool Table::export_to_TeX( QString fileName, TeXTableSettings& tex_settings )
1560 {
1561 
1562  WAIT_CURSOR;
1563 
1564  QFile file( fileName );
1565 
1566  if (!file.open( QIODevice::WriteOnly ))
1567  {
1568  QApplication::restoreOverrideCursor();
1569  QMessageBox::critical(0, tr("TeX Export Error"),
1570  tr("Could not write to file: <br><h4>%1</h4><p>Please verify that you have the right to write to this location!").arg(fileName));
1571  return false;
1572  }
1573 
1574 
1575  QList< Column* > columns_list;
1576  int first_row_index = 0;
1577  int last_row_index = 0;
1578 
1579 
1580  if (d_view->selectedColumnCount() != 0)
1581  {
1582  //Get selected columns
1583  for (int i = 0; i < columnCount(); i++)
1584  {
1585  if (d_view->isColumnSelected( i ))
1586  columns_list << column( i );
1587  }
1588 
1589  // Get the first and last selected row index
1590  first_row_index = d_view->firstSelectedRow();
1591  last_row_index = d_view->lastSelectedRow();
1592  }
1593  else
1594  {
1595  //Get all columns
1596  for( int i = 0; i < columnCount(); i++ )
1597  columns_list << column( i );
1598 
1599  // Get the first and last row index
1600  first_row_index = 0;
1601  if( rowCount() > 0 ) last_row_index = rowCount()-1;
1602  else last_row_index = 0;
1603  }
1604 
1605  // Get the TeX column alignment
1606  char cl_alignment = 'c';
1607  if (tex_settings.columnsAlignment() == ALIGN_LEFT) cl_alignment = 'l';
1608  else if (tex_settings.columnsAlignment() == ALIGN_RIGHT) cl_alignment = 'r';
1609 
1610  QTextStream out(&file);
1611 
1612  //Check whether the TeX table should have caption
1613  if (tex_settings.with_caption())
1614  out << "\\begin{table} \n \\caption{" << name() << "}\n";
1615 
1616  //begin tabular with all parameters
1617  out << QString("\\begin{tabular}{|*{") + QString().setNum( columns_list.count() )
1618  + ("}{") + QString(cl_alignment) + QString("|}}\n");
1619  out << "\\hline \n";
1620 
1621  //Check if export with table labels
1622  if (tex_settings.with_labels())
1623  {
1624  //Get the columns labes
1625  QStringList columns_labels;
1626  foreach (Column* col, columns_list) columns_labels << col->name();
1627  out << columns_labels.join(" & ") << "\\\\ \\hline \n";
1628  }
1629 
1630 
1631  //Export TeX table content
1632  QStringList str_row;
1633  for ( int row_index = first_row_index; row_index < last_row_index+1; row_index++)
1634  {
1635  str_row.clear();
1636  foreach( Column* col, columns_list )
1637  str_row << col->asStringColumn()->textAt( row_index );
1638  out << str_row.join(" & ") << " \\\\ \\hline \n ";
1639  }
1640 
1641  out << "\\end{tabular} \n";
1642 
1643  if( tex_settings.with_caption() ) out << "\\end{table} \n";
1644 
1645  RESET_CURSOR;
1646 
1647  return true;
1648 }
1649 
1650 
1651 
1652 
1653 QMenu * Table::createSelectionMenu(QMenu * append_to)
1654 {
1655  QMenu * menu = append_to;
1656  if(!menu)
1657  menu = new QMenu();
1658 
1659  QMenu * submenu = new QMenu(tr("Fi&ll Selection with"));
1660  submenu->addAction(action_fill_row_numbers);
1661  submenu->addAction(action_fill_random);
1662  menu->addMenu(submenu);
1663  menu->addSeparator();
1664 
1665  menu->addAction(action_cut_selection);
1666  menu->addAction(action_copy_selection);
1667  menu->addAction(action_paste_into_selection);
1668  menu->addAction(action_clear_selection);
1669  menu->addSeparator();
1670 #ifndef LEGACY_CODE_0_2_x
1671  menu->addAction(action_mask_selection);
1672  menu->addAction(action_unmask_selection);
1673  menu->addSeparator();
1674 #endif
1675  menu->addAction(action_normalize_selection);
1676  menu->addSeparator();
1677  menu->addAction(action_set_formula);
1678  menu->addAction(action_recalculate);
1679  menu->addSeparator();
1680 
1681  return menu;
1682 }
1683 
1684 
1685 QMenu * Table::createColumnMenu(QMenu * append_to)
1686 {
1687  QMenu * menu = append_to;
1688  if(!menu)
1689  menu = new QMenu();
1690 
1691  QMenu * submenu = new QMenu(tr("S&et Column(s) As"));
1692  submenu->addAction(action_set_as_x);
1693  submenu->addAction(action_set_as_y);
1694  submenu->addAction(action_set_as_z);
1695  submenu->addSeparator();
1696  submenu->addAction(action_set_as_xerr);
1697  submenu->addAction(action_set_as_yerr);
1698  submenu->addSeparator();
1699  submenu->addAction(action_set_as_none);
1700  menu->addMenu(submenu);
1701  menu->addSeparator();
1702 
1703  submenu = new QMenu(tr("Fi&ll Selection with"));
1704  submenu->addAction(action_fill_row_numbers);
1705  submenu->addAction(action_fill_random);
1706  menu->addMenu(submenu);
1707  menu->addSeparator();
1708 
1709  menu->addAction(action_insert_columns);
1710  menu->addAction(action_remove_columns);
1711  menu->addAction(action_clear_columns);
1712  menu->addAction(action_add_columns);
1713  menu->addSeparator();
1714 
1715  menu->addAction(action_normalize_columns);
1716  menu->addAction(action_sort_columns);
1717  menu->addSeparator();
1718 
1719  menu->addAction(action_edit_description);
1720  menu->addAction(action_type_format);
1721  connect(menu, SIGNAL(aboutToShow()), this, SLOT(adjustActionNames()));
1722  menu->addAction(action_toggle_comments);
1723  menu->addSeparator();
1724 
1725  menu->addAction(action_statistics_columns);
1726 
1727  return menu;
1728 }
1729 
1730 QMenu * Table::createTableMenu(QMenu * append_to)
1731 {
1732  QMenu * menu = append_to;
1733  if(!menu)
1734  menu = new QMenu();
1735 
1736  connect(menu, SIGNAL(aboutToShow()), this, SLOT(adjustActionNames()));
1737  menu->addAction(action_toggle_comments);
1738  menu->addAction(action_toggle_tabbar);
1739  menu->addAction(action_formula_mode);
1740  menu->addSeparator();
1741  menu->addAction(action_select_all);
1742  menu->addAction(action_clear_table);
1743  menu->addAction(action_export_to_TeX);
1744 #ifndef LEGACY_CODE_0_2_x
1745  menu->addAction(action_clear_masks);
1746  menu->addAction(action_sort_table);
1747 #endif
1748  menu->addSeparator();
1749  menu->addAction(action_add_column);
1750  menu->addSeparator();
1751  menu->addAction(action_go_to_cell);
1752 
1753  return menu;
1754 }
1755 
1756 QMenu * Table::createRowMenu(QMenu * append_to)
1757 {
1758  QMenu * menu = append_to;
1759  if(!menu)
1760  menu = new QMenu();
1761 
1762  menu->addAction(action_insert_rows);
1763  menu->addAction(action_remove_rows);
1764  menu->addAction(action_clear_rows);
1765  menu->addAction(action_add_rows);
1766  menu->addSeparator();
1767  QMenu *submenu = new QMenu(tr("Fi&ll Selection with"));
1768  submenu->addAction(action_fill_row_numbers);
1769  submenu->addAction(action_fill_random);
1770  menu->addMenu(submenu);
1771  menu->addSeparator();
1772  menu->addAction(action_statistics_rows);
1773 
1774  return menu;
1775 }
1776 
1778 {
1779  if (!d_view) return;
1780  bool ok;
1781 
1782  int col = QInputDialog::getInt(0, tr("Go to Cell"), tr("Enter column"),
1783  1, 1, columnCount(), 1, &ok);
1784  if ( !ok ) return;
1785 
1786  int row = QInputDialog::getInt(0, tr("Go to Cell"), tr("Enter row"),
1787  1, 1, rowCount(), 1, &ok);
1788  if ( !ok ) return;
1789 
1790  d_view->goToCell(row-1, col-1);
1791 }
1792 
1794 {
1795  Ui::DimensionsDialog ui;
1796  QDialog dialog;
1797  ui.setupUi(&dialog);
1798  dialog.setWindowTitle(tr("Set Table Dimensions"));
1799  ui.columnsSpinBox->setValue(columnCount());
1800  ui.rowsSpinBox->setValue(rowCount());
1801  connect(ui.buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
1802  connect(ui.buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
1803 
1804  if (dialog.exec())
1805  {
1806  setColumnCount(ui.columnsSpinBox->value());
1807  setRowCount(ui.rowsSpinBox->value());
1808  }
1809 }
1810 
1811 void Table::moveColumn(int from, int to)
1812 {
1813  beginMacro(tr("%1: move column %2 from position %3 to %4.").arg(name()).arg(d_table_private.column(from)->name()).arg(from+1).arg(to+1));
1814  moveChild(from, to);
1815  exec(new TableMoveColumnCmd(d_table_private, from, to));
1816  endMacro();
1817 }
1818 
1819 void Table::copy(Table * other)
1820 {
1821  WAIT_CURSOR;
1822  beginMacro(QObject::tr("%1: copy %2").arg(name()).arg(other->name()));
1823 
1824  removeColumns(0, columnCount());
1825  QList<Column *> columns;
1826  for (int i=0; i<other->columnCount(); i++)
1827  {
1828  Column * src_col = other->column(i);
1829  Column * new_col = new Column(src_col->name(), src_col->columnMode());
1830  new_col->copy(src_col);
1831  new_col->setPlotDesignation(src_col->plotDesignation());
1832  QList< Interval<int> > masks = src_col->maskedIntervals();
1833  foreach(Interval<int> iv, masks)
1834  new_col->setMasked(iv);
1835  QList< Interval<int> > formulas = src_col->formulaIntervals();
1836  foreach(Interval<int> iv, formulas)
1837  new_col->setFormula(iv, src_col->formula(iv.start()));
1838  columns.append(new_col);
1839  }
1840  appendColumns(columns);
1841  setCaptionSpec(other->captionSpec());
1842  setComment(other->comment());
1843  for (int i=0; i<columnCount(); i++)
1844  setColumnWidth(i, other->columnWidth(i));
1845  if (d_view) d_view->rereadSectionSizes();
1846 
1847  endMacro();
1848  RESET_CURSOR;
1849 }
1850 
1851 int Table::colX(int col)
1852 {
1853  for(int i=col-1; i>=0; i--)
1854  {
1855  if (column(i)->plotDesignation() == SciDAVis::X)
1856  return i;
1857  }
1858  int cols = columnCount();
1859  for(int i=col+1; i<cols; i++)
1860  {
1861  if (column(i)->plotDesignation() == SciDAVis::X)
1862  return i;
1863  }
1864  return -1;
1865 }
1866 
1867 int Table::colY(int col)
1868 {
1869  int cols = columnCount();
1870 
1871  if (column(col)->plotDesignation() == SciDAVis::xErr ||
1872  column(col)->plotDesignation() == SciDAVis::yErr) {
1873  // look to the left first
1874  for(int i=col-1; i>=0; i--) {
1875  if (column(i)->plotDesignation() == SciDAVis::Y)
1876  return i;
1877  }
1878  for(int i=col+1; i<cols; i++) {
1879  if (column(i)->plotDesignation() == SciDAVis::Y)
1880  return i;
1881  }
1882  } else {
1883  // look to the right first
1884  for(int i=col+1; i<cols; i++) {
1885  if (column(i)->plotDesignation() == SciDAVis::Y)
1886  return i;
1887  }
1888  for(int i=col-1; i>=0; i--) {
1889  if (column(i)->plotDesignation() == SciDAVis::Y)
1890  return i;
1891  }
1892  }
1893  return -1;
1894 }
1895 
1896 void Table::setPlotMenu(QMenu * menu)
1897 {
1898  d_plot_menu = menu;
1899 }
1900 
1901 void Table::sortDialog(QList<Column*> cols)
1902 {
1903  if(cols.isEmpty()) return;
1904 
1905  SortDialog *sortd = new future::SortDialog();
1906  sortd->setAttribute(Qt::WA_DeleteOnClose);
1907  connect(sortd, SIGNAL(sort(Column*,QList<Column*>,bool)), this, SLOT(sortColumns(Column*,QList<Column*>,bool)));
1908  sortd->setColumnsList(cols);
1909  sortd->exec();
1910 }
1911 
1912 
1913 void Table::sortColumns(Column *leading, QList<Column*> cols, bool ascending)
1914 {
1915  if(cols.isEmpty()) return;
1916 
1917  // the normal QPair comparison does not work properly with descending sorting
1918  // thefore we use our own compare functions
1919  class CompareFunctions{
1920  public:
1921  static bool doubleLess(const QPair<double, int>& a, const QPair<double, int>& b)
1922  {
1923  return a.first < b.first;
1924  }
1925  static bool doubleGreater(const QPair<double, int>& a, const QPair<double, int>& b)
1926  {
1927  return a.first > b.first;
1928  }
1929  static bool QStringLess(const QPair<QString, int>& a, const QPair<QString, int>& b)
1930  {
1931  return a < b;
1932  }
1933  static bool QStringGreater(const QPair<QString, int>& a, const QPair<QString, int>& b)
1934  {
1935  return a > b;
1936  }
1937  static bool QDateTimeLess(const QPair<QDateTime, int>& a, const QPair<QDateTime, int>& b)
1938  {
1939  return a < b;
1940  }
1941  static bool QDateTimeGreater(const QPair<QDateTime, int>& a, const QPair<QDateTime, int>& b)
1942  {
1943  return a > b;
1944  }
1945  };
1946 
1947  WAIT_CURSOR;
1948  beginMacro(tr("%1: sort column(s)").arg(name()));
1949 
1950  if(leading == 0) // sort separately
1951  {
1952  for(int i=0; i<cols.size(); i++)
1953  {
1954  Column* col = cols.at(i);
1955 
1956  if(col->dataType() == SciDAVis::TypeDouble)
1957  {
1958  int rows = col->rowCount();
1959  QList< QPair<double, int> > map;
1960 
1961  for(int j=0; j<rows; j++)
1962  map.append(QPair<double, int>(col->valueAt(j), j));
1963 
1964  if(ascending)
1965  qStableSort(map.begin(), map.end(), CompareFunctions::doubleLess);
1966  else
1967  qStableSort(map.begin(), map.end(), CompareFunctions::doubleGreater);
1968 
1969  QListIterator< QPair<double, int> > it(map);
1970  Column *temp_col = new Column("temp", col->columnMode());
1971 
1972  int k=0;
1973  // put the values in the right order into temp_col
1974  while(it.hasNext())
1975  {
1976  temp_col->copy(col, it.peekNext().second, k, 1);
1977  temp_col->setMasked(col->isMasked(it.next().second));
1978  k++;
1979  }
1980  // copy the sorted column
1981  col->copy(temp_col, 0, 0, rows);
1982  delete temp_col;
1983  }
1984  else if(col->dataType() == SciDAVis::TypeQString)
1985  {
1986  int rows = col->rowCount();
1987  QList< QPair<QString, int> > map;
1988 
1989  for(int j=0; j<rows; j++)
1990  map.append(QPair<QString, int>(col->textAt(j), j));
1991 
1992  if(ascending)
1993  qStableSort(map.begin(), map.end(), CompareFunctions::QStringLess);
1994  else
1995  qStableSort(map.begin(), map.end(), CompareFunctions::QStringGreater);
1996 
1997  QListIterator< QPair<QString, int> > it(map);
1998  Column *temp_col = new Column("temp", col->columnMode());
1999 
2000  int k=0;
2001  // put the values in the right order into temp_col
2002  while(it.hasNext())
2003  {
2004  temp_col->copy(col, it.peekNext().second, k, 1);
2005  temp_col->setMasked(col->isMasked(it.next().second));
2006  k++;
2007  }
2008  // copy the sorted column
2009  col->copy(temp_col, 0, 0, rows);
2010  delete temp_col;
2011  }
2012  else if(col->dataType() == SciDAVis::TypeQDateTime)
2013  {
2014  int rows = col->rowCount();
2015  QList< QPair<QDateTime, int> > map;
2016 
2017  for(int j=0; j<rows; j++)
2018  map.append(QPair<QDateTime, int>(col->dateTimeAt(j), j));
2019 
2020  if(ascending)
2021  qStableSort(map.begin(), map.end(), CompareFunctions::QDateTimeLess);
2022  else
2023  qStableSort(map.begin(), map.end(), CompareFunctions::QDateTimeGreater);
2024 
2025  QListIterator< QPair<QDateTime, int> > it(map);
2026  Column *temp_col = new Column("temp", col->columnMode());
2027 
2028  int k=0;
2029  // put the values in the right order into temp_col
2030  while(it.hasNext())
2031  {
2032  temp_col->copy(col, it.peekNext().second, k, 1);
2033  temp_col->setMasked(col->isMasked(it.next().second));
2034  k++;
2035  }
2036  // copy the sorted column
2037  col->copy(temp_col, 0, 0, rows);
2038  delete temp_col;
2039  }
2040  }
2041 
2042  }
2043  else // sort with leading column
2044  {
2045  if(leading->dataType() == SciDAVis::TypeDouble)
2046  {
2047  QList< QPair<double, int> > map;
2048  int rows = leading->rowCount();
2049 
2050  for(int i=0; i<rows; i++)
2051  map.append(QPair<double, int>(leading->valueAt(i), i));
2052 
2053  if(ascending)
2054  qStableSort(map.begin(), map.end(), CompareFunctions::doubleLess);
2055  else
2056  qStableSort(map.begin(), map.end(), CompareFunctions::doubleGreater);
2057  QListIterator< QPair<double, int> > it(map);
2058 
2059  for(int i=0; i<cols.size(); i++)
2060  {
2061  Column *temp_col = new Column("temp", cols.at(i)->columnMode());
2062  it.toFront();
2063  int j=0;
2064  // put the values in the right order into temp_col
2065  while(it.hasNext())
2066  {
2067  temp_col->copy(cols.at(i), it.peekNext().second, j, 1);
2068  temp_col->setMasked(cols.at(i)->isMasked(it.next().second));
2069  j++;
2070  }
2071  // copy the sorted column
2072  cols.at(i)->copy(temp_col, 0, 0, rows);
2073  delete temp_col;
2074  }
2075  }
2076  else if(leading->dataType() == SciDAVis::TypeQString)
2077  {
2078  QList< QPair<QString, int> > map;
2079  int rows = leading->rowCount();
2080 
2081  for(int i=0; i<rows; i++)
2082  map.append(QPair<QString, int>(leading->textAt(i), i));
2083 
2084  if(ascending)
2085  qStableSort(map.begin(), map.end(), CompareFunctions::QStringLess);
2086  else
2087  qStableSort(map.begin(), map.end(), CompareFunctions::QStringGreater);
2088  QListIterator< QPair<QString, int> > it(map);
2089 
2090  for(int i=0; i<cols.size(); i++)
2091  {
2092  Column *temp_col = new Column("temp", cols.at(i)->columnMode());
2093  it.toFront();
2094  int j=0;
2095  // put the values in the right order into temp_col
2096  while(it.hasNext())
2097  {
2098  temp_col->copy(cols.at(i), it.peekNext().second, j, 1);
2099  temp_col->setMasked(cols.at(i)->isMasked(it.next().second));
2100  j++;
2101  }
2102  // copy the sorted column
2103  cols.at(i)->copy(temp_col, 0, 0, rows);
2104  delete temp_col;
2105  }
2106  }
2107  else if(leading->dataType() == SciDAVis::TypeQDateTime)
2108  {
2109  QList< QPair<QDateTime, int> > map;
2110  int rows = leading->rowCount();
2111 
2112  for(int i=0; i<rows; i++)
2113  map.append(QPair<QDateTime, int>(leading->dateTimeAt(i), i));
2114 
2115  if(ascending)
2116  qStableSort(map.begin(), map.end(), CompareFunctions::QDateTimeLess);
2117  else
2118  qStableSort(map.begin(), map.end(), CompareFunctions::QDateTimeGreater);
2119  QListIterator< QPair<QDateTime, int> > it(map);
2120 
2121  for(int i=0; i<cols.size(); i++)
2122  {
2123  Column *temp_col = new Column("temp", cols.at(i)->columnMode());
2124  it.toFront();
2125  int j=0;
2126  // put the values in the right order into temp_col
2127  while(it.hasNext())
2128  {
2129  temp_col->copy(cols.at(i), it.peekNext().second, j, 1);
2130  temp_col->setMasked(cols.at(i)->isMasked(it.next().second));
2131  j++;
2132  }
2133  // copy the sorted column
2134  cols.at(i)->copy(temp_col, 0, 0, rows);
2135  delete temp_col;
2136  }
2137  }
2138  }
2139  endMacro();
2140  RESET_CURSOR;
2141 } // end of sortColumns()
2142 
2143 
2144 QIcon Table::icon() const
2145 {
2146  QIcon ico;
2147  ico.addPixmap(QPixmap(":/16x16/table.png"));
2148  ico.addPixmap(QPixmap(":/24x24/table.png"));
2149  ico.addPixmap(QPixmap(":/32x32/table.png"));
2150  return ico;
2151 }
2152 
2153 QString Table::text(int row, int col)
2154 {
2155  Column * col_ptr = column(col);
2156  if(!col_ptr)
2157  return QString();
2158  if(col_ptr->isInvalid(row))
2159  return QString();
2160 
2161  AbstractSimpleFilter * out_fltr = col_ptr->outputFilter();
2162  out_fltr->input(0, col_ptr);
2163  return out_fltr->output(0)->textAt(row);
2164 }
2165 
2167 {
2168  if (!d_view) return;
2169  d_view->selectAll();
2170 }
2171 
2173 {
2174  int index = columnIndex(static_cast<const Column *>(col));
2175  if(index != -1)
2177 }
2178 
2180 {
2181  int index = columnIndex(static_cast<const Column *>(aspect));
2182  if(index != -1)
2184 }
2185 
2187 {
2188  int index = columnIndex(static_cast<const Column *>(col));
2189  if(index != -1)
2191 }
2192 
2194 {
2195  int index = columnIndex(static_cast<const Column *>(col));
2196  if(index != -1)
2197  {
2198  if (col->rowCount() > rowCount())
2199  setRowCount(col->rowCount());
2200  emit dataChanged(0, index, col->rowCount()-1, index);
2201  }
2202 }
2203 
2204 void Table::handleRowsAboutToBeInserted(const AbstractColumn * col, int before, int count)
2205 {
2206  int new_size = col->rowCount() + count;
2207  if(before <= col->rowCount() && new_size > rowCount())
2208  setRowCount(new_size);
2209 }
2210 
2211 void Table::handleRowsInserted(const AbstractColumn * col, int before, int count)
2212 {
2213  Q_UNUSED(count);
2214  int index = columnIndex(static_cast<const Column *>(col));
2215  if(index != -1 && before <= col->rowCount())
2216  emit dataChanged(before, index, col->rowCount()-1, index);
2217 }
2218 
2219 
2220 void Table::handleRowsAboutToBeRemoved(const AbstractColumn * col, int first, int count)
2221 {
2222  Q_UNUSED(col);
2223  Q_UNUSED(first);
2224  Q_UNUSED(count);
2225 }
2226 
2227 void Table::handleRowsRemoved(const AbstractColumn * col, int first, int count)
2228 {
2229  Q_UNUSED(count);
2230  int index = columnIndex(static_cast<const Column *>(col));
2231  if(index != -1)
2232  emit dataChanged(first, index, col->rowCount()-1, index);
2233 }
2234 
2236 {
2237  connect(col, SIGNAL(aspectDescriptionChanged(const AbstractAspect *)), this,
2238  SLOT(handleDescriptionChange(const AbstractAspect *)));
2239  connect(col, SIGNAL(plotDesignationChanged(const AbstractColumn *)), this,
2241  connect(col, SIGNAL(modeChanged(const AbstractColumn *)), this,
2242  SLOT(handleDataChange(const AbstractColumn *)));
2243  connect(col, SIGNAL(dataChanged(const AbstractColumn *)), this,
2244  SLOT(handleDataChange(const AbstractColumn *)));
2245  connect(col, SIGNAL(modeChanged(const AbstractColumn *)), this,
2246  SLOT(handleModeChange(const AbstractColumn *)));
2247  connect(col, SIGNAL(rowsAboutToBeInserted(const AbstractColumn *, int, int)), this,
2248  SLOT(handleRowsAboutToBeInserted(const AbstractColumn *,int,int)));
2249  connect(col, SIGNAL(rowsInserted(const AbstractColumn *, int, int)), this,
2250  SLOT(handleRowsInserted(const AbstractColumn *,int,int)));
2251  connect(col, SIGNAL(rowsAboutToBeRemoved(const AbstractColumn *, int, int)), this,
2252  SLOT(handleRowsAboutToBeRemoved(const AbstractColumn *,int,int)));
2253  connect(col, SIGNAL(rowsRemoved(const AbstractColumn *, int, int)), this,
2254  SLOT(handleRowsRemoved(const AbstractColumn *,int,int)));
2255  connect(col, SIGNAL(maskingChanged(const AbstractColumn *)), this,
2256  SLOT(handleDataChange(const AbstractColumn *)));
2257 }
2258 
2260 {
2261  disconnect(col, 0, this, 0);
2262 }
2263 
2264 QVariant Table::headerData(int section, Qt::Orientation orientation,int role) const
2265 {
2266  return d_table_private.headerData(section, orientation, role);
2267 }
2268 
2270 {
2271  Column * column = qobject_cast<Column *>(aspect);
2272  if (!column) return;
2273  QList<Column*> cols;
2274  cols.append(column);
2276 }
2277 
2279 {
2280  Column * column = qobject_cast<Column *>(aspect);
2281  if (!column) return;
2282  int first = columnIndex(column);
2283  QList<Column*> cols;
2284  cols.append(column);
2285  exec(new TableRemoveColumnsCmd(d_table_private, first, 1, cols));
2286 }
2287 
2288 void Table::save(QXmlStreamWriter * writer) const
2289 {
2290  int cols = columnCount();
2291  int rows = rowCount();
2292  writer->writeStartElement("table");
2293  writeBasicAttributes(writer);
2294  writer->writeAttribute("columns", QString::number(cols));
2295  writer->writeAttribute("rows", QString::number(rows));
2296  writeCommentElement(writer);
2297 
2298  for (int col=0; col<cols; col++)
2299  column(col)->save(writer);
2300  for (int col=0; col<cols; col++)
2301  {
2302  writer->writeStartElement("column_width");
2303  writer->writeAttribute("column", QString::number(col));
2304  writer->writeCharacters(QString::number(columnWidth(col)));
2305  writer->writeEndElement();
2306  }
2307  writer->writeEndElement(); // "table"
2308 }
2309 
2311 {
2312  if(reader->isStartElement() && reader->name() == "table")
2313  {
2314  setColumnCount(0);
2315  setRowCount(0);
2316  setComment("");
2317 
2318  if (!readBasicAttributes(reader)) return false;
2319 
2320  // read dimensions
2321  bool ok1, ok2;
2322  int rows, cols;
2323  rows = reader->readAttributeInt("rows", &ok1);
2324  cols = reader->readAttributeInt("columns", &ok2);
2325  if(!ok1 || !ok2)
2326  {
2327  reader->raiseError(tr("invalid row or column count"));
2328  return false;
2329  }
2330 
2331  setRowCount(rows);
2332  // read child elements
2333  while (!reader->atEnd())
2334  {
2335  reader->readNext();
2336 
2337  if (reader->isEndElement()) break;
2338 
2339  if (reader->isStartElement())
2340  {
2341  if (reader->name() == "comment")
2342  {
2343  if (!readCommentElement(reader)) return false;
2344  }
2345  else if(reader->name() == "column")
2346  {
2347  Column * column = new Column(tr("Column %1").arg(1), SciDAVis::Text);
2348  if (!column->load(reader))
2349  {
2350  setColumnCount(0);
2351  return false;
2352  }
2353  QList<Column *> columns;
2354  columns.append(column);
2355  appendColumns(columns);
2356  }
2357  else if(reader->name() == "column_width")
2358  {
2359  if (!readColumnWidthElement(reader)) return false;
2360  }
2361  else // unknown element
2362  {
2363  reader->raiseWarning(tr("unknown element '%1'").arg(reader->name().toString()));
2364  if (!reader->skipToEndElement()) return false;
2365  }
2366  }
2367  }
2368  if (cols != columnCount())
2369  reader->raiseWarning(tr("columns attribute and number of read columns do not match"));
2370  }
2371  else // no table element
2372  reader->raiseError(tr("no table element found"));
2373 
2374  return !reader->hasError();
2375 }
2376 
2378 {
2379  if (!d_view) return;
2380 
2381  QString action_name;
2382  if(d_view->areCommentsShown())
2383  action_name = tr("Hide Comments");
2384  else
2385  action_name = tr("Show Comments");
2386  action_toggle_comments->setText(action_name);
2387 
2388  if(d_view->isControlTabBarVisible())
2389  action_name = tr("Hide Controls");
2390  else
2391  action_name = tr("Show Controls");
2392  action_toggle_tabbar->setText(action_name);
2393 }
2394 
2396 {
2397  Q_ASSERT(reader->isStartElement() && reader->name() == "column_width");
2398  bool ok;
2399  int col = reader->readAttributeInt("column", &ok);
2400  if(!ok)
2401  {
2402  reader->raiseError(tr("invalid or missing column index"));
2403  return false;
2404  }
2405  QString str = reader->readElementText();
2406  int value = str.toInt(&ok);
2407  if(!ok)
2408  {
2409  reader->raiseError(tr("invalid column width"));
2410  return false;
2411  }
2412  if (d_view)
2413  d_view->setColumnWidth(col, value);
2414  else
2415  setColumnWidth(col, value);
2416  return true;
2417 }
2418 
2419 void Table::setColumnWidth(int col, int width)
2420 {
2421  d_table_private.setColumnWidth(col, width);
2422 }
2423 
2424 int Table::columnWidth(int col) const
2425 {
2426  return d_table_private.columnWidth(col);
2427 }
2428 
2429 
2430 /* ========================= static methods ======================= */
2432 
2434 {
2435  if (!action_manager)
2437 
2438  return action_manager;
2439 }
2440 
2442 {
2443  if (!action_manager)
2444  action_manager = new ActionManager();
2445 
2446  action_manager->setTitle(tr("Table"));
2447  volatile Table * action_creator = new Table(); // initialize the action texts
2448  delete action_creator;
2449 }
2450 
2451 /* ========================== Table::Private ====================== */
2452 
2453 Column * Table::Private::column(int index) const
2454 {
2455  return d_columns.value(index);
2456 }
2457 
2458 void Table::Private::replaceColumns(int first, QList<Column*> new_cols)
2459 {
2460  if( (first < 0) || (first + new_cols.size() > d_column_count) )
2461  return;
2462 
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 = new_cols.at(i)->rowCount();
2468  if(rows > d_row_count)
2469  setRowCount(rows);
2470 
2471  if(d_columns.at(first+i))
2472  d_columns.at(first+i)->notifyReplacement(new_cols.at(i));
2473 
2474  d_columns[first+i] = new_cols.at(i);
2475  d_owner.connectColumn(new_cols.at(i));
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 }
2481 
2482 void Table::Private::insertColumns(int before, QList<Column*> cols)
2483 {
2484  int count = cols.count();
2485 
2486  if( (count < 1) || (before > d_column_count) )
2487  return;
2488 
2489  Q_ASSERT(before >= 0);
2490 
2491  int i, rows;
2492  for(i=0; i<count; i++)
2493  {
2494  rows = cols.at(i)->rowCount();
2495  if(rows > d_row_count)
2496  setRowCount(rows);
2497  }
2498 
2499  emit d_owner.columnsAboutToBeInserted(before, cols);
2500  for(int i=count-1; i>=0; i--)
2501  {
2502  d_columns.insert(before, cols.at(i));
2503  d_owner.connectColumn(cols.at(i));
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 }
2510 
2511 void Table::Private::removeColumns(int first, int count)
2512 {
2513  if( (count < 1) || (first >= d_column_count) )
2514  return;
2515 
2516  Q_ASSERT(first >= 0);
2517 
2518  Q_ASSERT(first+count <= d_column_count);
2519 
2520  emit d_owner.columnsAboutToBeRemoved(first, count);
2521  for(int i=count-1; i>=0; i--)
2522  {
2523  d_owner.disconnectColumn(d_columns.at(first));
2524  d_columns.removeAt(first);
2525  d_column_widths.removeAt(first);
2526  }
2527  d_column_count -= count;
2528  emit d_owner.columnsRemoved(first, count);
2529  updateHorizontalHeader(first, d_column_count-1);
2530 }
2531 
2532 void Table::Private::appendColumns(QList<Column*> cols)
2533 {
2534  insertColumns(d_column_count, cols);
2535 }
2536 
2537 void Table::Private::moveColumn(int from, int to)
2538 {
2539  if( from < 0 || from >= d_column_count) return;
2540  if( to < 0 || to >= d_column_count) return;
2541 
2542  d_columns.move(from, to);
2543  d_owner.connectColumn(d_columns.at(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 }
2550 
2552 {
2553  int diff = rows - d_row_count;
2554  int old_row_count = d_row_count;
2555  if(diff == 0)
2556  return;
2557 
2558  if(diff > 0)
2559  {
2560  emit d_owner.rowsAboutToBeInserted(d_row_count, diff);
2561  d_row_count = rows;
2562  updateVerticalHeader(d_row_count - diff);
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 }
2572 
2574 {
2575  return headerData(col, Qt::Horizontal, Qt::DisplayRole).toString();
2576 }
2577 
2579 {
2580  int count = 0;
2581 
2582  for (int i=0; i<d_column_count; i++)
2583  if(d_columns.at(i)->plotDesignation() == pd)
2584  count++;
2585 
2586  return count;
2587 }
2588 
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 }
2598 
2599 void Table::Private::updateHorizontalHeader(int start_col, int end_col)
2600 {
2601  if (start_col > end_col) return;
2602 
2603  while(d_horizontal_header_data.size() < d_column_count)
2604  d_horizontal_header_data << QString();
2605 
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 (d_columns.at(i)->plotDesignation() == SciDAVis::X)
2612  composeColumnHeader(i, d_columns.at(i)->name()+"[X" + QString::number(++x_cols) +"]");
2613  else if (d_columns.at(i)->plotDesignation() == SciDAVis::Y)
2614  {
2615  if(x_cols>0)
2616  composeColumnHeader(i, d_columns.at(i)->name()+"[Y"+ QString::number(x_cols) +"]");
2617  else
2618  composeColumnHeader(i, d_columns.at(i)->name()+"[Y]");
2619  }
2620  else if (d_columns.at(i)->plotDesignation() == SciDAVis::Z)
2621  {
2622  if(x_cols>0)
2623  composeColumnHeader(i, d_columns.at(i)->name()+"[Z"+ QString::number(x_cols) +"]");
2624  else
2625  composeColumnHeader(i, d_columns.at(i)->name()+"[Z]");
2626  }
2627  else if (d_columns.at(i)->plotDesignation() == SciDAVis::xErr)
2628  {
2629  if(x_cols>0)
2630  composeColumnHeader(i, d_columns.at(i)->name()+"[xEr"+ QString::number(x_cols) +"]");
2631  else
2632  composeColumnHeader(i, d_columns.at(i)->name()+"[xEr]");
2633  }
2634  else if (d_columns.at(i)->plotDesignation() == SciDAVis::yErr)
2635  {
2636  if(x_cols>0)
2637  composeColumnHeader(i, d_columns.at(i)->name()+"[yEr"+ QString::number(x_cols) +"]");
2638  else
2639  composeColumnHeader(i, d_columns.at(i)->name()+"[yEr]");
2640  }
2641  else
2642  composeColumnHeader(i, d_columns.at(i)->name());
2643  }
2644  }
2645  else
2646  {
2647  for (int i=0; i<d_column_count; i++)
2648  {
2649  if (d_columns.at(i)->plotDesignation() == SciDAVis::X)
2650  composeColumnHeader(i, d_columns.at(i)->name()+"[X]");
2651  else if(d_columns.at(i)->plotDesignation() == SciDAVis::Y)
2652  composeColumnHeader(i, d_columns.at(i)->name()+"[Y]");
2653  else if(d_columns.at(i)->plotDesignation() == SciDAVis::Z)
2654  composeColumnHeader(i, d_columns.at(i)->name()+"[Z]");
2655  else if(d_columns.at(i)->plotDesignation() == SciDAVis::xErr)
2656  composeColumnHeader(i, d_columns.at(i)->name()+"[xEr]");
2657  else if(d_columns.at(i)->plotDesignation() == SciDAVis::yErr)
2658  composeColumnHeader(i, d_columns.at(i)->name()+"[yEr]");
2659  else
2660  composeColumnHeader(i, d_columns.at(i)->name());
2661  }
2662  }
2663  emit d_owner.headerDataChanged(Qt::Horizontal, start_col, end_col);
2664 }
2665 
2666 void Table::Private::composeColumnHeader(int col, const QString& label)
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 }
2673 
2674 QVariant Table::Private::headerData(int section, Qt::Orientation orientation, int role) const
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 d_horizontal_header_data.at(section);
2685  case Qt::DecorationRole:
2686  return d_columns.at(section)->icon();
2688  return d_columns.at(section)->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 d_vertical_header_data.at(section);
2698  }
2699  break;
2700  }
2701  return QVariant();
2702 }
2703 
2704 } // namespace
TableRemoveColumnsCmd
Remove columns.
Definition: tablecommands.h:104
future::Table::action_fill_random
QAction * action_fill_random
Definition: future_Table.h:409
future::Table::Private::columnWidth
int columnWidth(int col) const
Definition: future_Table.h:561
AbstractFilter::input
bool input(int port, const AbstractColumn *source)
Connect the provided data source to the specified input port.
Definition: AbstractFilter.cpp:31
future::Table::Private::setRowCount
void setRowCount(int count)
Set the number of rows of the table.
Definition: future_Table.cpp:2551
TableSetNumberOfRowsCmd
Set the number of rows in the table.
Definition: tablecommands.h:79
future::Table::copySelection
void copySelection()
Definition: future_Table.cpp:354
future::Table::initActionManager
static void initActionManager()
Definition: future_Table.cpp:2441
future::Table::save
virtual void save(QXmlStreamWriter *) const
Save as XML.
Definition: future_Table.cpp:2288
future::Table::Private::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: future_Table.cpp:2674
future
Definition: AbstractAspect.h:43
AbstractFilter.h
AbstractAspect::writeCommentElement
void writeCommentElement(QXmlStreamWriter *writer) const
Save the comment to XML.
Definition: AbstractAspect.cpp:52
Column::dateTimeAt
QDateTime dateTimeAt(int row) const override
Return the QDateTime in row 'row'.
Definition: Column.cpp:255
future::Table::action_fill_row_numbers
QAction * action_fill_row_numbers
Definition: future_Table.h:408
future::Table::addActionsToView
void addActionsToView()
Definition: future_Table.cpp:1373
future::Table::action_clear_selection
QAction * action_clear_selection
Definition: future_Table.h:406
future::Table::columnWidth
int columnWidth(int col) const
Definition: future_Table.cpp:2424
future::Table::insertEmptyColumns
void insertEmptyColumns()
Insert columns depending on the selection.
Definition: future_Table.cpp:693
Double2DateTimeFilter.h
future::Table::moveColumn
void moveColumn(int from, int to)
Definition: future_Table.cpp:1811
future::Table::Table
Table()
Private ctor for initActionManager() only.
Definition: future_Table.cpp:115
Column::asStringColumn
ColumnStringIO * asStringColumn() const
Return a wrapper column object used for String I/O.
Definition: Column.h:166
future::Table::adjustActionNames
void adjustActionNames()
Definition: future_Table.cpp:2377
future::Table::action_set_formula
QAction * action_set_formula
Definition: future_Table.h:405
future::Table::normalizeSelection
void normalizeSelection()
Definition: future_Table.cpp:838
future::SortDialog
Sorting options dialog.
Definition: future_SortDialog.h:42
future::Table::clearSelectedCells
void clearSelectedCells()
Definition: future_Table.cpp:933
Double2MonthFilter.h
future::Table::clearSelectedColumns
void clearSelectedColumns()
Definition: future_Table.cpp:740
future::Table::fillSelectedCellsWithRowNumbers
void fillSelectedCellsWithRowNumbers()
Definition: future_Table.cpp:580
AbstractColumn::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: AbstractColumn.h:218
future::Table::action_clear_rows
QAction * action_clear_rows
Definition: future_Table.h:450
future::Table::setRowCount
void setRowCount(int new_size)
Set the number of rows of the table.
Definition: future_Table.cpp:228
SciDAVis::yErr
@ yErr
y errors
Definition: globals.h:61
future::Table::Private::removeColumns
void removeColumns(int first, int count)
Remove Columns.
Definition: future_Table.cpp:2511
future::Table::action_insert_columns
QAction * action_insert_columns
Definition: future_Table.h:430
Column::outputFilter
AbstractSimpleFilter * outputFilter() const
Return the output filter (for data type -> string conversion)
Definition: Column.cpp:593
future::Table::Private::rowCount
int rowCount() const
Return the number of rows in the table.
Definition: future_Table.h:522
future::Table::Private::appendColumns
void appendColumns(QList< Column * > cols)
Append columns to the table.
Definition: future_Table.cpp:2532
future::Table::appendRows
void appendRows(int count)
Definition: future_Table.h:137
future::Table::editDescriptionOfCurrentColumn
void editDescriptionOfCurrentColumn()
Definition: future_Table.cpp:970
future::Table::setSelectedColumnsAsX
void setSelectedColumnsAsX()
Definition: future_Table.cpp:776
future::Table::createTableMenu
QMenu * createTableMenu(QMenu *append_to=0)
Create a menu with table related operations.
Definition: future_Table.cpp:1730
String2MonthFilter.h
Column.h
Project.h
future::Table::setView
void setView(TableView *view)
set's the view attribute. Ownership not passed to this
Definition: future_Table.cpp:149
AbstractAspect::exec
void exec(QUndoCommand *command)
Execute the given command, pushing it on the undoStack() if available.
Definition: AbstractAspect.cpp:203
XmlStreamReader::raiseError
void raiseError(const QString &message=QString())
Definition: XmlStreamReader.cpp:80
SciDAVis::TypeQString
@ TypeQString
Definition: globals.h:79
tablecommands.h
future::Table::createSelectionMenu
QMenu * createSelectionMenu(QMenu *append_to=0)
Create a menu with selection related operations.
Definition: future_Table.cpp:1653
XmlStreamReader::readAttributeInt
int readAttributeInt(const QString &name, bool *ok)
Read an XML attribute and convert it to int.
Definition: XmlStreamReader.cpp:110
SciDAVis::xErr
@ xErr
x errors
Definition: globals.h:60
future::Table::Private::setColumnWidth
void setColumnWidth(int col, int width)
Definition: future_Table.h:560
str
#define str(x)
Definition: PythonScripting.cpp:41
SciDAVis::Y
@ Y
y values
Definition: globals.h:58
future::Table::action_toggle_comments
QAction * action_toggle_comments
Definition: future_Table.h:414
String2DayOfWeekFilter.h
XmlStreamReader
XML stream parser that supports errors as well as warnings.
Definition: XmlStreamReader.h:42
Column::maskedIntervals
QList< Interval< int > > maskedIntervals() const override
Return all intervals of masked rows.
Definition: Column.cpp:623
AbstractAspect::setComment
void setComment(const QString &value)
Definition: AbstractAspect.cpp:265
ALIGN_LEFT
@ ALIGN_LEFT
Definition: TeXTableSettings.h:34
SciDAVis::noDesignation
@ noDesignation
no plot designation
Definition: globals.h:56
AbstractAspect::moveChild
void moveChild(int from, int to)
Change the positon of a child in my list of children.
Definition: AbstractAspect.cpp:196
AbstractAspect::insertChild
void insertChild(AbstractAspect *child, int index)
Insert the given Aspect at a specific position in my list of children.
Definition: AbstractAspect.cpp:128
future::Table::translateActionsStrings
void translateActionsStrings()
Definition: future_Table.cpp:1427
future::Table::Private::updateVerticalHeader
void updateVerticalHeader(int start_row)
Update the vertical header labels.
Definition: future_Table.cpp:2589
future::Table::rowsAboutToBeInserted
void rowsAboutToBeInserted(int before, int count)
future::Table::action_set_as_none
QAction * action_set_as_none
Definition: future_Table.h:439
future::Table::setSelectionAs
void setSelectionAs(SciDAVis::PlotDesignation pd)
Definition: future_Table.cpp:762
future::Table::Private::columnHeader
QString columnHeader(int col)
Return the full column header string.
Definition: future_Table.cpp:2573
Double2StringFilter::numericFormat
char numericFormat() const
Get format character as in QString::number.
Definition: Double2StringFilter.h:50
future::Table::setSelectedColumnsAsZ
void setSelectedColumnsAsZ()
Definition: future_Table.cpp:786
TeXTableSettings::with_labels
bool with_labels(void)
Returns if the Tex table contains labels.
Definition: TeXTableSettings.h:58
future::Table
Aspect providing a spreadsheet table with column logic.
Definition: future_Table.h:86
future::Table::fillProjectToolBar
virtual bool fillProjectToolBar(QToolBar *bar)
Fill the part specific tool bar for the main window including setting the title.
Definition: future_Table.cpp:1039
future::Table::rowsAboutToBeRemoved
void rowsAboutToBeRemoved(int first, int count)
Column
Aspect that manages a column.
Definition: Column.h:59
future::Table::addColumn
void addColumn()
Append one column.
Definition: future_Table.cpp:320
future::Table::setSelectedColumnsAsXError
void setSelectedColumnsAsXError()
Definition: future_Table.cpp:796
TeXTableExportDialog.h
future::Table::action_statistics_columns
QAction * action_statistics_columns
Definition: future_Table.h:442
AbstractAspect::index
int index() const
Return my position in my parent's list of children.
Definition: AbstractAspect.h:137
future::Table::Private::insertColumns
void insertColumns(int before, QList< Column * > cols)
Insert columns before column number 'before'.
Definition: future_Table.cpp:2482
Double2StringFilter.h
future::Table::removeSelectedRows
void removeSelectedRows()
Definition: future_Table.cpp:921
future::Table::default_column_width
static int default_column_width
Definition: future_Table.h:237
ALIGN_RIGHT
@ ALIGN_RIGHT
Definition: TeXTableSettings.h:34
future::Table::recalculateSelectedCells
void recalculateSelectedCells()
Definition: future_Table.cpp:568
future::Table::rowsRemoved
void rowsRemoved(int first, int count)
TableModel.h
future::Table::pasteIntoSelection
void pasteIntoSelection()
Definition: future_Table.cpp:403
future::Table::icon
virtual QIcon icon() const
Return an icon to be used for decorating my views.
Definition: future_Table.cpp:2144
future::Table::sortColumns
void sortColumns(Column *leading, QList< Column * > cols, bool ascending)
Sort the given list of column.
Definition: future_Table.cpp:1913
Interval::size
T size() const
Definition: Interval.h:216
future::Table::defaultColumnWidth
static int defaultColumnWidth()
Definition: future_Table.h:232
future::Table::action_copy_selection
QAction * action_copy_selection
Definition: future_Table.h:399
future::Table::Private::columnCount
int columnCount() const
Return the number of columns in the table.
Definition: future_Table.h:520
DateTime2StringFilter.h
future::Table::action_sort_columns
QAction * action_sort_columns
Definition: future_Table.h:441
future::Table::action_paste_into_selection
QAction * action_paste_into_selection
Definition: future_Table.h:400
future::Table::action_manager
static ActionManager * action_manager
Definition: future_Table.h:235
Column::formulaIntervals
QList< Interval< int > > formulaIntervals() const override
Return the intervals that have associated formulas.
Definition: Column.cpp:633
future::Table::sortDialog
void sortDialog(QList< Column * > cols)
Open the sort dialog for the given columns.
Definition: future_Table.cpp:1901
TableView.h
scripted
Interface for maintaining a reference to the current ScriptingEnv.
Definition: Script.h:149
future::Table::removeColumns
void removeColumns(int first, int count)
Definition: future_Table.cpp:181
future_Table.h
future::Table::handleDataChange
void handleDataChange(const AbstractColumn *col)
Definition: future_Table.cpp:2193
future::Table::Private::composeColumnHeader
void composeColumnHeader(int col, const QString &label)
Internal function to put together the column header.
Definition: future_Table.cpp:2666
Column::replaceDateTimes
void replaceDateTimes(int first, const QList< QDateTime > &new_values) override
Replace a range of values.
Definition: Column.cpp:223
Column::setColumnMode
void setColumnMode(SciDAVis::ColumnMode mode, AbstractFilter *conversion_filter=0) override
Set the column mode.
Definition: Column.cpp:85
future::Table::action_cut_selection
QAction * action_cut_selection
Definition: future_Table.h:398
future::Table::action_recalculate
QAction * action_recalculate
Definition: future_Table.h:407
future::Table::colX
int colX(int col)
Determine the corresponding X column.
Definition: future_Table.cpp:1851
future::Table::action_normalize_columns
QAction * action_normalize_columns
Definition: future_Table.h:440
AbstractColumn::rowCount
virtual int rowCount() const =0
Return the data vector size.
future::Table::action_dimensions_dialog
QAction * action_dimensions_dialog
Definition: future_Table.h:425
future::Table::d_view
QPointer< TableView > d_view
Definition: future_Table.h:455
future::Table::showTableViewRowContextMenu
void showTableViewRowContextMenu(const QPoint &pos)
Show a context menu for the selected rows.
Definition: future_Table.cpp:1516
TeXTableSettings::with_caption
bool with_caption(void)
Returns if the TeX table contains caption.
Definition: TeXTableSettings.h:56
Column::removeRows
void removeRows(int first, int count) override
Remove 'count' rows starting from row 'first'.
Definition: Column.cpp:130
Column::setPlotDesignation
void setPlotDesignation(SciDAVis::PlotDesignation pd)
Set the column plot designation.
Definition: Column.cpp:136
Column::setFormula
void setFormula(Interval< int > i, QString formula)
Set a formula string for an interval of rows.
Definition: Column.cpp:182
future::Table::sortSelectedColumns
void sortSelectedColumns()
Definition: future_Table.cpp:872
future::Table::clear
void clear()
Clear the whole table.
Definition: future_Table.cpp:296
future::Table::removeSelectedColumns
void removeSelectedColumns()
Definition: future_Table.cpp:726
XmlStreamReader::skipToEndElement
bool skipToEndElement()
Go to the end element tag of the current element.
Definition: XmlStreamReader.cpp:121
future::Table::action_add_columns
QAction * action_add_columns
Definition: future_Table.h:433
Column::isInvalid
bool isInvalid(int row) const override
Return whether a certain row contains an invalid value
Definition: Column.cpp:598
TableView
View class for Table.
Definition: TableView.h:89
future::Table::selectAll
void selectAll()
Definition: future_Table.cpp:2166
future::Table::sortTable
void sortTable()
Open the sort dialog for all columns.
Definition: future_Table.cpp:683
future::Table::action_clear_columns
QAction * action_clear_columns
Definition: future_Table.h:432
future::Table::Private::moveColumn
void moveColumn(int from, int to)
Move a column to another position.
Definition: future_Table.cpp:2537
Column::rowCount
int rowCount() const override
Return the data vector size.
Definition: Column.cpp:583
AbstractAspect::endMacro
void endMacro()
End the undo stack macro.
Definition: AbstractAspect.cpp:222
future::Table::action_clear_masks
QAction * action_clear_masks
Definition: future_Table.h:421
future::Table::normalizeColumns
void normalizeColumns(QList< Column * > cols)
Definition: future_Table.cpp:806
AbstractAspect::captionSpec
QString captionSpec() const
Return the specification string used for constructing the caption().
Definition: AbstractAspect.cpp:271
future::Table::clearMasks
void clearMasks()
Clear all mask in the table.
Definition: future_Table.cpp:308
future::Table::handleModeChange
void handleModeChange(const AbstractColumn *col)
Definition: future_Table.cpp:2172
AbstractAspect::beginMacro
void beginMacro(const QString &text)
Begin an undo stack macro (series of commands)
Definition: AbstractAspect.cpp:215
future::Table::Private::updateHorizontalHeader
void updateHorizontalHeader(int start_col, int end_col)
Update the horizontal header labels.
Definition: future_Table.cpp:2599
future::Table::colY
int colY(int col)
Determine the corresponding Y column.
Definition: future_Table.cpp:1867
future::Table::statisticsOnSelectedRows
void statisticsOnSelectedRows()
Definition: future_Table.cpp:887
future::Table::handleRowsRemoved
void handleRowsRemoved(const AbstractColumn *col, int first, int count)
Definition: future_Table.cpp:2227
TeXTableSettings.h
future::Table::showTeXTableExportDialog
void showTeXTableExportDialog()
Open export to TeX dialog.
Definition: future_Table.cpp:1530
future::Table::dataChanged
void dataChanged(int top, int left, int bottom, int right)
ColumnStringIO::textAt
virtual QString textAt(int row) const
Return the content of row 'row'.
Definition: Column.cpp:644
future::Table::action_statistics_rows
QAction * action_statistics_rows
Definition: future_Table.h:452
future::Table::disconnectColumn
void disconnectColumn(const Column *col)
Internal function to disconnect a column.
Definition: future_Table.cpp:2259
Column::clearFormulas
void clearFormulas() override
Clear all formulas.
Definition: Column.cpp:192
future::Table::Private::d_columns
QList< Column * > d_columns
List of pointers to the column data vectors.
Definition: future_Table.h:575
future::Table::action_type_format
QAction * action_type_format
Definition: future_Table.h:443
SciDAVis::Month
@ Month
column contains month names
Definition: globals.h:69
WAIT_CURSOR
#define WAIT_CURSOR
Definition: future_Table.cpp:79
future::Table::action_unmask_selection
QAction * action_unmask_selection
Definition: future_Table.h:403
future::Table::unmaskSelection
void unmaskSelection()
Definition: future_Table.cpp:541
future::Table::prepareAspectRemoval
virtual void prepareAspectRemoval(AbstractAspect *aspect)
Called before a child is removed.
Definition: future_Table.cpp:2278
TeXTableSettings::columnsAlignment
ColumAlignment columnsAlignment(void)
Returns columns alignment of the TeX table.
Definition: TeXTableSettings.h:63
AbstractSimpleFilter::output
virtual AbstractColumn * output(int port)
Return a pointer to d_output_column on port 0 (don't override unless you really know what you are doi...
Definition: AbstractSimpleFilter.cpp:115
Column::clear
void clear() override
Clear the whole column.
Definition: Column.cpp:142
Column::load
bool load(XmlStreamReader *reader) override
Load the column from XML.
Definition: Column.cpp:364
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
future::Table::Private::column
Column * column(int index) const
Return column number 'index'.
Definition: future_Table.cpp:2453
future::Table::rowsInserted
void rowsInserted(int first, int count)
Column::columnMode
SciDAVis::ColumnMode columnMode() const override
Return the column mode.
Definition: Column.cpp:579
future::Table::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: future_Table.cpp:2264
AbstractAspect::readBasicAttributes
bool readBasicAttributes(XmlStreamReader *reader)
Load name, creation time and caption spec from XML.
Definition: AbstractAspect.cpp:77
future::Table::insertRows
void insertRows(int before, int count)
Definition: future_Table.cpp:214
future::Table::load
virtual bool load(XmlStreamReader *)
Load from XML.
Definition: future_Table.cpp:2310
Column::setMasked
void setMasked(Interval< int > i, bool mask=true)
Set an interval masked.
Definition: Column.cpp:172
future::Table::action_go_to_cell
QAction * action_go_to_cell
Definition: future_Table.h:424
future::Table::action_export_to_TeX
QAction * action_export_to_TeX
Definition: future_Table.h:419
future::Table::appendColumns
void appendColumns(QList< Column * > new_cols)
Append columns.
Definition: future_Table.h:132
future::Table::action_edit_description
QAction * action_edit_description
Definition: future_Table.h:444
future::Table::action_set_as_z
QAction * action_set_as_z
Definition: future_Table.h:436
Column::insertRows
void insertRows(int before, int count) override
Insert some empty (or initialized with zero) rows.
Definition: Column.cpp:124
future::Table::cutSelection
void cutSelection()
Definition: future_Table.cpp:340
SciDAVis::Text
@ Text
column contains strings
Definition: globals.h:68
future::Table::action_remove_columns
QAction * action_remove_columns
Definition: future_Table.h:431
Column::isMasked
bool isMasked(int row) const override
Return whether a certain row is masked
Definition: Column.cpp:613
future::Table::setPlotMenu
void setPlotMenu(QMenu *menu)
Set a plot menu.
Definition: future_Table.cpp:1896
future::Table::d_default_comment_visibility
static bool d_default_comment_visibility
Definition: future_Table.h:394
future::Table::readColumnWidthElement
bool readColumnWidthElement(XmlStreamReader *reader)
Definition: future_Table.cpp:2395
Column::dataType
SciDAVis::ColumnDataType dataType() const override
Return the data type of the column.
Definition: Column.cpp:574
future::Table::~Table
virtual ~Table()
Definition: future_Table.cpp:126
RESET_CURSOR
#define RESET_CURSOR
Definition: future_Table.cpp:80
future::Table::handleRowsAboutToBeInserted
void handleRowsAboutToBeInserted(const AbstractColumn *col, int before, int count)
Definition: future_Table.cpp:2204
future::Table::setSelectedColumnsAsNone
void setSelectedColumnsAsNone()
Definition: future_Table.cpp:801
future::Table::Private::columnIndex
int columnIndex(const Column *col) const
Return the index of the given column in the table.
Definition: future_Table.h:535
TableModel::CommentRole
@ CommentRole
the column comment (for headerData())
Definition: TableModel.h:67
future::Table::action_normalize_selection
QAction * action_normalize_selection
Definition: future_Table.h:410
TeXTableSettings
TeXTableSettings class.
Definition: TeXTableSettings.h:42
ActionManager.h
Column::replaceValues
virtual void replaceValues(int first, const QVector< qreal > &new_values) override
Replace a range of values.
Definition: Column.cpp:234
future::Table::action_add_rows
QAction * action_add_rows
Definition: future_Table.h:451
future::Table::setColumnWidth
void setColumnWidth(int col, int width)
This method should only be called by the view.
Definition: future_Table.cpp:2419
future::Table::showTableViewColumnContextMenu
void showTableViewColumnContextMenu(const QPoint &pos)
Show a context menu for the selected columns.
Definition: future_Table.cpp:1495
String2DateTimeFilter.h
future::Table::Private::replaceColumns
void replaceColumns(int first, QList< Column * > new_cols)
Replace columns completely.
Definition: future_Table.cpp:2458
future::Table::action_remove_rows
QAction * action_remove_rows
Definition: future_Table.h:449
future::Table::action_set_as_y
QAction * action_set_as_y
Definition: future_Table.h:435
future::Table::fillProjectMenu
virtual bool fillProjectMenu(QMenu *menu)
Fill the part specific menu for the main window including setting the title.
Definition: future_Table.cpp:987
AbstractAspect::aspectDescriptionChanged
void aspectDescriptionChanged(const AbstractAspect *aspect)
Emit this when the name, comment or caption spec changed.
SciDAVis::DateTime
@ DateTime
column contains dates and/or times
Definition: globals.h:71
AbstractAspect::writeBasicAttributes
void writeBasicAttributes(QXmlStreamWriter *writer) const
Save name, creation time and caption spec to XML.
Definition: AbstractAspect.cpp:70
future::Table::createContextMenu
virtual QMenu * createContextMenu() const
Return a new context menu.
Definition: future_Table.cpp:1049
Column::formula
QString formula(int row) const override
Return the formula associated with row 'row'
Definition: Column.cpp:628
future::Table::text
QString text(int row, int col)
Return the text displayed in the given cell.
Definition: future_Table.cpp:2153
SciDAVis::TypeDouble
@ TypeDouble
Definition: globals.h:78
AbstractAspect::removeChild
void removeChild(AbstractAspect *child, bool detach=false)
Remove the given Aspect from my list of children.
Definition: AbstractAspect.cpp:142
future::Table::dimensionsDialog
void dimensionsDialog()
Definition: future_Table.cpp:1793
future::Table::setSelectedColumnsAsY
void setSelectedColumnsAsY()
Definition: future_Table.cpp:781
future::Table::action_toggle_tabbar
QAction * action_toggle_tabbar
Definition: future_Table.h:415
AbstractAspect::setCaptionSpec
void setCaptionSpec(const QString &value)
Set the specification string used for constructing the caption().
Definition: AbstractAspect.cpp:276
Column::plotDesignation
SciDAVis::PlotDesignation plotDesignation() const override
Return the column plot designation.
Definition: Column.cpp:588
String2DoubleFilter.h
TeXTableExportDialog
TeXTableExportDialog.
Definition: TeXTableExportDialog.h:45
future::Table::fillSelectedCellsWithRandomNumbers
void fillSelectedCellsWithRandomNumbers()
Definition: future_Table.cpp:623
future::Table::action_insert_rows
QAction * action_insert_rows
Definition: future_Table.h:448
name
char * name()
Definition: exp_saturation.c:45
AbstractAspect::comment
QString comment() const
Definition: AbstractAspect.cpp:260
future::Table::action_set_as_xerr
QAction * action_set_as_xerr
Definition: future_Table.h:437
future::Table::removeColumn
void removeColumn(Column *col)
Definition: future_Table.cpp:196
future::Table::columnIndex
int columnIndex(const Column *col) const
Definition: future_Table.cpp:291
future::Table::editTypeAndFormatOfSelectedColumns
void editTypeAndFormatOfSelectedColumns()
Definition: future_Table.cpp:964
future::Table::createColumnMenu
QMenu * createColumnMenu(QMenu *append_to=0)
Create a menu with column related operations.
Definition: future_Table.cpp:1685
TeXTableExportDialog::tex_TableSettings
TeXTableSettings tex_TableSettings(void)
Returns the TeX table settings choosed by the user.
Definition: TeXTableExportDialog.cpp:46
future::Table::setSelectedColumnsAsYError
void setSelectedColumnsAsYError()
Definition: future_Table.cpp:791
future::Table::handleRowsInserted
void handleRowsInserted(const AbstractColumn *col, int before, int count)
Definition: future_Table.cpp:2211
future::Table::maskSelection
void maskSelection()
Definition: future_Table.cpp:521
future::Table::action_select_all
QAction * action_select_all
Definition: future_Table.h:416
future::Table::statisticsOnSelectedColumns
void statisticsOnSelectedColumns()
Definition: future_Table.cpp:879
TableInsertColumnsCmd
Insert columns.
Definition: tablecommands.h:51
future::Table::action_set_as_yerr
QAction * action_set_as_yerr
Definition: future_Table.h:438
future::Table::columnCount
int columnCount() const
Return the total number of columns in the table.
Definition: future_Table.cpp:248
future::Table::d_table_private
Private d_table_private
Definition: future_Table.h:586
future::Table::Private::numColsWithPD
int numColsWithPD(SciDAVis::PlotDesignation pd)
Return the number of columns with a given plot designation.
Definition: future_Table.cpp:2578
future::Table::handlePlotDesignationChange
void handlePlotDesignationChange(const AbstractColumn *col)
Definition: future_Table.cpp:2186
SciDAVis::PlotDesignation
PlotDesignation
Types of plot designations.
Definition: globals.h:55
future::Table::setFormulaForSelection
void setFormulaForSelection()
Definition: future_Table.cpp:562
Column::replaceTexts
void replaceTexts(int first, const QStringList &new_values) override
Replace a range of values.
Definition: Column.cpp:202
future::Table::copy
virtual void copy()
Copy current selection.
Definition: AbstractPart.h:79
Column::clearMasks
void clearMasks() override
Clear all masking information.
Definition: Column.cpp:157
Column::copy
bool copy(const AbstractColumn *other) override
Copy another column of the same type.
Definition: Column.cpp:108
ActionManager
Manages QActions and their shortcuts.
Definition: ActionManager.h:84
AbstractPart::createContextMenu
virtual QMenu * createContextMenu() const
Return AbstractAspect::createContextMenu() plus operations on the primary view.
Definition: AbstractPart.cpp:42
SciDAVis::Z
@ Z
z values
Definition: globals.h:59
future::Table::createRowMenu
QMenu * createRowMenu(QMenu *append_to=0)
Create a menu with row related operations.
Definition: future_Table.cpp:1756
ColumnStringIO::replaceTexts
virtual void replaceTexts(int start_row, const QStringList &texts)
Set the content of row 'row'.
Definition: Column.cpp:677
future::Table::column
Column * column(int index) const
Return column number 'index'.
Definition: future_Table.cpp:129
future::Table::d_plot_menu
QMenu * d_plot_menu
Definition: future_Table.h:393
future::Table::normalizeSelectedColumns
void normalizeSelectedColumns()
Definition: future_Table.cpp:833
AbstractSimpleFilter
Simplified filter interface for filters with only one output port.
Definition: AbstractSimpleFilter.h:129
future::Table::handleDescriptionChange
void handleDescriptionChange(const AbstractAspect *aspect)
Definition: future_Table.cpp:2179
SciDAVis::X
@ X
x values
Definition: globals.h:57
SciDAVis::Day
@ Day
column containts day of week names
Definition: globals.h:70
SciDAVis::TypeQDateTime
@ TypeQDateTime
Definition: globals.h:80
future::Table::addRows
void addRows()
Append as many rows as are selected.
Definition: future_Table.cpp:976
SciDAVis::Numeric
@ Numeric
column contains doubles
Definition: globals.h:67
future::Table::goToCell
void goToCell()
Definition: future_Table.cpp:1777
future::Table::setColumnCount
void setColumnCount(int new_size)
Set the number of columns.
Definition: future_Table.cpp:268
XmlStreamReader::raiseWarning
void raiseWarning(const QString &message=QString())
Definition: XmlStreamReader.cpp:86
TableMoveColumnCmd
Move a column.
Definition: tablecommands.h:131
future::Table::connectActions
void connectActions()
Definition: future_Table.cpp:1323
future::Table::action_sort_table
QAction * action_sort_table
Definition: future_Table.h:423
future::Table::connectColumn
void connectColumn(const Column *col)
Internal function to connect all column signals.
Definition: future_Table.cpp:2235
future::Table::removeRows
void removeRows(int first, int count)
Definition: future_Table.cpp:201
Interval< int >
future::Table::showTableViewContextMenu
void showTableViewContextMenu(const QPoint &pos)
Show a context menu for the selected cells.
Definition: future_Table.cpp:1472
future::Table::rowCount
int rowCount() const
Return the total number of rows in the table.
Definition: future_Table.cpp:253
Column::save
void save(QXmlStreamWriter *writer) const override
Save the column as XML.
Definition: Column.cpp:279
Column::textAt
QString textAt(int row) const override
Return the content of row 'row'.
Definition: Column.cpp:240
Column::valueAt
double valueAt(int row) const override
Return the double value in row 'row'.
Definition: Column.cpp:260
future::Table::addColumns
void addColumns()
Append as many columns as are selected.
Definition: future_Table.cpp:329
future::Table::view
virtual QWidget * view()
Construct a primary view on me.
Definition: future_Table.cpp:157
future::Table::insertColumns
void insertColumns(int before, QList< Column * > new_cols)
Insert columns.
Definition: future_Table.cpp:168
Double2StringFilter
Locale-aware conversion filter double -> QString.
Definition: Double2StringFilter.h:39
future::Table::action_add_column
QAction * action_add_column
Definition: future_Table.h:417
future::Table::insertEmptyRows
void insertEmptyRows()
Insert rows depending on the selection.
Definition: future_Table.cpp:895
SimpleCopyThroughFilter.h
future::Table::action_formula_mode
QAction * action_formula_mode
Definition: future_Table.h:426
future::Table::action_clear_table
QAction * action_clear_table
Definition: future_Table.h:418
future_SortDialog.h
future::Table::completeAspectInsertion
virtual void completeAspectInsertion(AbstractAspect *aspect, int index)
Called after a new child has been inserted or added.
Definition: future_Table.cpp:2269
AbstractAspect::readCommentElement
bool readCommentElement(XmlStreamReader *reader)
Load comment from an XML element.
Definition: AbstractAspect.cpp:61
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
DateTime2DoubleFilter.h
future::Table::action_mask_selection
QAction * action_mask_selection
Definition: future_Table.h:402
future::Table::handleRowsAboutToBeRemoved
void handleRowsAboutToBeRemoved(const AbstractColumn *col, int first, int count)
Definition: future_Table.cpp:2220
ActionManager::addAction
void addAction(QAction *action, const QString &internal_name)
Definition: ActionManager.cpp:44
future::Table::action_set_as_x
QAction * action_set_as_x
Definition: future_Table.h:434
future::Table::actionManager
static ActionManager * actionManager()
Definition: future_Table.cpp:2433
AbstractColumn
Interface definition for data with column logic.
Definition: AbstractColumn.h:82
future::SortDialog::setColumnsList
void setColumnsList(QList< Column * > list)
Definition: future_SortDialog.cpp:96
future::Table::export_to_TeX
bool export_to_TeX(QString fileName, TeXTableSettings &tex_settings)
Export to TeX.
Definition: future_Table.cpp:1559
future::Table::createActions
void createActions()
Definition: future_Table.cpp:1069
Column::setInvalid
void setInvalid(Interval< int > i, bool invalid=true)
Set an interval invalid or valid.
Definition: Column.cpp:162
Double2DayOfWeekFilter.h
AbstractPart
Base class of Aspects with MDI windows as views.
Definition: AbstractPart.h:44