$search
00001 /* 00002 Aseba - an event-based framework for distributed robot control 00003 Copyright (C) 2007--2012: 00004 Stephane Magnenat <stephane at magnenat dot net> 00005 (http://stephane.magnenat.net) 00006 and other contributors, see authors.txt for details 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published 00010 by the Free Software Foundation, version 3 of the License. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef NAMED_VALUES_VECTOR_MODEL_H 00022 #define NAMED_VALUES_VECTOR_MODEL_H 00023 00024 #include <QAbstractTableModel> 00025 #include <QVector> 00026 #include <QString> 00027 #include "../compiler/compiler.h" 00028 00029 00030 namespace Aseba 00031 { 00034 00035 class NamedValuesVectorModel: public QAbstractTableModel 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 NamedValuesVectorModel(NamedValuesVector* namedValues, const QString &tooltipText, QObject *parent = 0); 00041 NamedValuesVectorModel(NamedValuesVector* namedValues, QObject *parent = 0); 00042 00043 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00044 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00045 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 Qt::ItemFlags flags(const QModelIndex & index) const; 00049 00050 QStringList mimeTypes () const; 00051 void setExtraMimeType(QString mime) { privateMimeType = mime; } 00052 QMimeData * mimeData ( const QModelIndexList & indexes ) const; 00053 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); 00054 Qt::DropActions supportedDragActions(); 00055 Qt::DropActions supportedDropActions() const; 00056 00057 bool setData(const QModelIndex &index, const QVariant &value, int role); 00058 bool checkIfModified() { return wasModified; } 00059 void clearWasModified() { wasModified = false; } 00060 void setEditable(bool editable); 00061 00062 virtual bool moveRow(int oldRow, int& newRow); 00063 00064 public slots: 00065 void addNamedValue(const NamedValue& namedValue, int index = -1); 00066 void delNamedValue(int index); 00067 void clear(); 00068 00069 signals: 00070 void publicRowsInserted(); 00071 void publicRowsRemoved(); 00072 00073 protected: 00074 NamedValuesVector* namedValues; 00075 bool wasModified; 00076 QString privateMimeType; 00077 00078 private: 00079 QString tooltipText; 00080 bool editable; 00081 }; 00082 00083 class MaskableNamedValuesVectorModel: public NamedValuesVectorModel 00084 { 00085 Q_OBJECT 00086 00087 public: 00088 MaskableNamedValuesVectorModel(NamedValuesVector* namedValues, const QString &tooltipText, QObject *parent = 0); 00089 MaskableNamedValuesVectorModel(NamedValuesVector* namedValues, QObject *parent = 0); 00090 00091 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00092 00093 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00094 Qt::ItemFlags flags(const QModelIndex & index) const; 00095 00096 bool isVisible(const unsigned id); 00097 00098 virtual bool moveRow(int oldRow, int& newRow); 00099 00100 public slots: 00101 void addNamedValue(const NamedValue& namedValue); 00102 void delNamedValue(int index); 00103 void toggle(const QModelIndex &index); 00104 00105 private: 00106 std::vector<bool> viewEvent; 00107 }; 00108 00110 }; // Aseba 00111 00112 #endif