File indexing completed on 2024-04-21 03:41:57

0001 /*************************************************************************************
0002  *  Copyright (C) 2010-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 DICTIONARIESMODEL_H
0020 #define DICTIONARIESMODEL_H
0021 
0022 //Analitza includes
0023 #include <analitzaplot/plottingenums.h>
0024 
0025 //Qt includes
0026 #include <QtCore/QAbstractListModel>
0027 #include <QIcon>
0028 
0029 namespace Analitza { class Expression; }
0030 class SpaceItem;
0031 
0032 class SpacesModel : public QAbstractListModel
0033 {
0034 
0035 friend class SpaceItem;
0036 Q_OBJECT
0037 
0038 public:
0039     explicit SpacesModel(QObject *parent=nullptr);
0040 
0041     Qt::ItemFlags flags ( const QModelIndex & index ) const override;
0042     
0043     QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override;
0044     QVariant data( const QModelIndex &index, int role=Qt::DisplayRole) const override;
0045     bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
0046     int rowCount(const QModelIndex &parent=QModelIndex()) const override;
0047     int columnCount(const QModelIndex& parent) const override;
0048     bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) override;
0049 
0050     SpaceItem * addSpace(Analitza::Dimension dim, const QString & title = QString(), const QString &description = QString(),
0051                          const QPixmap &thumbnail=QIcon::fromTheme("khipu").pixmap(QSize(256,256)));
0052 
0053     SpaceItem * space(int row) const;
0054 
0055     //TODO temp solution for bug ... we need better API for this model
0056     QList<SpaceItem *> items() const { return m_items; }
0057     
0058 protected:
0059     void emitChanged(SpaceItem* it);
0060 
0061 private:
0062     QList<SpaceItem *> m_items;
0063     bool m_itemCanCallModelRemoveItem; // just a lock para evitar que el item llame recursivamente a removeItem
0064 };
0065 
0066 #endif