1 #include "qui/seqbrowser/SequenceDescription.hpp"
5 SequenceDescription::SequenceDescription(QWidget *parent)
7 layout(new QVBoxLayout),
8 name_label(new QLineEdit),
9 position_label(new QLabel),
10 length_label(new QLabel),
11 pos(-1) // set pos to an invalid value so the setPos function will call
17 SequenceDescription::SequenceDescription(
18 boost::shared_ptr<GlSequence> glseq,
25 void SequenceDescription::createWidget()
27 setFrameStyle(QFrame::Panel | QFrame::Sunken);
30 layout->addWidget(name_label);
31 layout->addWidget(position_label);
32 layout->addWidget(length_label);
33 name_label->setMaximumWidth(length_label->fontMetrics().width("01234567"));
35 connect(name_label, SIGNAL(textChanged(const QString& )),
36 this, SLOT(setName(const QString& )));
39 void SequenceDescription::setGlSequence(
40 boost::shared_ptr<GlSequence> glseq )
42 if (glseq != glsequence_) {
44 setName(glsequence_->sequence()->get_species());
45 setLength(glsequence_->sequence()->length());
46 emit glsequenceChanged(glsequence_);
50 boost::shared_ptr<GlSequence> SequenceDescription::glsequence()
55 void SequenceDescription::setName(std::string name)
57 setName(QString(name.c_str()));
60 void SequenceDescription::setName(const QString& name_)
62 std::string std_name_ = name_.toStdString();
64 if (std_name_ != glsequence_->sequence()->get_species()) {
65 glsequence_->sequence()->set_species(std_name_);
66 emit nameChanged(name_);
69 // no need to setText again if its because of user editing
70 if (name_ != name_label->text()) {
71 name_label->setText(name_);
72 name_label->setCursorPosition(0);
76 std::string SequenceDescription::name() const
79 return glsequence_->sequence()->get_species();
84 void SequenceDescription::setLength(int length)
87 float short_length = length;
88 if (short_length > 1000000) {
89 short_length /= 1000000;
90 s.setNum(short_length, 'f', 2);
92 } if (short_length > 1000) {
94 s.setNum(short_length, 'f', 2);
97 s.setNum(short_length);
100 length_label->setText(s);
103 int SequenceDescription::length() const
108 return glsequence_->sequence()->size();
113 void SequenceDescription::setPosition(int pos_)
118 position_label->setText(s.setNum(pos_));
119 emit positionChanged(pos);
123 int SequenceDescription::position() const