|
Electrosim
1.00
|
00001 /*********************************************************************** 00002 * Module: gridmodel.h 00003 * Author: SALMON PAUL 00004 * MONLOUIS Kevyn 00005 * DUREUIL Brice 00006 * Modified: samedi 12 mai 2012 17:15:14 00007 * Purpose: Declaration of the class GridModel 00008 ***********************************************************************/ 00009 00010 #ifndef GRIDMODEL_H 00011 #define GRIDMODEL_H 00012 00023 #include <QAbstractItemModel> 00024 #include <QVector> 00025 #include <QIcon> 00026 #include <QPair> 00027 #include <qmath.h> 00028 #include <QFile> 00029 #include <QTextStream> 00030 00031 #include "input.h" 00032 #include "output.h" 00033 #include "item.h" 00034 #include "not.h" 00035 #include "and.h" 00036 #include "or.h" 00037 #include "multiplexer.h" 00038 #include "demultiplexer.h" 00039 #include "xnor.h" 00040 #include "node.h" 00041 #include "xor.h" 00042 00051 class GridModel : public QAbstractItemModel 00052 { 00053 00054 Q_OBJECT 00055 public: 00063 explicit GridModel(int rows = 0, int columns = 0); 00064 00070 ~GridModel(); 00071 00080 virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; 00081 00088 virtual QModelIndex parent(const QModelIndex &child) const; 00089 00096 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; 00097 00104 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; 00105 00113 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00114 00123 virtual bool setData(const QModelIndex &index, const QVariant &value, int role); 00124 00132 bool insertColumn(int column, const QModelIndex &parent = QModelIndex()); 00133 00141 bool removeColumn(int column, const QModelIndex &parent = QModelIndex()); 00142 00150 bool insertRow(int row, const QModelIndex &parent = QModelIndex()); 00151 00159 bool removeRow(int row, const QModelIndex &parent = QModelIndex()); 00160 00169 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()); 00170 00179 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()); 00180 00189 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); 00190 00199 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); 00200 00207 Item* at(const QModelIndex &index); 00208 00216 bool addItem(const QModelIndex &index, Item* item); 00217 00224 bool connexion(Item::s_connect* conn); 00225 00232 bool removeItem(const QModelIndex &index); 00233 00239 bool resetAllConnexions(); 00240 00245 void simulate(); 00246 00254 QPair <QVector < QString >, QVector< QVector < int > > > verite(); 00255 00261 bool setDefValueOnInput(Item *item, int value); 00262 00269 bool saveInFile(QFile* file); 00270 00277 static GridModel* loadFromFile(QFile* file); 00278 00285 Item* findChildByName(QString name); 00286 00295 bool nameIsCorrect(const QString& name) const; 00296 00305 bool removeConnexion(Item::s_connect* conn); 00306 00313 QList<QVariant> getConnexions(Item *it) const ; 00314 00321 QModelIndex getIndex(Item *item) const; 00322 signals: 00328 void launch(); 00329 00330 private : 00331 int column_count; 00332 int row_count; 00333 QVector< QVector<Item*> > items; 00334 QList <Item *> inputs; 00335 QList <Item *> outputs; 00336 QModelIndex current_modelIndex; 00337 QList <Item::s_connect *> connexions; 00338 }; 00339 00340 #endif // GRIDMODEL_H
1.8.0