2 #include "qui/seqbrowser/SequenceDescription.hpp"
6 SequenceDescription::SequenceDescription(QWidget *parent)
8 pos(-1) // set pos to an invalid value so the setPos function will call
14 SequenceDescription::SequenceDescription(
15 boost::shared_ptr<GlSequence> glseq,
22 void SequenceDescription::createWidget()
24 setFrameStyle(QFrame::Panel | QFrame::Sunken);
26 QLayout *layout = new QVBoxLayout;
27 layout->addWidget(&name_label);
28 layout->addWidget(&length_label);
29 layout->addWidget(&position_label);
30 name_label.setMaximumWidth(length_label.fontMetrics().width("01234567"));
33 connect(&name_label, SIGNAL(textChanged(const QString& )),
34 this, SLOT(setName(const QString& )));
37 void SequenceDescription::setGlSequence(
38 boost::shared_ptr<GlSequence> glseq )
40 if (glseq != glsequence_) {
42 setName(glsequence_->sequence()->get_species());
43 setLength(glsequence_->sequence()->length());
44 emit glsequenceChanged(glsequence_);
48 boost::shared_ptr<GlSequence> SequenceDescription::glsequence()
53 void SequenceDescription::setName(std::string name)
55 setName(QString(name.c_str()));
58 void SequenceDescription::setName(const QString& name_)
60 std::string std_name_ = name_.toStdString();
62 if (std_name_ != glsequence_->sequence()->get_species()) {
63 glsequence_->sequence()->set_species(std_name_);
64 emit nameChanged(name_);
67 // no need to setText again if its because of user editing
68 if (name_ != name_label.text()) {
69 name_label.setText(name_);
70 name_label.setCursorPosition(0);
74 std::string SequenceDescription::name() const
77 return glsequence_->sequence()->get_species();
82 void SequenceDescription::setLength(int length)
85 float short_length = length;
86 if (short_length > 1000000) {
87 short_length /= 1000000;
88 s.setNum(short_length, 'f', 2);
90 } if (short_length > 1000) {
92 s.setNum(short_length, 'f', 2);
95 s.setNum(short_length);
98 length_label.setText(s);
101 int SequenceDescription::length() const
106 return glsequence_->sequence()->size();
111 void SequenceDescription::setPosition(int pos_)
116 position_label.setText(s.setNum(pos_));
117 emit positionChanged(pos);
121 int SequenceDescription::position() const