Finish off setting sequence offset user interface
[mussa.git] / qui / seqbrowser / seqproperties / PropertiesWindow.cpp
index 45427b933b5b65adb62ad72aea8842a4ce8b41ad..a47b7101e9aa502b15533303019d8f661d32dca5 100644 (file)
@@ -14,26 +14,27 @@ PropertiesWindow::PropertiesWindow(/* MussaRef m, */
   : QWidget(parent),
     /* analysis(m), */
     table(0),
-    okButton(0),
-    cancelButton(0),
+    applyButton(0),
+    closeButton(0),
     model(glseqs)
 {
   QGridLayout *parameterLayout = new QGridLayout;
 
-  okButton = new QPushButton(tr("&OK"), this);
-  okButton->setEnabled( false );
-  connect(okButton, SIGNAL(clicked()), this, SLOT(apply()));
+  applyButton = new QPushButton(tr("&Apply"), this);
+  applyButton->setFocusPolicy(Qt::StrongFocus);
+  applyButton->setEnabled( not model.empty() );
+  connect(applyButton, SIGNAL(clicked()), this, SLOT(apply()));
 
-  cancelButton = new QPushButton(tr("Cancel"), this);
-  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
+  closeButton = new QPushButton(tr("Close"), this);
+  connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
 
   table = new QTableView(this);
   table->setModel(&model);
 
   // layout buttons
   QHBoxLayout *buttonLayout = new QHBoxLayout;
-  buttonLayout->addWidget(okButton);
-  buttonLayout->addWidget(cancelButton);
+  buttonLayout->addWidget(applyButton);
+  buttonLayout->addWidget(closeButton);
 
   // layout verticle space
   QVBoxLayout *verticalLayout = new QVBoxLayout;
@@ -55,7 +56,7 @@ SequencePropertiesModel& PropertiesWindow::getModel()
   return model;
 }
 
-void PropertiesWindow::cancel()
+void PropertiesWindow::close()
 {
   model.clear();
   hide();
@@ -63,19 +64,14 @@ void PropertiesWindow::cancel()
 
 void PropertiesWindow::apply()
 {
-  std::cout << "implement PropertiesWindow::apply" << std::endl;
-  
-  for(SequencePropertiesModel::iterator itor = model.begin();
-      itor != model.end();
-      ++itor)
-  {
-  }
+  model.saveChanges();
+  emit propertiesChanged();
 }
 
 void PropertiesWindow::modelUpdated(const QModelIndex&, int, int )
 {
   // if the model is empty we shouldn't be able to click ok
-  if (okButton) okButton->setEnabled(not model.empty());
+  if (applyButton) applyButton->setEnabled(not model.empty());
 }
 
 void PropertiesWindow::updateTitle()