Developer Documentation
loadWidget.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
51 #include <OpenFlipper/Core/Core.hh>
52 
53 #if QT_VERSION >= 0x050000
54  #include <QtWidgets>
55 #else
56  #include <QtGui>
57 #endif
58 
59 #include <QDirModel>
60 
61 #include <map>
62 
63 class LoadWidget : public QFileDialog
64 {
65  Q_OBJECT
66  public:
67  LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent = 0 );
68  ~LoadWidget();
69 
70  signals:
71  void load(QString _filename, int _pluginID);
72  void loadFiles(QStringList _filenames, IdList _pluginIds);
73  void save(int _id, QString _filename, int _pluginID);
74  void save(IdList _ids, QString _filename, int _pluginID);
75 
76  private slots:
77  void slotSetPluginForExtension(QString _extension, int _pluginId );
78  void slotSetLoadFilters();
79  void slotSetSaveFilters(DataType _type);
80 
81  private:
82  IdList ids_;
83 
84  bool loadMode_;
85  QStringList lastPaths;
86  std::vector<fileTypes>& supportedTypes_;
87 
88  public:
89  int showLoad();
90  int showSave(int _id, QString _filename);
91  int showSave(IdList _ids, QString _filename);
92 
93  bool validFilename();
95  bool dirExists();
96 
97  public slots :
98  virtual void accept();
99 
100  private :
101  void loadFile();
102  void saveFile();
103 
105  QCheckBox* optionsBox_;
106 
107  std::map< QString, int > pluginForExtension_;
108 
109 };
110 
int showLoad()
show Widget for loading Files
Definition: loadWidget.cc:372
void slotSetSaveFilters(DataType _type)
adjust save-filters to current datatype
Definition: loadWidget.cc:139
Predefined datatypes.
Definition: DataTypes.hh:96
QCheckBox * optionsBox_
checkbox for option displaying
Definition: loadWidget.hh:105
int showSave(int _id, QString _filename)
show Widget for saving Files
Definition: loadWidget.cc:388
void slotSetLoadFilters()
adjust load-filters to current datatype
Definition: loadWidget.cc:93
~LoadWidget()
Destructor.
Definition: loadWidget.cc:87
void loadFile()
find suitable plugin for loading current file
Definition: loadWidget.cc:191
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
void saveFile()
find suitable plugin for saving current file
Definition: loadWidget.cc:288
bool dirExists()
returns true, if the directory of the specified filename (user input via widget) exists ...
Definition: loadWidget.cc:522