WhatsThis update
[mussa.git] / qui / mussa_setup_dialog / SequenceSetupWidget.cpp
index 832abbfd297866ee66219a70d8a9bb4ac2cc86ff..7128c4f51ddc230d2518a1b6a2ffaaca03cbafa2 100644 (file)
@@ -5,68 +5,96 @@
 #include <QFileDialog>
 #include <QPushButton>
 
-//#include "qui/IsFileValidator.hpp"
 #include "qui/mussa_setup_dialog/SequenceSetupWidget.hpp"
+#include "qui/mussa_setup_dialog/SequenceSetupFrame.hpp"
 
+#include <cassert>
 
-SequenceSetupWidget::SequenceSetupWidget(QWidget *parent) :
-  QWidget(parent), 
+SequenceSetupWidget::SequenceSetupWidget(SequenceSetupFrame *setupFrame_,
+                                         QWidget *parent) :
+  QWidget(parent),
+  sequenceNameEdit(0),
   sequenceLineEdit(0), 
   annotLineEdit(0),
   fastaIndexLineEdit(0),
   seqStartLineEdit(0),
-  seqStopLineEdit(0)
+  seqStopLineEdit(0),
+  setupFrame(setupFrame_)
 {
+  // we really need the setupFrame, so lets declair that requirement
+  assert(setupFrame != 0);
+
+  sequenceNameEdit = new QLineEdit;
+  sequenceNameEdit->setWhatsThis("Name of input sequence ");
+  QLabel *sequenceNameLabel = new QLabel(tr("Sequence name:"));
+  sequenceNameLabel->setBuddy(sequenceNameEdit);
+  sequenceNameLabel->setWhatsThis("Name of input sequence ");
 
   // Sequence row
   sequenceLineEdit = new QLineEdit;
+  sequenceLineEdit->setWhatsThis("File path to input sequence ");
   //const IsFileValidator *fileValidator = new IsFileValidator(this);
   //sequenceLineEdit->setValidator(fileValidator);
-  QLabel *sequenceLabel = new QLabel("Sequence:");
+  QLabel *sequenceLabel = new QLabel("Sequence Filename:");
   sequenceLabel->setBuddy(sequenceLineEdit);
+  sequenceLabel->setWhatsThis("File path to input sequence ");
   
   QPushButton *sequenceButton = new QPushButton("Browse...");
+  sequenceButton->setWhatsThis("Browse for input sequence ");
   connect(sequenceButton, SIGNAL(clicked()), 
          this, SLOT(promptForFastaFile()));
 
   // Annotation row
   annotLineEdit = new QLineEdit;
+  annotLineEdit->setWhatsThis("Annotation file path for above input sequence ");
   //const IsFileValidator *fileValidator2 = new IsFileValidator(this);
   //annotLineEdit->setValidator(fileValidator2);
-  QLabel *annotLabel = new QLabel("Label:");
+  QLabel *annotLabel = new QLabel("Annotation Filename:");
   annotLabel->setBuddy(annotLineEdit);
+  annotLabel->setWhatsThis("Annotation file path for above input sequence ");
 
   QPushButton *annotButton = new QPushButton("Browse...");
+  annotButton->setWhatsThis("Browse for annotation file for above input sequence ");
   connect(annotButton, SIGNAL(clicked()),
          this, SLOT(promptForAnnotFile()));
 
   // Index row
   fastaIndexLineEdit = new QLineEdit;
+  fastaIndexLineEdit->setWhatsThis("When a FASTA file contains more then one FASTA record, provide a 1 based index (first record is index 1) to select which one to use. ");
   //fastaIndexLineEdit->setMaximumWidth(100);
 
   QLabel *fastaIndexLabel = new QLabel("Fasta Index:");
   fastaIndexLabel->setBuddy(fastaIndexLineEdit);
+  fastaIndexLabel->setWhatsThis("When a FASTA file contains more then one FASTA record, provide a 1 based index (first record is index 1) to select which one to use. ");
 
   seqStartLineEdit = new QLineEdit;
+  seqStartLineEdit->setWhatsThis("Start base pair in input sequence (0 based: 1st base pair is 0) ");
   //seqStartLineEdit->setMinimumWidth(60);
   //seqStartLineEdit->setMaximumWidth(80);
 
   QLabel *seqStartLabel = new QLabel("Sequence Start:");
+  seqStartLabel->setWhatsThis("Start base pair in input sequence (0 based: 1st base pair is 0) ");
   seqStartLabel->setBuddy(seqStartLineEdit);
   
   seqStopLineEdit = new QLineEdit;
+  seqStopLineEdit->setWhatsThis("Stop base pair in input sequence (0 based: 1st base pair is 0) 0 means all of remaining sequence. ");
   //seqStopLineEdit->setMinimumWidth(40);
   //seqStopLineEdit->setMaximumWidth(60);
 
   QLabel *seqStopLabel = new QLabel("Sequence Stop:");
+  seqStopLabel->setWhatsThis("Stop base pair in input sequence (0 based: 1st base pair is 0) 0 means all of remaining sequence. ");
   seqStopLabel->setBuddy(seqStopLineEdit);
 
   // Layout
+  QHBoxLayout *sequenceNameLayout = new QHBoxLayout;
   QHBoxLayout *sequenceRowLayout = new QHBoxLayout;
   QHBoxLayout *annotRowLayout = new QHBoxLayout;
   QHBoxLayout *indexRowLayout = new QHBoxLayout;
   QVBoxLayout *mainLayout = new QVBoxLayout;
 
+  sequenceNameLayout->addWidget(sequenceNameLabel);
+  sequenceNameLayout->addWidget(sequenceNameEdit);
+
   sequenceRowLayout->addWidget(sequenceLabel);
   sequenceRowLayout->addWidget(sequenceLineEdit);
   sequenceRowLayout->addWidget(sequenceButton);
@@ -82,43 +110,56 @@ SequenceSetupWidget::SequenceSetupWidget(QWidget *parent) :
   indexRowLayout->addWidget(seqStopLabel);
   indexRowLayout->addWidget(seqStopLineEdit);
 
+  mainLayout->addLayout(sequenceNameLayout);
   mainLayout->addLayout(sequenceRowLayout);
   mainLayout->addLayout(annotRowLayout);
   mainLayout->addLayout(indexRowLayout);
   setLayout(mainLayout);
 }
 
