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 };
27 //! return what analysis we were attached to
28 const MussaRef getAnalysis() const;
30 //! \defgroup VectorInterface
31 //! \addtogroup VectorInterface
33 //! assign num copies of val to our vector
34 void assign(size_type num, const MotifElement& val);
35 //! return a specific element
36 MotifElement& at(size_type index);
37 //! return the last element
39 //! return an iterator to the beginning of the model
41 //! return an iterator to the beginning of the model
42 const_iterator begin() const;
45 //! return an iterator to the end of the model
47 //! return an iterator to the end of the model
48 const_iterator end() const;
49 //! is the model empty?
51 //! return a specific element
52 MotifElement& operator[](size_type index);
53 //! remove the last element from our model
55 //! add a MotifElement location to the end of our model
56 void push_back(const MotifElement&);
57 //! add an empty element to the end of our model
59 //! how many elements are in our model.
60 size_type size() const;
63 //! \defgroup QtModelInterface
64 //! \addtogroup QtModel
66 int rowCount(const QModelIndex& parent=QModelIndex()) const;
67 int columnCount(const QModelIndex& parent=QModelIndex()) const;
68 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
70 QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
72 bool setData(const QModelIndex& index, const QVariant &value,
73 int role=Qt::EditRole);
74 Qt::ItemFlags flags(const QModelIndex& index) const;
76 //bool insertRows(int row, int count,
77 // const QModelIndex& parent=QModelIndex());
78 //bool removeRows(int row, int count,
79 // const QModelIndex& parent=QModelIndex());