Back to index

fet  5.18.0
sparseitemmodel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 FET
00003                           -------------------
00004    copyright            : (C) by Lalescu Liviu
00005     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00006  ***************************************************************************
00007                       sparseitemmodel.h  -  description
00008                              -------------------
00009     begin                : 2010
00010     copyright            : (C) 2010 by Liviu Lalescu
00011                          : http://lalescu.ro/liviu/
00012  ***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 #ifndef SPARSE_ITEM_MODEL_H
00022 #define SPARSE_ITEM_MODEL_H
00023 
00024 #include <QAbstractItemModel>
00025 #include <QHash>
00026 #include <QPair>
00027 #include <QString>
00028 #include <QStringList>
00029 
00030 class SparseItemModel: public QAbstractItemModel{
00031        int n_rows;
00032        int n_columns;
00033 
00034 public:
00035 
00036        QHash<QPair<int, int> , QString> items;
00037        QStringList horizontalHeaderItems;
00038        QStringList verticalHeaderItems;
00039 
00040        SparseItemModel();
00041 
00042        QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const ;
00043        QModelIndex parent ( const QModelIndex & index ) const ;
00044        int rowCount ( const QModelIndex & parent = QModelIndex() ) const ;
00045        int columnCount ( const QModelIndex & parent = QModelIndex() ) const ;
00046        QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const ;
00047        QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const ;
00048        
00049        void clear();
00050        void clearDataAndHeaders();
00051        void resize(int _nr, int _nc);
00052        void allItemsChanged();
00053        void allHeadersChanged();
00054 };
00055 
00056 #endif