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 #include <OpenFlipper/common/Types.hh>
45 #include <OpenFlipper/Core/Core.hh>
46
47 #include <QtWidgets>
48
49 #include <QDirModel>
50
51 #include <map>
52
53 #include <OpenFlipper/common/FileTypes.hh>
54
55
56 class LoadWidget : public QFileDialog
57 {
58 Q_OBJECT
59 public:
60 LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent = 0 );
61 ~LoadWidget();
62
63 signals:
64 void load(QString _filename, int _pluginID);
65 void loadFiles(QStringList _filenames, IdList _pluginIds);
66 void save(int _id, QString _filename, int _pluginID);
67 void save(IdList _ids, QString _filename, int _pluginID);
68
69 private slots:
70 void slotSetPluginForExtension(QString _extension, int _pluginId );
71 void slotSetLoadFilters();
72 void slotSetSaveFilters(DataType _type);
73
74 private:
75 IdList ids_;
76
77 bool loadMode_;
78 QStringList lastPaths;
79 std::vector<fileTypes>& supportedTypes_;
80
81 public:
82 int showLoad();
83 int showSave(int _id, QString _filename);
84 int showSave(IdList _ids, QString _filename);
85
86 bool validFilename();
88 bool dirExists();
89
90 public slots :
91 virtual void accept();
92
93 private :
94 void loadFile();
95 void saveFile();
96
98 QCheckBox* optionsBox_;
99
100 std::map< QString, int > pluginForExtension_;
101
102 };
103
LoadWidget::showLoad
int showLoad()
show Widget for loading Files
Definition: loadWidget.cc:366
LoadWidget::~LoadWidget
~LoadWidget()
Destructor.
Definition: loadWidget.cc:81
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
IdList
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
LoadWidget::slotSetSaveFilters
void slotSetSaveFilters(DataType _type)
adjust save-filters to current datatype
Definition: loadWidget.cc:133
LoadWidget::saveFile
void saveFile()
find suitable plugin for saving current file
Definition: loadWidget.cc:282
LoadWidget
Definition: loadWidget.hh:56
LoadWidget::showSave
int showSave(int _id, QString _filename)
show Widget for saving Files
Definition: loadWidget.cc:382
Core.hh
FileTypes.hh
LoadWidget::slotSetLoadFilters
void slotSetLoadFilters()
adjust load-filters to current datatype
Definition: loadWidget.cc:87
LoadWidget::loadFile
void loadFile()
find suitable plugin for loading current file
Definition: loadWidget.cc:185
LoadWidget::optionsBox_
QCheckBox * optionsBox_
checkbox for option displaying
Definition: loadWidget.hh:98
Types.hh
LoadWidget::dirExists
bool dirExists()
returns true, if the directory of the specified filename (user input via widget) exists ...
Definition: loadWidget.cc:516