1 #ifndef _MOTIF_MODEL_HPP_
2 #define _MOTIF_MODEL_HPP_
4 #include "alg/sequence.hpp"
5 #include "qui/motif_editor/MotifElement.hpp"
6 #include "qui/motif_editor/MotifEditorDelegate.hpp"
8 #include <QAbstractTableModel>
12 class MotifModel : public QAbstractTableModel
17 MotifModel(QObject *parent = 0);
19 typedef std::vector<MotifElement> model_type;
20 typedef model_type::size_type size_type;
21 typedef model_type::iterator iterator;
22 typedef model_type::const_iterator const_iterator;
24 enum cell_names { EnabledCell, ColorCell, NameCell, SequenceCell };
25 //! \defgroup VectorInterface
26 //! \addtogroup VectorInterface
28 //! assign num copies of val to our vector
29 void assign(size_type num, const MotifElement& val);
30 //! return a specific element
31 MotifElement& at(size_type index);
32 //! return the last element
34 //! return an iterator to the beginning of the model
36 //! return an iterator to the beginning of the model
37 const_iterator begin() const;
40 //! return an iterator to the end of the model
42 //! return an iterator to the end of the model
43 const_iterator end() const;
44 //! is the model empty?
46 //! return a specific element
47 MotifElement& operator[](size_type index);
48 //! remove the last element from our model
50 //! add a MotifElement location to the end of our model
51 void push_back(const MotifElement&);
52 //! add an empty element to the end of our model
54 //! how many elements are in our model.
55 size_type size() const;
58 //! \defgroup QtModelInterface
59 //! \addtogroup QtModel
61 int rowCount(const QModelIndex& parent=QModelIndex()) const;
62 int columnCount(const QModelIndex& parent=QModelIndex()) const;
63 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
65 QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
67 bool setData(const QModelIndex& index, const QVariant &value,
68 int role=Qt::EditRole);
69 Qt::ItemFlags flags(const QModelIndex& index) const;
71 //bool insertRows(int row, int count,
72 // const QModelIndex& parent=QModelIndex());
73 //bool removeRows(int row, int count,
74 // const QModelIndex& parent=QModelIndex());