1 #ifndef _MOTIF_MODEL_HPP_
2 #define _MOTIF_MODEL_HPP_
4 #include "alg/sequence.hpp"
5 #include "alg/mussa.hpp"
6 #include "qui/motif_editor/MotifElement.hpp"
7 #include "qui/motif_editor/MotifEditorDelegate.hpp"
9 #include <QAbstractTableModel>
13 class MotifModel : public QAbstractTableModel
18 MotifModel(MussaRef m, QObject *parent = 0);
20 typedef std::vector<MotifElement> model_type;
21 typedef model_type::size_type size_type;
22 typedef model_type::iterator iterator;
23 typedef model_type::const_iterator const_iterator;
25 enum cell_names { EnabledCell, ColorCell, NameCell, SequenceCell };
26 //! \defgroup VectorInterface
27 //! \addtogroup VectorInterface
29 //! assign num copies of val to our vector
30 void assign(size_type num, const MotifElement& val);
31 //! return a specific element
32 MotifElement& at(size_type index);
33 //! return the last element
35 //! return an iterator to the beginning of the model
37 //! return an iterator to the beginning of the model
38 const_iterator begin() const;
41 //! return an iterator to the end of the model
43 //! return an iterator to the end of the model
44 const_iterator end() const;
45 //! is the model empty?
47 //! return a specific element
48 MotifElement& operator[](size_type index);
49 //! remove the last element from our model
51 //! add a MotifElement location to the end of our model
52 void push_back(const MotifElement&);
53 //! add an empty element to the end of our model
55 //! how many elements are in our model.
56 size_type size() const;
59 //! \defgroup QtModelInterface
60 //! \addtogroup QtModel
62 int rowCount(const QModelIndex& parent=QModelIndex()) const;
63 int columnCount(const QModelIndex& parent=QModelIndex()) const;
64 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
66 QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
68 bool setData(const QModelIndex& index, const QVariant &value,
69 int role=Qt::EditRole);
70 Qt::ItemFlags flags(const QModelIndex& index) const;
72 //bool insertRows(int row, int count,
73 // const QModelIndex& parent=QModelIndex());
74 //bool removeRows(int row, int count,
75 // const QModelIndex& parent=QModelIndex());