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 extra space is added because for some reason
38 // Qt's whatsthis feature is chopping off the last word
40 name_label->setWhatsThis("Name of sequence ");
41 position_label->setWhatsThis("Edge of viewport base pair position ");
42 length_label->setWhatsThis("Total length of sequence ");
44 layout->addWidget(name_label);
45 layout->addWidget(position_label);
46 layout->addWidget(length_label);
47 name_label->setMaximumWidth(length_label->fontMetrics().width("01234567"));
49 connect(name_label, SIGNAL(textChanged(const QString& )),
50 this, SLOT(setName(const QString& )));
53 void SequenceDescription::setGlSequence(
54 boost::shared_ptr<GlSequence> glseq )
56 if (glseq != glsequence_) {
58 setName(glsequence_->sequence()->get_species());
59 setLength(glsequence_->sequence()->length());
60 emit glsequenceChanged(glsequence_);
64 boost::shared_ptr<GlSequence> SequenceDescription::glsequence()
69 void SequenceDescription::setName(std::string name)
71 setName(QString(name.c_str()));
74 void SequenceDescription::setName(const QString& name_)
76 std::string std_name_ = name_.toStdString();
78 if (std_name_ != glsequence_->sequence()->get_species()) {
79 glsequence_->sequence()->set_species(std_name_);
80 emit nameChanged(name_);
83 // no need to setText again if its because of user editing
84 if (name_ != name_label->text()) {
85 name_label->setText(name_);
86 name_label->setCursorPosition(0);
90 std::string SequenceDescription::name() const
93 return glsequence_->sequence()->get_species();
98 void SequenceDescription::setLength(int length)
101 float short_length = length;
102 if (short_length > 1000000) {
103 short_length /= 1000000;
104 s.setNum(short_length, 'f', 2);
106 } if (short_length > 1000) {
107 short_length /= 1000;
108 s.setNum(short_length, 'f', 2);
111 s.setNum(short_length);
114 length_label->setText(s);
117 int SequenceDescription::length() const
122 return glsequence_->sequence()->size();
127 void SequenceDescription::setPosition(int pos_)
132 position_label->setText(s.setNum(pos_));
133 emit positionChanged(pos);
137 int SequenceDescription::position() const