Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/file/GNEFileDialog.h
193808 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNEFileDialog.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Aug 2025
17
///
18
// Dialog used for opening/saving files
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/dialogs/GNEDialog.h>
24
25
// ===========================================================================
26
// class declaration
27
// ===========================================================================
28
29
class GNEFileSelector;
30
31
// ===========================================================================
32
// class definitions
33
// ===========================================================================
34
35
class GNEFileDialog : public GNEDialog {
36
37
public:
38
/// @brief file open mode
39
enum class OpenMode {
40
SAVE, // A single file, existing or not (to save to)
41
LOAD_SINGLE, // An existing file (to load)
42
LOAD_MULTIPLE, // Multiple existing files
43
LOAD_DIRECTORY // Existing directory, including '.' or '..'
44
};
45
46
/// @brief config type
47
enum class ConfigType {
48
SUMO, // sumo config
49
NETEDIT, // netedit config
50
};
51
52
/// @brief constructor
53
GNEFileDialog(GNEApplicationWindow* applicationWindow, const std::string elementFile,
54
const std::vector<std::string>& extensions, GNEFileDialog::OpenMode openMode,
55
GNEFileDialog::ConfigType configType, const std::string initialFolder = "");
56
57
/// @brief constructor with dialog parent
58
GNEFileDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,
59
const std::string elementFile, const std::vector<std::string>& extensions,
60
GNEFileDialog::OpenMode openMode, GNEFileDialog::ConfigType configType,
61
const std::string initialFolder = "");
62
63
/// @brief destructor
64
~GNEFileDialog();
65
66
/// @brief run internal test
67
void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument);
68
69
/// @brief Return file name, if any
70
std::string getFilename() const;
71
72
/// @brief Return empty-string terminated list of selected file names, or NULL if none selected
73
std::vector<std::string> getFilenames() const;
74
75
/// @brief Return directory
76
std::string getDirectory() const;
77
78
/// @brief check extensions
79
std::string assureExtension(const std::string& filename) const;
80
81
/// @name FOX-callbacks
82
/// @{
83
84
/// @brief called when accept or yes button is pressed (can be reimplemented in children)
85
long onCmdAccept(FXObject*, FXSelector, void*);
86
87
/// @}
88
89
protected:
90
/// @brief the file selector widget
91
GNEFileSelector* myFileSelector;
92
93
private:
94
/// @brief builder
95
void buildFileDialog(const std::string elementFile, const std::vector<std::string>& extensions,
96
GNEFileDialog::OpenMode openMode, GNEFileDialog::ConfigType configType,
97
const std::string initialFolder);
98
99
/// @brief invalidate copy constructor
100
GNEFileDialog(const GNEFileDialog&) = delete;
101
102
/// @brief invalidate assignment operator
103
GNEFileDialog& operator=(const GNEFileDialog&) = delete;
104
};
105
106