WhatsThis update
[mussa.git] / qui / seqbrowser / SequenceDescription.cpp
index 8bf36e6c6911cb47f944b7fdfd009beddf551312..d1165047793badac57ed778b77db476858b9756d 100644 (file)
@@ -1,14 +1,17 @@
-#include <QVBoxLayout>
 #include "qui/seqbrowser/SequenceDescription.hpp"
 
 using namespace std;
 
 SequenceDescription::SequenceDescription(QWidget *parent)
-  : QFrame(parent), 
+  : QFrame(parent),
+    layout(0),
+    name_label(0),
+    position_label(0),
+    length_label(0),
     pos(-1) // set pos to an invalid value so the setPos function will call
             // setText
 {
-  createWidget();
+  setupWidgets();
 }
 
 SequenceDescription::SequenceDescription(
@@ -16,21 +19,35 @@ SequenceDescription::SequenceDescription(
     QWidget *parent
 ) : QFrame(parent) 
 {
+  setupWidgets();
   setGlSequence(glseq);  
 }
 
-void SequenceDescription::createWidget()
+void SequenceDescription::setupWidgets()
 {
+  layout = new QVBoxLayout;
+  name_label = new QLineEdit;
+  position_label = new QLabel;
+  length_label = new QLabel;
+  
   setFrameStyle(QFrame::Panel | QFrame::Sunken);
   setLineWidth(1);
-  QLayout *layout = new QVBoxLayout;
-  layout->addWidget(&name_label);
-  layout->addWidget(&length_label);
-  layout->addWidget(&position_label);
-  name_label.setMaximumWidth(length_label.fontMetrics().width("01234567"));
-  setLayout(layout);
 
-  connect(&name_label, SIGNAL(textChanged(const QString& )),
+  // What's this feature descriptions
+  // FIXME: The '*' is added because for some reason
+  // Qt's whatsthis feature is chopping off the last word
+  // If the '*' eventually shows up in a whatsthis pop-up
+  // then the '*' should be removed.
+  name_label->setWhatsThis("Name of sequence *");
+  position_label->setWhatsThis("Edge of viewport base pair position *");
+  length_label->setWhatsThis("Total length of sequence *");
+  
+  layout->addWidget(name_label);
+  layout->addWidget(position_label);
+  layout->addWidget(length_label);
+  name_label->setMaximumWidth(length_label->fontMetrics().width("01234567"));
+  setLayout(layout);
+  connect(name_label, SIGNAL(textChanged(const QString& )),
           this, SLOT(setName(const QString& )));
 }
 
@@ -65,9 +82,9 @@ void SequenceDescription::setName(const QString& name_)
   }
 
     // no need to setText again if its because of user editing
-  if (name_ != name_label.text()) {
-    name_label.setText(name_);
-    name_label.setCursorPosition(0);
+  if (name_ != name_label->text()) {
+    name_label->setText(name_);
+    name_label->setCursorPosition(0);
   }
 }
 
@@ -95,7 +112,7 @@ void SequenceDescription::setLength(int length)
     s.setNum(short_length);
     s += "b";
   }
-  length_label.setText(s);
+  length_label->setText(s);
 }
 
 int SequenceDescription::length() const 
@@ -113,7 +130,7 @@ void SequenceDescription::setPosition(int pos_)
   QString s; 
   if (pos != pos_) {
     pos = pos_;
-    position_label.setText(s.setNum(pos_));
+    position_label->setText(s.setNum(pos_));
     emit positionChanged(pos);
   }
 }