2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
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. +
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. +
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/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "iooperation.h"
24 #include "guimainwindow.h"
26 #include <QFileDialog>
28 IOOperation::IOOperation()
31 setResetOperationCounter(true);
36 void IOOperation::setFormat(QString 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
);
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();
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);
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();
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());
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());
120 bool IOOperation::isValid()
125 const char* IOOperation::getCFileName()
127 return qPrintable(m_FileName
);
130 QString
IOOperation::getFileName()