SciDAVis  1.D4
Column.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Column.h
3  Project : SciDAVis
4  Description : Aspect that manages a column
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 COLUMN_H
31 #define COLUMN_H
32 
33 #include "core/AbstractAspect.h"
35 #include "lib/IntervalAttribute.h"
36 #include "lib/XmlStreamReader.h"
37 class QString;
38 
39 class ColumnStringIO;
40 
42 
55 class Column : public AbstractColumn
56 {
57  Q_OBJECT
58 
59  public:
60  class Private;
61  friend class Private;
63 
67  Column(const QString& name, SciDAVis::ColumnMode mode);
69 
74  Column(const QString& name, QVector<qreal> data, IntervalAttribute<bool> validity = IntervalAttribute<bool>());
76 
81  Column(const QString& name, QStringList data, IntervalAttribute<bool> validity = IntervalAttribute<bool>());
83 
88  Column(const QString& name, QList<QDateTime> data, IntervalAttribute<bool> validity = IntervalAttribute<bool>());
90  ~Column();
91 
93 
94 
95  virtual QIcon icon() const;
97 
101  bool isReadOnly() const { return false; };
103 
110 
114  void setColumnMode(SciDAVis::ColumnMode mode, AbstractFilter *conversion_filter=0);
116 
122  bool copy(const AbstractColumn * other);
124 
133  bool copy(const AbstractColumn * source, int source_start, int dest_start, int num_rows);
135 
140  int rowCount() const;
142  void insertRows(int before, int count);
144  void removeRows(int first, int count);
150  void clear();
152  void notifyReplacement(const AbstractColumn* replacement);
154 
161 
163 
164 
165  bool isInvalid(int row) const;
167  bool isInvalid(Interval<int> i) const;
169  QList< Interval<int> > invalidIntervals() const;
171  bool isMasked(int row) const;
173  bool isMasked(Interval<int> i) const;
175  QList< Interval<int> > maskedIntervals() const;
177  void clearValidity();
179  void clearMasks();
181 
185  void setInvalid(Interval<int> i, bool invalid = true);
187  void setInvalid(int row, bool invalid = true);
189 
193  void setMasked(Interval<int> i, bool mask = true);
195  void setMasked(int row, bool mask = true);
197 
199 
200 
201  QString formula(int row) const;
203 
214  QList< Interval<int> > formulaIntervals() const;
216  void setFormula(Interval<int> i, QString formula);
218  void setFormula(int row, QString formula);
220  void clearFormulas();
222 
224 
225 
226 
229  QString textAt(int row) const;
231 
234  void setTextAt(int row, const QString& new_value);
236 
239  void replaceTexts(int first, const QStringList& new_values);
241 
244  QDate dateAt(int row) const;
246 
249  void setDateAt(int row, const QDate& new_value);
251 
254  QTime timeAt(int row) const;
256 
259  void setTimeAt(int row, const QTime& new_value);
261 
264  QDateTime dateTimeAt(int row) const;
266 
269  void setDateTimeAt(int row, const QDateTime& new_value);
271 
274  void replaceDateTimes(int first, const QList<QDateTime>& new_values);
276  double valueAt(int row) const;
278 
281  void setValueAt(int row, double new_value);
283 
286  virtual void replaceValues(int first, const QVector<qreal>& new_values);
288 
290 
291 
292  void save(QXmlStreamWriter * writer) const;
294  bool load(XmlStreamReader * reader);
295  private:
297  bool XmlReadInputFilter(XmlStreamReader * reader);
299  bool XmlReadOutputFilter(XmlStreamReader * reader);
301  bool XmlReadMask(XmlStreamReader * reader);
303  bool XmlReadFormula(XmlStreamReader * reader);
305  bool XmlReadRow(XmlStreamReader * reader);
307 
308  private slots:
309  void notifyDisplayChange();
310 
311  private:
315 
316  friend class ColumnStringIO;
317 };
318 
321 {
322  Q_OBJECT
323 
324  public:
325  ColumnStringIO(Column * owner) : AbstractColumn(tr("as string")), d_owner(owner), d_setting(false) {}
326  virtual SciDAVis::ColumnMode columnMode() const { return SciDAVis::Text; }
329  virtual int rowCount() const { return d_owner->rowCount(); }
330  virtual QString textAt(int row) const;
331  virtual void setTextAt(int row, const QString &value);
332  virtual bool isInvalid(int row) const {
333  if (d_setting)
334  return false;
335  else
336  return d_owner->isInvalid(row);
337  }
338  virtual bool copy(const AbstractColumn *other);
339  virtual bool copy(const AbstractColumn *source, int source_start, int dest_start, int num_rows);
340  virtual void replaceTexts(int start_row, const QStringList &texts);
341 
342  private:
344  bool d_setting;
345  QString d_to_set;
346 };
347 
348 #endif