better motif editor
[mussa.git] / qui / motif_editor / MotifModel.hpp
1 #ifndef _MOTIF_MODEL_HPP_
2 #define _MOTIF_MODEL_HPP_
3
4 #include "alg/sequence.hpp"
5 #include "qui/motif_editor/MotifElement.hpp"
6 #include "qui/motif_editor/MotifEditorDelegate.hpp"
7
8 #include <QAbstractTableModel>
9
10 #include <vector>
11
12 class MotifModel : public QAbstractTableModel
13 {
14   Q_OBJECT
15
16   public:
17     MotifModel(QObject *parent = 0);
18
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; 
23
24     enum cell_names { EnabledCell, ColorCell, NameCell, SequenceCell };
25     //! \defgroup VectorInterface
26     //! \addtogroup VectorInterface
27     //! \@{
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
33     MotifElement& back();
34     //! return an iterator to the beginning of the model
35     iterator begin();
36     //! return an iterator to the beginning of the model
37     const_iterator begin() const;
38     //! empty the model
39     void clear();
40     //! return an iterator to the end of the model
41     iterator end();
42     //! return an iterator to the end of the model
43     const_iterator end() const;
44     //! is the model empty?
45     bool empty() const;
46     //! return a specific element
47     MotifElement& operator[](size_type index);
48     //! remove the last element from our model
49     void pop_back();
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
53     void push_empty();
54     //! how many elements are in our model.
55     size_type size() const;
56     //! \@}
57
58     //! \defgroup QtModelInterface
59     //! \addtogroup QtModel
60     //! \@{
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;
64
65     QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
66
67     bool setData(const QModelIndex& index, const QVariant &value, 
68                  int role=Qt::EditRole);
69     Qt::ItemFlags flags(const QModelIndex& index) const;
70
71     //bool insertRows(int row, int count, 
72     //                const QModelIndex& parent=QModelIndex());
73     //bool removeRows(int row, int count,
74     //                const QModelIndex& parent=QModelIndex());
75     //! \@}
76   private:      
77     model_type motifs;
78 };
79
80 #endif