Vespucci  1.0.0
historydialog.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 *******************************************************************************/
20 #include "historydialog.h"
21 #include "ui_historydialog.h"
23 
24 HistoryDialog::HistoryDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws) :
25  QDialog(parent),
26  ui(new Ui::HistoryDialog)
27 {
28  ui->setupUi(this);
29  workspace_ = ws;
30 }
31 
33 {
34  delete ui;
35 }
36 
38 {
39  dataset_key_ = key;
40  QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(key);
41  QStringList actions = dataset->operations();
42  ui->actionsListWidget->clear();
43  ui->actionsListWidget->addItems(actions);
44  ui->datasetLabel->setText("History for " + key);
45 }
46 
47 void HistoryDialog::on_savePushButton_clicked()
48 {
49  QString filename = QFileDialog::getSaveFileName(this, "Save macro",
50  workspace_->directory(),
51  "Text files (*.txt)");
52  if (filename.isEmpty()) return;
53  QFile outfile(filename);
54  outfile.open(QFile::WriteOnly);
55  QTextStream outstream(&outfile);
56  for (int i = 0; i < ui->actionsListWidget->count(); ++i)
57  outstream << ui->actionsListWidget->item(i)->text() << "\n";
58  outfile.close();
59 }
60 
61 void HistoryDialog::on_sendPushButton_clicked()
62 {
63  QStringList macro;
64  for (int i = 0; i < ui->actionsListWidget->count(); ++i)
65  macro << ui->actionsListWidget->item(i)->text();
66  emit MacroRequested(macro);
67 }
68 
69 void HistoryDialog::on_refreshPushButton_clicked()
70 {
71  ui->actionsListWidget->clear();
72  if (workspace_->dataset_names().contains(dataset_key_)){
73  QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key_);
74  QStringList operations = dataset->operations();
75  ui->actionsListWidget->addItems(operations);
76  }
77 }
78 
79 void HistoryDialog::closeEvent(QCloseEvent *event)
80 {
81  workspace_->main_window()->SetHistoryDialogActionChecked(false);
82  event->accept();
83 }
84 
85 void HistoryDialog::showEvent(QShowEvent *event)
86 {
87  workspace_->main_window()->SetHistoryDialogActionChecked(true);
88  event->accept();
89 }
Definition: ahcadialog.h:26
void DatasetSelectionChanged(QString key)
void closeEvent(QCloseEvent *event)
HistoryDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
void MacroRequested(const QStringList &macro)
void showEvent(QShowEvent *event)