SciDAVis  1.D4
AbstractColumn.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : AbstractColumn.h
3  Project : SciDAVis
4  Description : Interface definition for data with column logic
5  --------------------------------------------------------------------
6  Copyright : (C) 2007-2009 Tilman Benkert (thzs*gmx.net)
7  (replace * with @ in the email addresses)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef ABSTRACTCOLUMN_H
31 #define ABSTRACTCOLUMN_H
32 
33 #include <QList>
34 #include <QString>
35 #include <QDateTime>
36 #include <QDate>
37 #include <QTime>
38 #include "lib/Interval.h"
39 #include "globals.h"
40 #include "core/AbstractAspect.h"
41 
42 class Column;
44 class QStringList;
45 
47 
81 {
82  Q_OBJECT
83 
84  public:
86  AbstractColumn(const QString& name) : AbstractAspect(name) {}
88  virtual ~AbstractColumn() { aboutToBeDestroyed(this);}
89 
91  virtual SciDAVis::ColumnDataType dataType() const = 0;
93  virtual bool isReadOnly() const { return true; };
95  /*
96  * This function is most used by tables but can also be used
97  * by plots. The column mode specifies how to interpret
98  * the values in the column additional to the data type.
99  */
100  virtual SciDAVis::ColumnMode columnMode() const = 0;
102 
106  virtual void setColumnMode(SciDAVis::ColumnMode mode) { Q_UNUSED(mode) };
108 
114  virtual bool copy(const AbstractColumn * other) { Q_UNUSED(other) return false; };
116 
125  virtual bool copy(const AbstractColumn * source, int source_start, int dest_start, int num_rows)
126  {
127  Q_UNUSED(source)
128  Q_UNUSED(source_start)
129  Q_UNUSED(dest_start)
130  Q_UNUSED(num_rows)
131  return false;
132  };
133 
135  virtual int rowCount() const = 0;
137  virtual void insertRows(int before, int count) { Q_UNUSED(before) Q_UNUSED(count) };
139  virtual void removeRows(int first, int count) { Q_UNUSED(first) Q_UNUSED(count) };
141  virtual SciDAVis::PlotDesignation plotDesignation() const = 0;
143  //virtual void setPlotDesignation(SciDAVis::PlotDesignation pd) { Q_UNUSED(pd) };
145  virtual void clear() {};
147  virtual void notifyReplacement(const AbstractColumn *replacement) { aboutToBeReplaced(this, replacement); }
148 
150 
151 
152  virtual bool isInvalid(int row) const { return !Interval<int>(0, rowCount()-1).contains(row); }
154  virtual bool isInvalid(Interval<int> i) const { return !Interval<int>(0, rowCount()-1).contains(i); }
156  virtual QList< Interval<int> > invalidIntervals() const { return QList< Interval<int> >(); }
158  virtual bool isMasked(int row) const { Q_UNUSED(row); return false; }
160  virtual bool isMasked(Interval<int> i) const { Q_UNUSED(i); return false; }
162  virtual QList< Interval<int> > maskedIntervals() const { return QList< Interval<int> >(); }
164  virtual void clearValidity() {};
166  virtual void clearMasks() {};
168 
172  //virtual void setInvalid(Interval<int> i, bool invalid = true) { Q_UNUSED(i) Q_UNUSED(invalid) };
174  //virtual void setInvalid(int row, bool invalid = true) { Q_UNUSED(row) Q_UNUSED(invalid) };
176 
180  //virtual void setMasked(Interval<int> i, bool mask = true) { Q_UNUSED(i) Q_UNUSED(mask) };
182  //virtual void setMasked(int row, bool mask = true) { Q_UNUSED(row) Q_UNUSED(mask) };
184 
186 
187 
188  virtual QString formula(int row) const { Q_UNUSED(row); return QString(); }
190 
201  virtual QList< Interval<int> > formulaIntervals() const { return QList< Interval<int> >(); }
203  //virtual void setFormula(Interval<int> i, QString formula) { Q_UNUSED(i) Q_UNUSED(formula) };
205  //virtual void setFormula(int row, QString formula) { Q_UNUSED(row) Q_UNUSED(formula) };
207  virtual void clearFormulas() {};
209 
211 
212 
213 
216  virtual QString textAt(int row) const { Q_UNUSED(row); return ""; }
218 
221  //virtual void setTextAt(int row, const QString& new_value) { Q_UNUSED(row) Q_UNUSED(new_value) };
223 
226  virtual void replaceTexts(int first, const QStringList& new_values) { Q_UNUSED(first) Q_UNUSED(new_values) };
228 
231  virtual QDate dateAt(int row) const { Q_UNUSED(row); return QDate(); };
233 
236  //virtual void setDateAt(int row, const QDate& new_value) { Q_UNUSED(row) Q_UNUSED(new_value) };
238 
241  virtual QTime timeAt(int row) const { Q_UNUSED(row); return QTime(); };
243 
246  //virtual void setTimeAt(int row, const QTime& new_value) { Q_UNUSED(row) Q_UNUSED(new_value) };
248 
251  virtual QDateTime dateTimeAt(int row) const { Q_UNUSED(row); return QDateTime(); };
253 
256  //virtual void setDateTimeAt(int row, const QDateTime& new_value) { Q_UNUSED(row) Q_UNUSED(new_value) };
258 
261  virtual void replaceDateTimes(int first, const QList<QDateTime>& new_values) { Q_UNUSED(first) Q_UNUSED(new_values) };
263 
266  virtual double valueAt(int row) const { Q_UNUSED(row); return 0; };
268 
271  //virtual void setValueAt(int row, double new_value) { Q_UNUSED(row) Q_UNUSED(new_value) };
273 
276  virtual void replaceValues(int first, const QVector<double>& new_values) { Q_UNUSED(first) Q_UNUSED(new_values) };
278 
279  signals:
281 
286  void plotDesignationAboutToChange(const AbstractColumn * source);
288 
293  void plotDesignationChanged(const AbstractColumn * source);
295 
300  void modeAboutToChange(const AbstractColumn * source);
302 
307  void modeChanged(const AbstractColumn * source);
309 
314  void dataAboutToChange(const AbstractColumn * source);
316 
324  void dataChanged(const AbstractColumn * source);
326 
336  void aboutToBeReplaced(const AbstractColumn * source, const AbstractColumn* new_col);
338 
343  void rowsAboutToBeInserted(const AbstractColumn * source, int before, int count);
345 
350  void rowsInserted(const AbstractColumn * source, int before, int count);
352 
357  void rowsAboutToBeRemoved(const AbstractColumn * source, int first, int count);
359 
364  void rowsRemoved(const AbstractColumn * source, int first, int count);
366  void maskingAboutToChange(const AbstractColumn * source);
368  void maskingChanged(const AbstractColumn * source);
369  // TODO: Check whether aboutToBeDestroyed is needed
371 
376  void aboutToBeDestroyed(const AbstractColumn * source);
377 
378  friend class ColumnPrivate;
379  friend class AbstractSimpleFilter;
380  friend class SimpleMappingFilter;
382 };
383 
384 #endif