-SequenceSetupWidget::SequenceSetupWidget(const SequenceSetupWidget& ssw) :
-  sequenceLineEdit(ssw.sequenceLineEdit), 
-  annotLineEdit(ssw.annotLineEdit),
-  fastaIndexLineEdit(ssw.fastaIndexLineEdit),
-  seqStartLineEdit(ssw.seqStartLineEdit),
-  seqStopLineEdit(ssw.seqStopLineEdit)
+//SequenceSetupWidget::SequenceSetupWidget(const SequenceSetupWidget& ssw) :
+//  sequenceLineEdit(ssw.sequenceLineEdit), 
+//  annotLineEdit(ssw.annotLineEdit),
+//  fastaIndexLineEdit(ssw.fastaIndexLineEdit),
+//  seqStartLineEdit(ssw.seqStartLineEdit),
+//  seqStopLineEdit(ssw.seqStopLineEdit)
+//{
+//}
+
+int SequenceSetupWidget::getFastaIndex() const
 {
+  if (fastaIndexLineEdit->text().size() == 0)
+    return 1;
+  else
+    return fastaIndexLineEdit->text().toInt(); 
 }
 
 void SequenceSetupWidget::promptForFastaFile()
 {
+  QString default_dir = setupFrame->get_default_dir().absolutePath();
   QString fastaFilePath = QFileDialog::getOpenFileName(this,
                                               "Choose a fasta file",
-                                              ".",
+                                              default_dir,
                                               "Fasta (*.fa *.fasta *.fsa *.txt)");
   if (fastaFilePath.isEmpty())
     return;
 
   sequenceLineEdit->setText(fastaFilePath);
+  setupFrame->set_default_dir(QDir(fastaFilePath));
   return;
 }
 
 void SequenceSetupWidget::promptForAnnotFile()
 {
+  QString default_dir = setupFrame->get_default_dir().absolutePath();
   QString annotFilePath = QFileDialog::getOpenFileName(this,
                                               "Choose a annotation file",
-                                              ".",
-                                              "Annot (*.txt)");
+                                              default_dir,
+                                              "Annot (*.txt *.annot)");
   if (annotFilePath.isEmpty())
     return;
 
   annotLineEdit->setText(annotFilePath);
+  setupFrame->set_default_dir(QDir(annotFilePath));
   return;
 }