21 #include "ui_macrodialog.h" 30 dataset_valid_ =
false;
41 dataset_valid_ =
true;
46 QString operations = ui->plainTextEdit->toPlainText() +
"\n";
47 for (
auto line: macro){
48 operations = operations + line +
"\n";
50 ui->plainTextEdit->setPlainText(operations);
55 dataset_ = workspace_->GetDataset(dataset_key);
56 ui->datasetLabel->setText(
"Dataset: " + dataset_key);
61 if (dataset_->name() == dataset_key){
62 dataset_valid_ =
false;
63 dataset_ = QSharedPointer<VespucciDataset>(NULL);
64 ui->datasetLabel->setText(
"Dataset: N/A");
70 QDialog::closeEvent(ev);
74 void MacroDialog::on_openToolButton_clicked()
76 QString filename = QFileDialog::getOpenFileName(
this,
"Load Macro",
77 workspace_->directory(),
78 "Text files (*.txt)");
79 QFileInfo file_info(filename);
80 if (file_info.exists() && file_info.isFile()){
82 file.open(QFile::ReadOnly);
83 QTextStream stream(&file);
84 QString text = stream.readAll();
86 ui->plainTextEdit->clear();
87 ui->plainTextEdit->setPlainText(text);
91 void MacroDialog::on_saveToolButton_clicked()
93 QString filename = QFileDialog::getSaveFileName(
this,
"Save Macro",
94 workspace_->directory(),
95 "Text files (*.txt)");
97 file.open(QFile::WriteOnly);
98 QTextStream stream(&file);
99 QString text = ui->plainTextEdit->toPlainText();
104 void MacroDialog::on_runToolButton_clicked()
106 if (!dataset_.isNull()){
108 QString macro = ui->plainTextEdit->toPlainText();
114 workspace_->main_window()->DisplayExceptionWarning(e);
119 int error_line, error_param;
120 parser.
Error(error_line, error_param);
121 QString description =
"Error occured at parameter " 122 + QString::number(error_param)
123 +
" in line " + QString::number(error_line);
124 QMessageBox::warning(
this,
"Syntax Error", description);
129 void MacroDialog::on_helpToolButton_clicked()
131 QDesktopServices::openUrl(QUrl(
"http://vespucciproject.org/Vespucci-docs/adv/macros.html"));
134 void MacroDialog::on_runAllToolButton_clicked()
136 QString macro = ui->plainTextEdit->toPlainText();
137 for (
auto dataset_key: workspace_->dataset_names()){
138 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
145 workspace_->main_window()->DisplayExceptionWarning(e);
150 int error_line, error_param;
151 parser.
Error(error_line, error_param);
152 QString description =
"Error occured at parameter " 153 + QString::number(error_param)
154 +
" in line " + QString::number(error_line);
155 QMessageBox::warning(
this,
"Syntax Error", description);
MacroDialog(MainWindow *parent, QSharedPointer< VespucciWorkspace > ws)
void SetActionChecked(bool checked)
void closeEvent(QCloseEvent *ev)
bool LoadMacro(QString macro)
MacroParser::LoadMacro.
void DatasetSelectionChanged(QString dataset_key)
void MacroRequested(const QStringList ¯o)
void SetActiveDataset(QSharedPointer< VespucciDataset > dataset)
void Error(int &error_line, int &error_param)
void DatasetToBeRemoved(const QString &dataset_key)
bool ExecuteMacro()
MacroParser::ExecuteMacro Iteratively executes the commands in commands_. Each command is first valid...
The MainWindow class The main window of the program, this is where the user performs most operations...