use spinboxes for the setup analysis dialog
authorDiane Trout <diane@caltech.edu>
Wed, 11 Oct 2006 00:52:28 +0000 (00:52 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 11 Oct 2006 00:52:28 +0000 (00:52 +0000)
ticket:148
the easiest way of making sure that threshold was less than window
size was to use spin boxes.

Also I updated the dialog box to use dynamically allocated Qt widgets.

qui/mussa_setup_dialog/MussaSetupWidget.cpp
qui/mussa_setup_dialog/MussaSetupWidget.hpp

index 4e7b37bf26a31c71550920c7477a85fd5d45ff90..bef824470e1574da7372e83841c570d70f3c1523 100644 (file)
@@ -22,42 +22,53 @@ namespace fs = boost::filesystem;
 
 MussaSetupWidget::MussaSetupWidget(QWidget *parent)
   : QWidget(parent),
-    createPushButton(tr("Create")),
-    cancelPushButton(tr("Cancel")),
+    analysisNameLineEdit(new QLineEdit),
+    windowEdit(new QSpinBox),
+    thresholdEdit(new QSpinBox),
+    numOfSequencesSpinBox(new QSpinBox),
+    createPushButton(new QPushButton(tr("Create"))),
+    cancelPushButton(new QPushButton(tr("Cancel"))),
     seqSetupFrame(0)
 {
   
   // Analysis name
   QLabel *analysisNameLabel = new QLabel(tr("Analysis Name"));
-  analysisNameLabel->setBuddy(&analysisNameLineEdit);
+  analysisNameLabel->setBuddy(analysisNameLineEdit);
 
   // Window
+  windowEdit->setMinimum(1);
+  windowEdit->setValue(30);
   QLabel *windowLabel = new QLabel(tr("Window (nt)"));
-  windowLabel->setBuddy(&windowLineEdit);
+  windowLabel->setBuddy(windowEdit);
 
   // Threshold
+  thresholdEdit->setMinimum(1);
+  thresholdEdit->setMaximum(windowEdit->value());
+  thresholdEdit->setValue(21);
   QLabel *thresholdLabel = new QLabel(tr("Threshold (nt)"));
-  thresholdLabel->setBuddy(&thresholdLineEdit);
+  thresholdLabel->setBuddy(thresholdEdit);
+  connect(windowEdit, SIGNAL(valueChanged(int)),
+          this, SLOT(updateThreshold(int)));
 
   // Number of sequences
   QLabel *numOfSequencesLabel = new QLabel(tr("Number of sequences"));
-  numOfSequencesLabel->setBuddy(&numOfSequencesSpinBox);
-  numOfSequencesSpinBox.setMinimum(1);
+  numOfSequencesLabel->setBuddy(numOfSequencesSpinBox);
+  numOfSequencesSpinBox->setMinimum(1);
 
   //Sequence setup frame
   seqSetupFrame = new SequenceSetupFrame;
 
-  connect(&numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
+  connect(numOfSequencesSpinBox, SIGNAL(valueChanged(int)),
          seqSetupFrame, SLOT(changeSequenceCount(int)));
 
-  numOfSequencesSpinBox.setValue(2);
+  numOfSequencesSpinBox->setValue(2);
 
   // Create Experiment Button
-  connect(&createPushButton, SIGNAL(pressed()),
+  connect(createPushButton, SIGNAL(pressed()),
          this, SLOT(mussaCreatePushed()));
   
   // Cancle Button
-  connect(&cancelPushButton, SIGNAL(pressed()),
+  connect(cancelPushButton, SIGNAL(pressed()),
          this, SLOT(mussaCancelPushed()));
 
   // LAYOUT
@@ -67,24 +78,24 @@ MussaSetupWidget::MussaSetupWidget(QWidget *parent)
   QHBoxLayout *buttonLayout = new QHBoxLayout;
 
   row1Layout->addWidget(analysisNameLabel);
-  row1Layout->addWidget(&analysisNameLineEdit);
+  row1Layout->addWidget(analysisNameLineEdit);
 
   row2Layout->addWidget(thresholdLabel);
-  row2Layout->addWidget(&thresholdLineEdit);
+  row2Layout->addWidget(thresholdEdit);
   row2Layout->addWidget(windowLabel);
-  row2Layout->addWidget(&windowLineEdit);
+  row2Layout->addWidget(windowEdit);
   row2Layout->addWidget(numOfSequencesLabel);
-  row2Layout->addWidget(&numOfSequencesSpinBox);
+  row2Layout->addWidget(numOfSequencesSpinBox);
 
-  buttonLayout->addWidget(&createPushButton);
-  buttonLayout->addWidget(&cancelPushButton);
+  buttonLayout->addStretch(1);
+  buttonLayout->addWidget(createPushButton);
+  buttonLayout->addWidget(cancelPushButton);
 
   mainLayout->addLayout(row1Layout);
   mainLayout->addLayout(row2Layout);
   mainLayout->addWidget(seqSetupFrame);
   mainLayout->addLayout(buttonLayout);
   setLayout(mainLayout);
-
 }
 
 void MussaSetupWidget::mussaCreatePushed()
@@ -97,6 +108,11 @@ void MussaSetupWidget::mussaCancelPushed()
   emit cancelButtonPushed();
 }
 
+void MussaSetupWidget::updateThreshold(int new_threshold)
+{
+  thresholdEdit->setMaximum(new_threshold);
+}
+
 MussaRef MussaSetupWidget::getMussaObject()
 {
   MussaRef mussa(new Mussa);
@@ -124,9 +140,9 @@ MussaRef MussaSetupWidget::getMussaObject()
   }
   setupInfoList.clear();
 
-  int win_size = windowLineEdit.text().toInt();
-  int threshold = thresholdLineEdit.text().toInt();
-  std::string name = analysisNameLineEdit.text().toStdString();
+  int win_size = windowEdit->value();
+  int threshold = thresholdEdit->value();
+  std::string name = analysisNameLineEdit->text().toStdString();
   if (win_size == 0 or threshold == 0) {
     throw mussa_load_error("must set analysis parameters");
   } else {
@@ -141,11 +157,3 @@ MussaRef MussaSetupWidget::getMussaObject()
   return mussa;
 }
 
-//MussaSetupWidget::MussaSetupWidget(const MussaSetupWidget& msw)
-//  : analysisNameLineEdit(msw.analysisNameLineEdit),
-//    windowLineEdit(msw.windowLineEdit),
-//    thresholdLineEdit(msw.thresholdLineEdit),
-//    numOfSequencesLineEdit(msw.numOfSequencesLineEdit),
-//    seqSetupFrame(msw.seqSetupFrame)
-//{
-//}
index f228f9ab7a3736a123d85a4b19754020c9631035..4e0a4fd949a0a06073622f6dbe7d203985f161f8 100644 (file)
@@ -27,15 +27,16 @@ signals:
 private slots:
   void mussaCreatePushed();
   void mussaCancelPushed();
+  void updateThreshold(int);
 
 private:
 
-  QLineEdit analysisNameLineEdit;
-  QLineEdit windowLineEdit;
-  QLineEdit thresholdLineEdit;
-  QSpinBox numOfSequencesSpinBox;
-  QPushButton createPushButton;
-  QPushButton cancelPushButton;
+  QLineEdit *analysisNameLineEdit;
+  QSpinBox *windowEdit;
+  QSpinBox *thresholdEdit;
+  QSpinBox *numOfSequencesSpinBox;
+  QPushButton *createPushButton;
+  QPushButton *cancelPushButton;
 
   SequenceSetupFrame *seqSetupFrame;
 };