Vespucci  1.0.0
metadatasetdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
21 #include "ui_metadatasetdialog.h"
23 MetaDatasetDialog::MetaDatasetDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws) :
24  QDialog(parent),
25  ui(new Ui::MetaDatasetDialog)
26 {
27  ui->setupUi(this);
28  workspace_ = ws;
29  dataset_list_model_ = new DatasetListModel(this, workspace_->dataset_names());
30  ui->datasetListView->setModel(dataset_list_model_);
31  ui->datasetListView->setSelectionMode(QAbstractItemView::MultiSelection);
32 }
33 
35 {
36  delete ui;
37 }
38 
39 void MetaDatasetDialog::on_buttonBox_rejected()
40 {
41  close();
42 }
43 
44 void MetaDatasetDialog::on_buttonBox_accepted()
45 {
46  QList<QSharedPointer<VespucciDataset> > parent_datasets;
47  QModelIndexList selected_indices = ui->datasetListView->selectionModel()->selectedRows();
48  if (selected_indices.size() <= 0){
49  return;
50  }
51  for (int i = 0; i < selected_indices.size(); ++i){
52  parent_datasets.append(workspace_->GetDataset(dataset_list_model_->DatasetName(selected_indices[i].row())));
53  }
54 
55  QString method_description = ui->methodComboBox->currentText();
56  MetaMethod::Method method;
57  switch(ui->methodComboBox->currentIndex()){
58  case 0:
59  cout << method_description.toStdString() << "\n";
60 
61  cout << "0\n";
62 
64  break;
65  case 1: default:
66  cout << method_description.toStdString() << "\n";
67 
68  cout << "1 or default\n";
69 
71  break;
72  }
73 
74  QString name = ui->nameLineEdit->text();
75  QSharedPointer<MetaDataset> new_dataset;
76  try{
77  new_dataset = QSharedPointer<MetaDataset>(new MetaDataset(name, workspace_->main_window(), workspace_->directory_ptr(), method_description, method, parent_datasets));
78  }
79  catch(exception e){
80  cerr << "Exception thrown\n";
81 
82  cerr << e.what() << "\n";
83 
84  QMessageBox::warning(this, "Exception Occured", "An exception was thrown in the MetaDataset constructor");
85  return;
86  }
87  workspace_->AddDataset(new_dataset);
88 
89 }
The MetaDataset class A subclass of VespucciDataset for datasets created from multiple other datasets...
Definition: metadataset.h:30
Definition: ahcadialog.h:26
MetaDatasetDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
QString DatasetName(int row)