Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QtFileDialog.cc
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 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51
52 //=============================================================================
53 //
54 // CLASS QtFileDialog - IMPLEMENTATION
55 //
56 //=============================================================================
57
58 //== INCLUDES =================================================================
59
60 #include "QtFileDialog.hh"
61
62 #include <OpenMesh/Core/IO/IOManager.hh>
63
64 #include <QFileDialog>
65 #include <QMessageBox>
66
67
68 //== NAMESPACES ===============================================================
69
70 namespace ACG {
71
72 //== IMPLEMENTATION ==========================================================
73
74
75 QString
76 getOpenFileName(QWidget* _parent,
77 const QString& _caption,
78 const QString& _filter,
79 const QString& _start)
80 {
81 return
82 QFileDialog::getOpenFileName( _parent, // parent
83 _caption, // caption
84 _start, // dir
85 _filter, // filter
86 0, // selected filter
87 0 // options
88 );
89 }
90
91
92 QString
93 getOpenMeshName(QWidget* _parent,
94 const QString& _caption,
95 const QString& _start)
96 {
97 return
98 ACG::getOpenFileName(_parent,
99 _caption,
100 OpenMesh::IO::IOManager().qt_read_filters().c_str(),
101 _start);
102 }
103
104
105 //-----------------------------------------------------------------------------
106
107
108 QStringList
109 getOpenFileNames(QWidget* _parent,
110 const QString& _caption,
111 const QString& _filter,
112 const QString& _start)
113 {
114 return
115 QFileDialog::getOpenFileNames( _parent, // parent
116 _caption, // caption
117 _start, // dir
118 _filter, //_filter
119 0, // selected filter
120 0 // options
121 );
122 }
123
124
125 QStringList
126 getOpenMeshNames(QWidget* _parent,
127 const QString& _caption,
128 const QString& _start)
129 {
130 return
131 ACG::getOpenFileNames(_parent,
132 _caption,
133 OpenMesh::IO::IOManager().qt_read_filters().c_str(),
134 _start);
135 }
136
137
138 //-----------------------------------------------------------------------------
139
140
141 QString
142 getSaveFileName(QWidget* _parent,
143 const QString& _caption,
144 const QString& _filter,
145 bool _askOW,
146 const QString& _start)
147 {
148 QString filename =
149 QFileDialog::getSaveFileName ( _parent, // parent
150 _caption, // caption
151 _start, // dir
152 _filter, // filter,
153 0, // selected filter
154 0 // options
155 );
156
157 if (_askOW && !filename.isEmpty() && QFile(filename).exists())
158 {
159 QString s;
160 s += QString("The file\n ");
161 s += filename;
162 s += QString("\nalready exists.\n\n");
163 s += QString("Do you want to overwrite it?");
164
165 if (QMessageBox::warning(_parent, "Overwrite", s,
166 QMessageBox::Yes | QMessageBox::Default,
167 QMessageBox::No | QMessageBox::Escape)
168 != QMessageBox::Yes)
169 return QString::null;
170 }
171
172 return filename;
173 }
174
175
176 QString
177 getSaveMeshName(QWidget* _parent,
178 const QString& _caption,
179 bool _askOW,
180 const QString& _start)
181 {
182 return
183 ACG::getSaveFileName(_parent,
184 _caption,
185 OpenMesh::IO::IOManager().
186 qt_write_filters().c_str(),
187 _askOW,
188 _start);
189 }
190
191
192 //=============================================================================
193 } // namespace ACG
194 //=============================================================================
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
OpenMesh::IO::IOManager
_IOManager_ & IOManager()
Definition: IOManager.cc:77