1 // Copyright (C) 2010-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay
21 #include <QTableWidget>
22 #include <QItemDelegate>
23 #include <QStringListModel>
24 #include <QAbstractTableModel>
26 #include <QStyledItemDelegate>
28 class OnOffDelegate : public QStyledItemDelegate//QItemDelegate
32 OnOffDelegate(QObject *parent=0);
33 void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
36 class VectBoolSpreadSheet : public QTableView
40 VectBoolSpreadSheet(QWidget *parent);
41 ~VectBoolSpreadSheet();
43 void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
45 void nbOfRowsHasChanged(int newNbOfRows);
46 void selectUnselectAllFired();
48 OnOffDelegate *_delegate;
51 class VectBoolModel : public QAbstractTableModel
55 VectBoolModel(int maxSize, int nbRows);
56 std::size_t getSize() const { return _activated.size(); }
57 bool getStatusAt(int pos) const { return _activated[pos]; }
58 void setStatusAt(int pos, bool val) { _activated[pos]=val; }
59 int rowCount( const QModelIndex & parent = QModelIndex() ) const;
60 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
61 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
62 QVariant data(const QModelIndex &index, int role) const;
63 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
65 bool setCurrentItems(const QStringList& dts, const QStringList& its, const QStringList& tts);
66 int getNbOfActivatedTimeSteps() const;
68 void setNumberOfRows(int newNbOfRows);
69 void selectUnselectAll();
71 void nbOfTimeStepsOnChanged(int newNbOfTimeStepsOn, int totalNbOfTS);
73 void setCurSize(int sz);
76 std::vector<bool> _activated;
77 QStringList _dts,_its,_tts;