test MotifModel and MotifElement
[mussa.git] / qui / motif_editor / MotifModel.cpp
index 1bb05e471a3b1db5d62a48601986262eb7efda58..d07798abd3f1241591b5892aa60ecf265f6cab89 100644 (file)
@@ -2,9 +2,29 @@
 
 #include <QColor>
 
-MotifModel::MotifModel(QObject *parent) 
-  : QAbstractTableModel(parent)
+const size_t MotifModel::model_column_size = 4;
+
+MotifModel::MotifModel(MussaRef m, QObject *parent) 
+  : analysis(m),
+    QAbstractTableModel(parent)
 {
+  const std::set<Sequence>& motif_set = m->motifs();
+  boost::shared_ptr<AnnotationColors> cm = m->colorMapper();
+  
+  std::set<Sequence>::const_iterator motif_i;
+  for(motif_i = motif_set.begin();
+      motif_i != motif_set.end();
+      ++motif_i)
+  {
+    // ideally we'd know what the motif color was?
+    MotifElement new_element(*motif_i, cm->lookup("motif", motif_i->get_sequence()));
+    push_back(new_element);
+  }
+  push_empty();
+}
+
+const MussaRef MotifModel::getAnalysis() const {
+  return analysis;
 }
 
 void MotifModel::assign(
@@ -106,7 +126,7 @@ MotifModel::rowCount( const QModelIndex& parent) const
 int 
 MotifModel::columnCount(const QModelIndex& parent) const
 {
-  return 4;
+  return model_column_size;
 }
 
 QVariant 
@@ -118,7 +138,7 @@ MotifModel::data(const QModelIndex &index, int role) const
   if (index.row() >= motifs.size())
     return QVariant();
 
-  if (index.column() >= 4)
+  if (index.column() >= model_column_size)
     return QVariant();
 
   const MotifElement& motif = motifs[index.row()];