OGS
FileListDialog Class Reference

Detailed Description

A list of selected files selected for conversion incl. an output directory.

Definition at line 21 of file FileListDialog.h.

#include <FileListDialog.h>

Inheritance diagram for FileListDialog:
[legend]
Collaboration diagram for FileListDialog:
[legend]

Public Member Functions

 FileListDialog (FileType input, FileType output, QWidget *parent=nullptr)
 Constructor.
 ~FileListDialog () override
 Destructor.
const QStringList getInputFileList () const
 Returns list of all selected files.
const QString getOutputDir () const
 Returns selected output directory.

Private Slots

void on_addButton_pressed ()
void on_removeButton_pressed ()
void on_browseButton_pressed ()
void accept () override
 Instructions if the OK-Button has been pressed.
void reject () override
 Instructions if the Cancel-Button has been pressed.

Private Member Functions

QString getFileTypeString (FileType file_type) const
 Returns a string for the given file type enum.
void displayWarningLabel () const
 Display a warning for vtu- to msh-conversion.

Private Attributes

QStringListModel _allFiles
QString _output_dir
const FileType _input_file_type
const FileType _output_file_type

Constructor & Destructor Documentation

◆ FileListDialog()

FileListDialog::FileListDialog ( FileType input,
FileType output,
QWidget * parent = nullptr )

Constructor.

Definition at line 14 of file FileListDialog.cpp.

15 : QDialog(parent),
16 _output_dir(""),
17 _input_file_type(input),
18 _output_file_type(output)
19{
20 setupUi(this);
21
23 {
25 }
26
27 this->listView->setModel(&_allFiles);
28}
QStringListModel _allFiles
const FileType _input_file_type
void displayWarningLabel() const
Display a warning for vtu- to msh-conversion.
const FileType _output_file_type

References _allFiles, _input_file_type, _output_dir, _output_file_type, displayWarningLabel(), MSH, and VTU.

◆ ~FileListDialog()

FileListDialog::~FileListDialog ( )
overridedefault

Destructor.

Member Function Documentation

◆ accept

void FileListDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 76 of file FileListDialog.cpp.

77{
78 if (_allFiles.stringList().empty())
79 {
80 OGSError::box("No files selected.");
81 return;
82 }
83
84 _output_dir = this->outputDirEdit->text();
85 if (!this->outputDirEdit->text().isEmpty() && QDir(_output_dir).exists())
86 {
87 this->done(QDialog::Accepted);
88 }
89 else
90 {
91 OGSError::box("Output directory not found.");
92 }
93}
static void box(const QString &e)
Definition OGSError.cpp:13

References _allFiles, _output_dir, and OGSError::box().

◆ displayWarningLabel()

void FileListDialog::displayWarningLabel ( ) const
private

Display a warning for vtu- to msh-conversion.

Definition at line 121 of file FileListDialog.cpp.

122{
123 this->warningLabel->setFixedWidth(300);
124 this->warningLabel->setFixedHeight(40);
125 QFont font = this->warningLabel->font();
126 font.setPointSize(9);
127 font.setBold(true);
128 warningLabel->setFont(font);
129 this->warningLabel->setStyleSheet("QLabel { color : red; }");
130 this->warningLabel->setText(
131 "Warning: all scalar information except<br />MaterialIDs will be "
132 "lost!");
133}

Referenced by FileListDialog().

◆ getFileTypeString()

QString FileListDialog::getFileTypeString ( FileType file_type) const
private

Returns a string for the given file type enum.

Definition at line 100 of file FileListDialog.cpp.

101{
102 if (file_type == FileType::GML)
103 {
104 return "OpenGeoSys geometry files (*.gml)";
105 }
106 if (file_type == FileType::VTU)
107 {
108 return "OpenGeoSys mesh files (*.vtu)";
109 }
110 if (file_type == FileType::GLI)
111 {
112 return "GeoSys geometry files (*.gli)";
113 }
114 if (file_type == FileType::MSH)
115 {
116 return "GeoSys mesh files (*.msh)";
117 }
118 return "All files (*.*)";
119}

References GLI, GML, MSH, and VTU.

Referenced by on_addButton_pressed().

◆ getInputFileList()

const QStringList FileListDialog::getInputFileList ( ) const
inline

◆ getOutputDir()

const QString FileListDialog::getOutputDir ( ) const
inline

◆ on_addButton_pressed

void FileListDialog::on_addButton_pressed ( )
privateslot

Definition at line 32 of file FileListDialog.cpp.

33{
34 QSettings settings("UFZ", "OpenGeoSys-5");
35 QFileDialog dlg(this);
36 dlg.setDirectory(settings.value("lastOpenedOgsFileDirectory").toString());
37 dlg.setFileMode(QFileDialog::ExistingFiles);
38 dlg.setNameFilter(this->getFileTypeString(_input_file_type));
39
40 if (dlg.exec())
41 {
42 QStringList const file_names = dlg.selectedFiles();
43
44 if (file_names.empty())
45 {
46 return;
47 }
48
49 QStringList list = _allFiles.stringList();
50 list.append(file_names);
51 _allFiles.setStringList(list);
52 QDir const dir = QDir(file_names[0]);
53 settings.setValue("lastOpenedOgsFileDirectory", dir.absolutePath());
54 }
55}
QString getFileTypeString(FileType file_type) const
Returns a string for the given file type enum.

References _allFiles, _input_file_type, and getFileTypeString().

◆ on_browseButton_pressed

void FileListDialog::on_browseButton_pressed ( )
privateslot

Definition at line 67 of file FileListDialog.cpp.

68{
69 QSettings const settings("UFZ", "OpenGeoSys-5");
70 QFileInfo const fi(settings.value("lastOpenedOgsFileDirectory").toString());
71 QString const dirName = QFileDialog::getExistingDirectory(
72 this, "Save to", fi.absolutePath().append("/"));
73 this->outputDirEdit->setText(dirName);
74}

◆ on_removeButton_pressed

void FileListDialog::on_removeButton_pressed ( )
privateslot

Definition at line 57 of file FileListDialog.cpp.

58{
59 QModelIndexList selected =
60 this->listView->selectionModel()->selectedIndexes();
61 for (auto& item : selected)
62 {
63 this->_allFiles.removeRow(item.row());
64 }
65}

References _allFiles.

◆ reject

void FileListDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 95 of file FileListDialog.cpp.

96{
97 this->done(QDialog::Rejected);
98}

Member Data Documentation

◆ _allFiles

QStringListModel FileListDialog::_allFiles
private

◆ _input_file_type

const FileType FileListDialog::_input_file_type
private

Definition at line 44 of file FileListDialog.h.

Referenced by FileListDialog(), and on_addButton_pressed().

◆ _output_dir

QString FileListDialog::_output_dir
private

Definition at line 43 of file FileListDialog.h.

Referenced by FileListDialog(), accept(), and getOutputDir().

◆ _output_file_type

const FileType FileListDialog::_output_file_type
private

Definition at line 45 of file FileListDialog.h.

Referenced by FileListDialog().


The documentation for this class was generated from the following files: