47 #include "OpenFlipper/widgets/loadWidget/loadWidget.hh" 68 emit
log(
LOGERR, tr(
"saveObject : cannot get object %1").arg(_id) );
72 QString file_extension = QFileInfo(_filename).suffix();
74 for (
int i=0; i < (int)supportedTypes().size(); i++) {
75 if ( supportedTypes()[i].type.contains(object->
dataType()) &&
76 ( supportedTypes()[i].saveFilters.contains(file_extension) || file_extension.isEmpty() ) ) {
78 if ( OpenFlipper::Options::gui() ) {
79 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
80 if ( !OpenFlipper::Options::savingSettings() )
86 bool ok = supportedTypes()[i].plugin->saveObject(_id,_filename);
88 if ( OpenFlipper::Options::gui() ) {
90 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
93 emit
log(
LOGERR, tr(
"Plugin was: '%1'. File Extension was: %2").arg(supportedTypes()[i].name, file_extension ) );
94 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
97 if ( !OpenFlipper::Options::savingSettings() )
102 if (ok && !OpenFlipper::Options::savingSettings()
103 && OpenFlipper::Options::gui() )
111 if ( OpenFlipper::Options::gui() ){
113 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
127 emit
log(
LOGERR, tr(
"saveObject : cannot get object %1").arg(_id) );
131 if ( OpenFlipper::Options::gui() ) {
132 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
133 if ( !OpenFlipper::Options::savingSettings() )
137 time_t start = clock();
139 bool ok = supportedTypes()[_pluginID].plugin->saveObject(_id,_filename);
140 time_t end = clock();
141 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) );
143 if ( OpenFlipper::Options::gui() ) {
145 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
147 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
149 if ( !OpenFlipper::Options::savingSettings() )
154 if (ok && !OpenFlipper::Options::savingSettings()
155 && OpenFlipper::Options::gui() )
169 for (uint i=0; i < _ids.size(); i++){
174 type |=
object->dataType();
177 if ( OpenFlipper::Options::gui() ) {
178 coreWidget_->statusMessage( tr(
"Saving ") + _filename +
" ...");
179 if ( !OpenFlipper::Options::savingSettings() )
184 if ( !supportedTypes()[_pluginID].saveMultipleObjects){
185 emit
log(
LOGERR, tr(
"Unable to save objects. Plugin does not allow multiple objects."));
189 bool ok = supportedTypes()[_pluginID].plugin->saveObjects(_ids,_filename);
191 if ( OpenFlipper::Options::gui() ) {
193 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... done"), 4000 );
195 coreWidget_->statusMessage( tr(
"Saving ") + _filename + tr(
" ... failed!"), 4000 );
197 if ( !OpenFlipper::Options::savingSettings() )
202 if (ok && !OpenFlipper::Options::savingSettings()
203 && OpenFlipper::Options::gui() )
215 if ( OpenFlipper::Options::gui() ){
219 widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
221 connect(widget,SIGNAL(save(
int, QString,
int)),
this,SLOT(
saveObject(
int, QString,
int)));
223 if (supportedTypes().size() != 0)
224 result = widget->
showSave(_id,_filename);
226 emit
log(
LOGERR,tr(
"Could not show 'save objects' dialog. Missing file-plugins."));
228 widget->disconnect();
243 if ( OpenFlipper::Options::gui() ){
247 widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
251 if (supportedTypes().size() != 0)
252 result = widget->
showSave(_ids,_filename);
254 emit
log(
LOGERR,tr(
"Could not show 'save objects' dialog. Missing file-plugins."));
256 widget->disconnect();
268 if ( OpenFlipper::Options::gui() ){
271 for (
int i=0; i < (int)supportedTypes().size(); i++)
272 supportedTypes()[i].plugin->saveOptionsWidget(
"");
278 if ( !QDir(o_it->path()).exists() || o_it->path().trimmed() ==
"" || o_it->path().trimmed() ==
"." )
282 QString filename = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name() ;
294 if ( OpenFlipper::Options::gui() ){
297 for (
int i=0; i < (int)supportedTypes().size(); i++)
298 supportedTypes()[i].plugin->saveOptionsWidget(
"");
306 types |= o_it->dataType();
307 ids.push_back( o_it->id() );
311 bool multiSave =
false;
313 for (
int i=0; i < (int)supportedTypes().size(); i++)
314 if ( (supportedTypes()[i].saveMultipleObjects) && (supportedTypes()[i].type.contains(types)) )
318 if (ids.size() > 1 && multiSave){
void saveAllObjectsTo()
Slot for saving objects to a new location.
Status is ready (green light)
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
bool saveObjectsTo(IdList _ids, QString _filename)
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
bool dataType(DataType _type) const
std::vector< int > IdList
Standard Type for id Lists used for scripting.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
CoreWidget * coreWidget_
The main applications widget ( only created in gui mode )
bool saveObjectTo(int _id, QString _filename)
void saveObjects(IdList _ids, QString _filename, int _pluginID)
QString name() const
return the name of the object. The name defaults to NONAME if unset.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void saveAllObjects()
Slot for saving objects from Menu.
Status is processing but system will allow interaction (yellow light)
bool saveObject(int _id, QString _filename)
Save an object.
const DataType DATA_UNKNOWN(0)
None of the other Objects.