Debian Codegraph @

HercUtilities/TapeMap.cpp

raw symbols SCIP
1 /*
2 * File: TapeMap.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 31, 2010
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24 #include "TapeMap.h"
25
26 #include "HerculesStudio.h"
27 #include "SystemUtils.h"
28 #include "Preferences.h"
29 #include "UtilityExecutor.h"
30 #include "UtilityRunner.h"
31 #include "StringTokenizer.h"
32
33 #include <QFileDialog>
34 #include <QMessageBox>
35 #include <QTimer>
36
37 #include <csignal>
38
39 TapeMap::TapeMap(QWidget *parent)
40 : GenericUtility("tapemap", parent)
41 {
42 ui.setupUi(this);
43
44 connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runClicked()));
45 connect(ui.exitButton, SIGNAL(clicked()), this, SLOT(exitClicked()));
46 connect(ui.browseFileButton, SIGNAL(clicked()), this, SLOT(browseFileClicked()));
47 }
48
49 TapeMap::~TapeMap()
50 {
51
52 }
53
54 void TapeMap::runClicked()
55 {
56 if (!runOrStopClicked())
57 {
58 ui.runButton->setText("Run");
59 return;
60 }
61 if (ui.filename->text().isEmpty())
62 {
63 QMessageBox::warning(this, "tapemap", "Please specify tape file to process",
64 QMessageBox::Ok, QMessageBox::NoButton);
65 return;
66 }
67 if (!QFile::exists(ui.filename->text()))
68 {
69 QMessageBox::warning(this, "tapemap", "The specified file does not exist",
70 QMessageBox::Ok, QMessageBox::NoButton);
71 return;
72 }
73 std::vector<std::string> parameters;
74
75 parameters.push_back(ui.filename->text().toStdString());
76
77 std::string command = "tapemap";
78
79 execute(command, Preferences::getInstance().hercDir(), parameters);
80 ui.runButton->setText("Stop");
81 }
82
83 void TapeMap::browseFileClicked()
84 {
85 QString dir = ui.filename->text();
86 if (dir.isEmpty())
87 dir = Preferences::getInstance().configDir().c_str();
88 QString s = QFileDialog::getOpenFileName(this,"Browse for tape to map",dir);
89 ui.filename->setText(s);
90 }
91
92 void TapeMap::exitClicked()
93 {
94 deleteLater();
95 }
96
97 void TapeMap::finishedSlot()
98 {
99 if (mStarted && mFinished && mFinishedOK)
100 {
101 QMessageBox::information(this, "tapemap", "Tapemap operation successfully completed!",
102 QMessageBox::Ok,
103 QMessageBox::NoButton);
104 deleteLater();
105 }
106 else emit error();
107 }