File indexing completed on 2024-04-14 14:08:50

0001 /*************************************************************************************
0002  *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #ifndef KHIPU_DOCUMENT_H_h_
0020 #define KHIPU_DOCUMENT_H_h_
0021 
0022 //Analitza includes
0023 #include <analitzaplot/plottingenums.h>
0024 
0025 //Qt includes
0026 #include <QSortFilterProxyModel>
0027 
0028 class SpaceItem;
0029 class SpacesModel;
0030 class DataStore;
0031 
0032 class SpacesFilterProxyModel : public QSortFilterProxyModel
0033 {
0034     Q_OBJECT
0035 
0036     public:
0037         explicit SpacesFilterProxyModel(QObject *parent = nullptr);
0038 
0039         void setFilterDimension(Analitza::Dimensions dimension);
0040         void setFilterText(const QString& text);
0041 protected:
0042         bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0043 
0044     private:
0045         Analitza::Dimensions m_dimension;
0046         QString m_filterText;
0047 };
0048 
0049 //si no se establece ningun filter2d entonces no hay filtro y muetra todos los items sin importar que dimension
0050 //estoy es util para un vista (itemview) que quiera mostrar todo el modelo por ejemplo 
0051 class PlotsProxyModel : public QSortFilterProxyModel
0052 {
0053     Q_OBJECT
0054 
0055     public:
0056 
0057         explicit PlotsProxyModel(QObject *parent = nullptr);
0058         ~PlotsProxyModel() override;
0059 
0060         int filterSpaceDimension() const { return m_dimension; }
0061         void setFilterSpaceDimension(Analitza::Dimensions dimension);
0062 
0063         //functiontype ... if the item is a functiongraph TODO
0064 
0065     protected:
0066         bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0067         bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
0068 
0069     private:
0070         Analitza::Dimensions m_dimension;
0071 };
0072 
0073 //ademas de filtrar la dimencione sta clase se encarga de filtra por space asociado al plotitem
0074 class SpacePlotsFilterProxyModel : public PlotsProxyModel
0075 {
0076     Q_OBJECT
0077 
0078     public:
0079         explicit SpacePlotsFilterProxyModel(DataStore *ds, QObject *parent = nullptr);
0080         ~SpacePlotsFilterProxyModel() override;
0081 
0082         SpaceItem* filterSpace() const { return m_space; }
0083         void setFilterSpace(SpaceItem *space);
0084 
0085     protected:
0086         bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0087 
0088     private:
0089         SpaceItem *m_space;
0090         DataStore *m_dataStore; // tiene los maps: space ->items
0091 };
0092 
0093 #endif