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 // What's this feature descriptions
37 // FIXME: The '*' is added because for some reason
38 // Qt's whatsthis feature is chopping off the last word
39 // If the '*' eventually shows up in a whatsthis pop-up
40 // then the '*' should be removed.
41 name_label->setWhatsThis("Name of sequence *");
42 position_label->setWhatsThis("Edge of viewport base pair position *");
43 length_label->setWhatsThis("Total length of sequence *");
45 layout->addWidget(name_label);
46 layout->addWidget(position_label);
47 layout->addWidget(length_label);
48 name_label->setMaximumWidth(length_label->fontMetrics().width("01234567"));
50 connect(name_label, SIGNAL(textChanged(const QString& )),
51 this, SLOT(setName(const QString& )));
54 void SequenceDescription::setGlSequence(
55 boost::shared_ptr<GlSequence> glseq )
57 if (glseq != glsequence_) {
59 setName(glsequence_->sequence()->get_species());
60 setLength(glsequence_->sequence()->length());
61 emit glsequenceChanged(glsequence_);
65 boost::shared_ptr<GlSequence> SequenceDescription::glsequence()
70 void SequenceDescription::setName(std::string name)
72 setName(QString(name.c_str()));
75 void SequenceDescription::setName(const QString& name_)
77 std::string std_name_ = name_.toStdString();
79 if (std_name_ != glsequence_->sequence()->get_species()) {
80 glsequence_->sequence()->set_species(std_name_);
81 emit nameChanged(name_);
84 // no need to setText again if its because of user editing
85 if (name_ != name_label->text()) {
86 name_label->setText(name_);
87 name_label->setCursorPosition(0);
91 std::string SequenceDescription::name() const
94 return glsequence_->sequence()->get_species();
99 void SequenceDescription::setLength(int length)
102 float short_length = length;
103 if (short_length > 1000000) {
104 short_length /= 1000000;
105 s.setNum(short_length, 'f', 2);
107 } if (short_length > 1000) {
108 short_length /= 1000;
109 s.setNum(short_length, 'f', 2);
112 s.setNum(short_length);
115 length_label->setText(s);
118 int SequenceDescription::length() const
123 return glsequence_->sequence()->size();
128 void SequenceDescription::setPosition(int pos_)
133 position_label->setText(s.setNum(pos_));
134 emit positionChanged(pos);
138 int SequenceDescription::position() const