deactivated deprecated start_engrid copy
[engrid.git] / src / iooperation.cpp
blob6cb45af9766d6bf3aaf45503b1b14cbba2065b6a
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "iooperation.h"
24 #include "guimainwindow.h"
26 #include <QFileDialog>
28 IOOperation::IOOperation()
30 EG_TYPENAME;
31 setResetOperationCounter(true);
32 setQuickSave(true);
33 m_FileName = "";
36 void IOOperation::setFormat(QString format)
38 m_FormatTxt = format;
41 void IOOperation::setExtension(QString extension)
43 m_ExtensionTxt = extension;
46 void IOOperation::readInputFileName(QString default_filename)
48 QApplication::restoreOverrideCursor();
50 QFileDialog dialog(NULL, "read file", GuiMainWindow::getCwd(), m_FormatTxt);
51 dialog.selectFile(default_filename);
52 if (dialog.exec()) {
53 QStringList selected_files = dialog.selectedFiles();
54 m_FileName = selected_files[0];
55 if (!m_FileName.isNull()) {
56 GuiMainWindow::setCwd(QFileInfo(m_FileName).absolutePath());
57 GuiMainWindow::setUnsaved(true);
58 GuiMainWindow::pointer()->setFilename(m_FileName);
59 GuiMainWindow::pointer()->resetXmlDoc();
60 m_Valid = true;
61 } else {
62 m_Valid = false;
65 else m_Valid = false;
67 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
70 void IOOperation::readOutputFileName(QString default_filename)
72 QApplication::restoreOverrideCursor();
74 QFileDialog dialog(NULL, "write file", GuiMainWindow::getCwd(), m_FormatTxt);
75 dialog.selectFile(default_filename);
76 dialog.setAcceptMode(QFileDialog::AcceptSave);
77 dialog.setConfirmOverwrite(true);
78 if (dialog.exec()) {
79 QStringList selected_files = dialog.selectedFiles();
80 m_FileName = selected_files[0];
81 if (!m_FileName.isNull()) {
82 GuiMainWindow::setCwd(QFileInfo(m_FileName).absolutePath());
83 if (m_FileName.right(4) != m_ExtensionTxt.toLower()) {
84 if (m_FileName.right(4) != m_ExtensionTxt.toUpper()) {
85 m_FileName += m_ExtensionTxt.toLower();
88 m_Valid = true;
89 } else {
90 m_Valid = false;
93 else m_Valid = false;
95 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
98 void IOOperation::readOutputDirectory()
100 m_FileName = QFileDialog::getExistingDirectory(NULL, "write OpenFOAM mesh", GuiMainWindow::getCwd());
101 if (!m_FileName.isNull()) {
102 GuiMainWindow::setCwd(QFileInfo(m_FileName).absolutePath());
103 m_Valid = true;
104 } else {
105 m_Valid = false;
109 void IOOperation::readInputDirectory(QString title_txt)
111 m_FileName = QFileDialog::getExistingDirectory(NULL, title_txt, GuiMainWindow::getCwd());
112 if (!m_FileName.isNull()) {
113 GuiMainWindow::setCwd(QFileInfo(m_FileName).absolutePath());
114 m_Valid = true;
115 } else {
116 m_Valid = false;
120 bool IOOperation::isValid()
122 return m_Valid;
125 const char* IOOperation::getCFileName()
127 return qPrintable(m_FileName);
130 QString IOOperation::getFileName()
132 return m_FileName;