OGS
FileListDialog Class Reference

Detailed Description

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

Definition at line 32 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 25 of file FileListDialog.cpp.

26 : QDialog(parent),
27 _output_dir(""),
28 _input_file_type(input),
29 _output_file_type(output)
30{
31 setupUi(this);
32
34 {
36 }
37
38 this->listView->setModel(&_allFiles);
39}
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_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 87 of file FileListDialog.cpp.

88{
89 if (_allFiles.stringList().empty())
90 {
91 OGSError::box("No files selected.");
92 return;
93 }
94
95 _output_dir = this->outputDirEdit->text();
96 if (!this->outputDirEdit->text().isEmpty() && QDir(_output_dir).exists())
97 {
98 this->done(QDialog::Accepted);
99 }
100 else
101 {
102 OGSError::box("Output directory not found.");
103 }
104}
static void box(const QString &e)
Definition OGSError.cpp:23

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

◆ displayWarningLabel()

void FileListDialog::displayWarningLabel ( ) const
private

Display a warning for vtu- to msh-conversion.

Definition at line 132 of file FileListDialog.cpp.

133{
134 this->warningLabel->setFixedWidth(300);
135 this->warningLabel->setFixedHeight(40);
136 QFont font = this->warningLabel->font();
137 font.setPointSize(9);
138 font.setBold(true);
139 warningLabel->setFont(font);
140 this->warningLabel->setStyleSheet("QLabel { color : red; }");
141 this->warningLabel->setText(
142 "Warning: all scalar information except<br />MaterialIDs will be "
143 "lost!");
144}

Referenced by FileListDialog().

◆ getFileTypeString()

QString FileListDialog::getFileTypeString ( FileType file_type) const
private

Returns a string for the given file type enum.

Definition at line 111 of file FileListDialog.cpp.

112{
113 if (file_type == FileType::GML)
114 {
115 return "OpenGeoSys geometry files (*.gml)";
116 }
117 if (file_type == FileType::VTU)
118 {
119 return "OpenGeoSys mesh files (*.vtu)";
120 }
121 if (file_type == FileType::GLI)
122 {
123 return "GeoSys geometry files (*.gli)";
124 }
125 if (file_type == FileType::MSH)
126 {
127 return "GeoSys mesh files (*.msh)";
128 }
129 return "All files (*.*)";
130}

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 43 of file FileListDialog.cpp.

44{
45 QSettings settings("UFZ", "OpenGeoSys-5");
46 QFileDialog dlg(this);
47 dlg.setDirectory(settings.value("lastOpenedOgsFileDirectory").toString());
48 dlg.setFileMode(QFileDialog::ExistingFiles);
49 dlg.setNameFilter(this->getFileTypeString(_input_file_type));
50
51 if (dlg.exec())
52 {
53 QStringList const file_names = dlg.selectedFiles();
54
55 if (file_names.empty())
56 {
57 return;
58 }
59
60 QStringList list = _allFiles.stringList();
61 list.append(file_names);
62 _allFiles.setStringList(list);
63 QDir const dir = QDir(file_names[0]);
64 settings.setValue("lastOpenedOgsFileDirectory", dir.absolutePath());
65 }
66}
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 78 of file FileListDialog.cpp.

79{
80 QSettings const settings("UFZ", "OpenGeoSys-5");
81 QFileInfo const fi(settings.value("lastOpenedOgsFileDirectory").toString());
82 QString const dirName = QFileDialog::getExistingDirectory(
83 this, "Save to", fi.absolutePath().append("/"));
84 this->outputDirEdit->setText(dirName);
85}

◆ on_removeButton_pressed

void FileListDialog::on_removeButton_pressed ( )
privateslot

Definition at line 68 of file FileListDialog.cpp.

69{
70 QModelIndexList selected =
71 this->listView->selectionModel()->selectedIndexes();
72 for (auto& item : selected)
73 {
74 this->_allFiles.removeRow(item.row());
75 }
76}

References _allFiles.

◆ reject

void FileListDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 106 of file FileListDialog.cpp.

107{
108 this->done(QDialog::Rejected);
109}

Member Data Documentation

◆ _allFiles

QStringListModel FileListDialog::_allFiles
private

◆ _input_file_type

const FileType FileListDialog::_input_file_type
private

Definition at line 55 of file FileListDialog.h.

Referenced by FileListDialog(), and on_addButton_pressed().

◆ _output_dir

QString FileListDialog::_output_dir
private

Definition at line 54 of file FileListDialog.h.

Referenced by accept(), and getOutputDir().

◆ _output_file_type

const FileType FileListDialog::_output_file_type
private

Definition at line 56 of file FileListDialog.h.

Referenced by FileListDialog().


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