53 #include "OpenFlipper/widgets/loadWidget/loadWidget.hh" 74 emit
log(
LOGERR, tr(
"saveObject : cannot get object %1").arg(_id) );
78 QString file_extension = QFileInfo(_filename).suffix();
80 for (
int i=0; i < (int)supportedTypes().size(); i++) {
81 if ( supportedTypes()[i].type.contains(object->
dataType()) &&
82 ( supportedTypes()[i].saveFilters.contains(file_extension) || file_extension.isEmpty() ) ) {
84 if ( OpenFlipper::Options::gui() ) {
85 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
86 if ( !OpenFlipper::Options::savingSettings() )
92 bool ok = supportedTypes()[i].plugin->saveObject(_id,_filename);
94 if ( OpenFlipper::Options::gui() ) {
96 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
99 emit
log(
LOGERR, tr(
"Plugin was: '%1'. File Extension was: %2").arg(supportedTypes()[i].name, file_extension ) );
100 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
103 if ( !OpenFlipper::Options::savingSettings() )
108 if (ok && !OpenFlipper::Options::savingSettings()
109 && OpenFlipper::Options::gui() )
117 if ( OpenFlipper::Options::gui() ){
119 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
133 emit
log(
LOGERR, tr(
"saveObject : cannot get object %1").arg(_id) );
137 if ( OpenFlipper::Options::gui() ) {
138 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
139 if ( !OpenFlipper::Options::savingSettings() )
143 time_t start = clock();
145 bool ok = supportedTypes()[_pluginID].plugin->saveObject(_id,_filename);
146 time_t end = clock();
147 emit
log(
LOGINFO,tr(
"Saving %1 with Plugin %2 took %3 seconds.").arg(_filename).arg(supportedTypes()[_pluginID].name).arg((
double)(end-start)/CLOCKS_PER_SEC) );
149 if ( OpenFlipper::Options::gui() ) {
151 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
153 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
155 if ( !OpenFlipper::Options::savingSettings() )
160 if (ok && !OpenFlipper::Options::savingSettings()
161 && OpenFlipper::Options::gui() )
175 for (uint i=0; i < _ids.size(); i++){
180 type |=
object->dataType();
183 if ( OpenFlipper::Options::gui() ) {
184 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
185 if ( !OpenFlipper::Options::savingSettings() )
190 if ( !supportedTypes()[_pluginID].saveMultipleObjects){
191 emit
log(
LOGERR, tr(
"Unable to save objects. Plugin does not allow multiple objects."));
195 bool ok = supportedTypes()[_pluginID].plugin->saveObjects(_ids,_filename);
197 if ( OpenFlipper::Options::gui() ) {
199 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
201 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
203 if ( !OpenFlipper::Options::savingSettings() )
208 if (ok && !OpenFlipper::Options::savingSettings()
209 && OpenFlipper::Options::gui() )
221 if ( OpenFlipper::Options::gui() ){
225 widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
227 connect(widget,SIGNAL(save(
int, QString,
int)),
this,SLOT(
saveObject(
int, QString,
int)));
229 if (supportedTypes().size() != 0)
230 result = widget->
showSave(_id,_filename);
232 emit
log(
LOGERR,tr(
"Could not show 'save objects' dialog. Missing file-plugins."));
234 widget->disconnect();
249 if ( OpenFlipper::Options::gui() ){
253 widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
257 if (supportedTypes().size() != 0)
258 result = widget->
showSave(_ids,_filename);
260 emit
log(
LOGERR,tr(
"Could not show 'save objects' dialog. Missing file-plugins."));
262 widget->disconnect();
274 if ( OpenFlipper::Options::gui() ){
277 for (
int i=0; i < (int)supportedTypes().size(); i++)
278 supportedTypes()[i].plugin->saveOptionsWidget(
"");
284 if ( !QDir(o_it->path()).exists() || o_it->path().trimmed() ==
"" || o_it->path().trimmed() ==
"." )
288 QString filename = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name() ;
300 if ( OpenFlipper::Options::gui() ){
303 for (
int i=0; i < (int)supportedTypes().size(); i++)
304 supportedTypes()[i].plugin->saveOptionsWidget(
"");
312 types |= o_it->dataType();
313 ids.push_back( o_it->id() );
317 bool multiSave =
false;
319 for (
int i=0; i < (int)supportedTypes().size(); i++)
320 if ( (supportedTypes()[i].saveMultipleObjects) && (supportedTypes()[i].type.contains(types)) )
324 if (ids.size() > 1 && multiSave){
void addRecent(QString _filename, DataType _type)
Add a recent file and update menu.
CoreWidget * coreWidget_
The main applications widget ( only created in gui mode )
void saveObjects(IdList _ids, QString _filename, int _pluginID)
int showSave(int _id, QString _filename)
show Widget for saving Files
bool getObject(int _identifier, BSplineCurveObject *&_object)
bool dataType(DataType _type) const
bool saveObject(int _id, QString _filename)
Save an object.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
Status is ready (green light)
bool saveObjectTo(int _id, QString _filename)
const DataType DATA_UNKNOWN(0)
None of the other Objects.
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
void saveAllObjectsTo()
Slot for saving objects to a new location.
bool saveObjectsTo(IdList _ids, QString _filename)
Status is processing but system will allow interaction (yellow light)
std::vector< int > IdList
Standard Type for id Lists used for scripting.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
void saveAllObjects()
Slot for saving objects from Menu.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.