Debian Codegraph @

HercUtilities/HetUpd.cpp

raw symbols SCIP
1 /*
2 * File: HetUpd.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Sep 3, 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
25 #include "HetUpd.h"
26 #include "HerculesStudio.h"
27 #include "UtilityRunner.h"
28 #include "Preferences.h"
29
30 #include <QFileDialog>
31 #include <QMessageBox>
32
33 #include <csignal>
34
35
36 HetUpd::HetUpd(QWidget *parent)
37 : GenericUtility("hetupd",parent)
38 {
39 ui.setupUi(this);
40
41 connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runClicked()));
42 connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(exitClicked()));
43 connect(ui.selInfile, SIGNAL(clicked()), this, SLOT(browseInFileClicked()));
44 connect(ui.selOutdir, SIGNAL(clicked()), this, SLOT(browseOutDirClicked()));
45 connect(ui.selOutfile, SIGNAL(clicked()), this, SLOT(browseOutFileClicked()));
46
47 ui.outdir->setText(Preferences::getInstance().logsDir().c_str());
48 ui.outdir->setBackgroundRole(QPalette::Window);
49 ui.outdir->setToolTip("Use the button on the right to select directory");
50 }
51
52 HetUpd::~HetUpd()
53 {
54
55 }
56
57 void HetUpd::runClicked()
58 {
59 if (!runOrStopClicked())
60 {
61 ui.runButton->setText("Run");
62 return;
63 }
64
65 if (ui.outfile->text().isEmpty())
66 {
67 QMessageBox::warning(this, "hetupd", "Please specify tape file to create",
68 QMessageBox::Ok, QMessageBox::NoButton);
69 return;
70 }
71 std::vector<std::string> parameters;
72
73
74 std::string command = "hetupd";
75
76 execute(command, Preferences::getInstance().hercDir(), parameters);
77 ui.runButton->setText("Stop");
78 }
79
80
81 void HetUpd::exitClicked()
82 {
83 deleteLater();
84 }
85
86 void HetUpd::browseInFileClicked()
87 {
88 QString s = QFileDialog::getOpenFileName(this,"Browse for Input File",ui.infile->text());
89 if (s.size() > 0)
90 ui.infile->setText(s);
91 }
92
93 void HetUpd::browseOutFileClicked()
94 {
95 QString s = QFileDialog::getOpenFileName(this,"Browse for Output File",ui.outfile->text());
96 if (s.size() > 0)
97 {
98 QFileInfo fi(s);
99 ui.outdir->setText(fi.absolutePath());
100 ui.outfile->setText(fi.fileName());
101 }
102 }
103
104 void HetUpd::browseOutDirClicked()
105 {
106 QString s = QFileDialog::getExistingDirectory(this,"Browse For Output Directory",ui.outdir->text());
107 if (s.size() > 0) ui.outdir->setText(s);
108 }
109
110 void HetUpd::finishedSlot()
111 {
112 deleteLater();
113 }