1 #include "qui/seqbrowser/SequenceDescription.hpp"
5 SequenceDescription::SequenceDescription(QWidget *parent)
11 pos(-1) // set pos to an invalid value so the setPos function will call
17 SequenceDescription::SequenceDescription(
18 boost::shared_ptr<GlSequence> glseq,
26 void SequenceDescription::setupWidgets()
28 layout = new QVBoxLayout;
29 name_label = new QLineEdit;
30 position_label = new QLabel;
31 length_label = new QLabel;
33 setFrameStyle(QFrame::Panel | QFrame::Sunken);
36 layout->addWidget(name_label);
37 layout->addWidget(position_label);
38 layout->addWidget(length_label);
39 name_label->setMaximumWidth(length_label->fontMetrics().width("01234567"));
41 connect(name_label, SIGNAL(textChanged(const QString& )),
42 this, SLOT(setName(const QString& )));
45 void SequenceDescription::setGlSequence(
46 boost::shared_ptr<GlSequence> glseq )
48 if (glseq != glsequence_) {
50 setName(glsequence_->sequence()->get_species());
51 setLength(glsequence_->sequence()->length());
52 emit glsequenceChanged(glsequence_);
56 boost::shared_ptr<GlSequence> SequenceDescription::glsequence()
61 void SequenceDescription::setName(std::string name)
63 setName(QString(name.c_str()));
66 void SequenceDescription::setName(const QString& name_)
68 std::string std_name_ = name_.toStdString();
70 if (std_name_ != glsequence_->sequence()->get_species()) {
71 glsequence_->sequence()->set_species(std_name_);
72 emit nameChanged(name_);
75 // no need to setText again if its because of user editing
76 if (name_ != name_label->text()) {
77 name_label->setText(name_);
78 name_label->setCursorPosition(0);
82 std::string SequenceDescription::name() const
85 return glsequence_->sequence()->get_species();
90 void SequenceDescription::setLength(int length)
93 float short_length = length;
94 if (short_length > 1000000) {
95 short_length /= 1000000;
96 s.setNum(short_length, 'f', 2);
98 } if (short_length > 1000) {
100 s.setNum(short_length, 'f', 2);
103 s.setNum(short_length);
106 length_label->setText(s);
109 int SequenceDescription::length() const
114 return glsequence_->sequence()->size();
119 void SequenceDescription::setPosition(int pos_)
124 position_label->setText(s.setNum(pos_));
125 emit positionChanged(pos);
129 int SequenceDescription::position() const