File indexing completed on 2024-05-12 15:26:38

0001 /***************************************************************************
0002     File                 : AbstractSimpleFilter.h
0003     Project              : AbstractColumn
0004     --------------------------------------------------------------------
0005     Copyright            : (C) 2007 Knut Franke (knut.franke@gmx.de)
0006     Copyright            : (C) 2007 Tilman Benkert (thzs@gmx.net)
0007     Copyright            : (C) 2017-2020 Stefan Gerlach (stefan.gerlach@uni.kn)
0008     Description          : Simplified filter interface for filters with
0009                            only one output port.
0010  ***************************************************************************/
0011 
0012 /***************************************************************************
0013  *                                                                         *
0014  *  This program is free software; you can redistribute it and/or modify   *
0015  *  it under the terms of the GNU General Public License as published by   *
0016  *  the Free Software Foundation; either version 2 of the License, or      *
0017  *  (at your option) any later version.                                    *
0018  *                                                                         *
0019  *  This program is distributed in the hope that it will be useful,        *
0020  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0021  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0022  *  GNU General Public License for more details.                           *
0023  *                                                                         *
0024  *   You should have received a copy of the GNU General Public License     *
0025  *   along with this program; if not, write to the Free Software           *
0026  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0027  *   Boston, MA  02110-1301  USA                                           *
0028  *                                                                         *
0029  ***************************************************************************/
0030 #ifndef ABSTRACTSIMPLEFILTER_H
0031 #define ABSTRACTSIMPLEFILTER_H
0032 
0033 #include "AbstractFilter.h"
0034 #include "AbstractColumn.h"
0035 #include "backend/lib/IntervalAttribute.h"
0036 
0037 class SimpleFilterColumn;
0038 
0039 class AbstractSimpleFilter : public AbstractFilter {
0040     Q_OBJECT
0041 
0042 public:
0043     AbstractSimpleFilter();
0044     int inputCount() const override;
0045     int outputCount() const override;
0046     AbstractColumn* output(int port) override;
0047     const AbstractColumn * output(int port) const override;
0048     virtual AbstractColumn::PlotDesignation plotDesignation() const;
0049     virtual QString plotDesignationString() const;
0050     virtual AbstractColumn::ColumnMode columnMode() const;
0051     virtual QString textAt(int row) const;
0052     virtual QDate dateAt(int row) const;
0053     virtual QTime timeAt(int row) const;
0054     virtual QDateTime dateTimeAt(int row) const;
0055     virtual double valueAt(int row) const;
0056     virtual int integerAt(int row) const;
0057     virtual qint64 bigIntAt(int row) const;
0058 
0059     void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
0060     void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
0061 
0062     virtual int rowCount() const;
0063     virtual int availableRowCount() const;
0064     virtual QList<Interval<int>> dependentRows(const Interval<int>& inputRange) const;
0065 
0066     void save(QXmlStreamWriter*) const override;
0067     bool load(XmlStreamReader*, bool preview) override;
0068     virtual void writeExtraAttributes(QXmlStreamWriter*) const;
0069 
0070 signals:
0071     void formatChanged();
0072     void digitsChanged();
0073 
0074 protected:
0075     void inputPlotDesignationAboutToChange(const AbstractColumn*) override;
0076     void inputPlotDesignationChanged(const AbstractColumn*) override;
0077     void inputModeAboutToChange(const AbstractColumn*) override;
0078     void inputModeChanged(const AbstractColumn*) override;
0079     void inputDataAboutToChange(const AbstractColumn*) override;
0080     void inputDataChanged(const AbstractColumn*) override;
0081 
0082     void inputRowsAboutToBeInserted(const AbstractColumn * source, int before, int count) override;
0083     void inputRowsInserted(const AbstractColumn * source, int before, int count) override;
0084     void inputRowsAboutToBeRemoved(const AbstractColumn * source, int first, int count) override;
0085     void inputRowsRemoved(const AbstractColumn * source, int first, int count) override;
0086 
0087     SimpleFilterColumn* m_output_column;
0088     QLocale m_numberLocale;
0089     bool m_useDefaultLocale{true};
0090 };
0091 
0092 class SimpleFilterColumn : public AbstractColumn {
0093     Q_OBJECT
0094 
0095 public:
0096     explicit SimpleFilterColumn(AbstractSimpleFilter* owner) : AbstractColumn(owner->name(), AspectType::SimpleFilterColumn), m_owner(owner) {}
0097 
0098     AbstractColumn::ColumnMode columnMode() const override;
0099     int rowCount() const override { return m_owner->rowCount(); }
0100     int availableRowCount() const override { return m_owner->availableRowCount(); }
0101     AbstractColumn::PlotDesignation plotDesignation() const override { return m_owner->plotDesignation(); }
0102     QString plotDesignationString() const override { return m_owner->plotDesignationString(); }
0103     QString textAt(int row) const override;
0104     QDate dateAt(int row) const override;
0105     QTime timeAt(int row) const override;
0106     QDateTime dateTimeAt(int row) const override;
0107     double valueAt(int row) const override;
0108     int integerAt(int row) const override;
0109     qint64 bigIntAt(int row) const override;
0110     void save(QXmlStreamWriter*) const override {};
0111     bool load(XmlStreamReader*, bool preview) override {Q_UNUSED(preview); return true;};
0112 private:
0113     AbstractSimpleFilter* m_owner;
0114 
0115     friend class AbstractSimpleFilter;
0116 };
0117 
0118 #endif // ifndef ABSTRACTSIMPLEFILTER_H
0119