Commit c8db30d1 authored by Jan Möbius's avatar Jan Möbius

External file for FileFilterCollection, About Dialog extension to show registered file plugins

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11209 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1f6f1730
......@@ -111,17 +111,10 @@
#include <OpenFlipper/threads/JobInfo.hh>
#include <OpenFlipper/common/FileTypes.hh>
//== CLASS DEFINITION =========================================================
struct fileTypes {
QString name;
DataType type;
QString loadFilters;
QString saveFilters;
FileInterface* plugin;
QObject* object;
bool saveMultipleObjects;
};
struct dataTypes {
QString name;
......@@ -1375,9 +1368,6 @@ private slots:
/// Logger interfaces between plugins and core logger
std::vector<PluginLogger*> loggers_;
/// File-Plugins
std::vector<fileTypes> supportedTypes_;
/// Type-Plugins
std::vector<dataTypes> supportedDataTypes_;
......
......@@ -1803,7 +1803,7 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
ft.object = plugin;
ft.saveMultipleObjects = checkSlot(plugin,"saveObjects(IdList,QString)");
supportedTypes_.push_back(ft);
supportedTypes().push_back(ft);
if ( checkSignal(plugin,"openedFile(int)" ) )
......
......@@ -58,7 +58,7 @@
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <time.h>
#include <OpenFlipper/common/DataTypes.hh>
void Core::resetScenegraph( bool _resetTrackBall ) {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) {
......@@ -87,10 +87,10 @@ void Core::slotGetAllFilters ( QStringList& _list){
/// \todo check why the supported Type is used here!
// Iterate over all types
for (int i=0; i < (int)supportedTypes_.size(); i++){
QString f = supportedTypes_[i].plugin->getLoadFilters();
for (int i=0; i < (int)supportedTypes().size(); i++){
QString f = supportedTypes()[i].plugin->getLoadFilters();
f = f.section(")",0,0).section("(",1,1).trimmed();
_list << (QString::number(supportedTypes_[i].plugin->supportedType().value()) + " " + f);
_list << (QString::number(supportedTypes()[i].plugin->supportedType().value()) + " " + f);
}
}
......@@ -203,9 +203,9 @@ int Core::loadObject ( QString _filename ) {
QFileInfo fi(_filename);
for (int i=0; i < (int)supportedTypes_.size(); i++){
for (int i=0; i < (int)supportedTypes().size(); i++){
QString filters = supportedTypes_[i].plugin->getLoadFilters();
QString filters = supportedTypes()[i].plugin->getLoadFilters();
//check extension
if ( ! filters.contains( "*." + fi.completeSuffix() , Qt::CaseInsensitive) ) {
if ( ! filters.contains( "*." + fi.suffix() , Qt::CaseInsensitive) ) {
......@@ -222,7 +222,7 @@ int Core::loadObject ( QString _filename ) {
}
//load file
int id = supportedTypes_[i].plugin->loadObject(_filename);
int id = supportedTypes()[i].plugin->loadObject(_filename);
if ( OpenFlipper::Options::gui() ) {
if ( id != -1 ) {
......@@ -263,10 +263,10 @@ int Core::loadObject( DataType _type, QString _filename) {
QFileInfo fi(_filename);
for (int i=0; i < (int)supportedTypes_.size(); i++)
if (supportedTypes_[i].type & _type || supportedTypes_[i].type == _type) {
for (int i=0; i < (int)supportedTypes().size(); i++)
if (supportedTypes()[i].type & _type || supportedTypes()[i].type == _type) {
QString filters = supportedTypes_[i].plugin->getLoadFilters();
QString filters = supportedTypes()[i].plugin->getLoadFilters();
//check extension
if ( ! filters.contains( "*." + fi.suffix() ,Qt::CaseInsensitive ) )
continue;
......@@ -281,10 +281,10 @@ int Core::loadObject( DataType _type, QString _filename) {
int id = -1;
//load file
if ( checkSlot( supportedTypes_[i].object , "loadObject(QString,DataType)" ) )
id = supportedTypes_[i].plugin->loadObject(_filename, _type);
if ( checkSlot( supportedTypes()[i].object , "loadObject(QString,DataType)" ) )
id = supportedTypes()[i].plugin->loadObject(_filename, _type);
else
id = supportedTypes_[i].plugin->loadObject(_filename);
id = supportedTypes()[i].plugin->loadObject(_filename);
if ( OpenFlipper::Options::gui() ) {
if ( id != -1 ) {
......@@ -328,10 +328,10 @@ int Core::addEmptyObject( DataType _type ) {
if(retCode != -1) return retCode;
// File plugins
for (int i=0; i < (int)supportedTypes_.size(); i++)
if ( supportedTypes_[i].type & _type ) {
for (int i=0; i < (int)supportedTypes().size(); i++)
if ( supportedTypes()[i].type & _type ) {
emit log(LOGERR, tr("File Plugins are not allowed to create empty objects anymore! Use the addEmpty call instead!") );
retCode = supportedTypes_[i].plugin->addEmpty();
retCode = supportedTypes()[i].plugin->addEmpty();
}
return retCode; // -1 if no plugin found
......@@ -408,7 +408,7 @@ void Core::slotLoad(QString _filename, int _pluginID) {
}
//load file
int id = supportedTypes_[_pluginID].plugin->loadObject(_filename);
int id = supportedTypes()[_pluginID].plugin->loadObject(_filename);
if ( OpenFlipper::Options::gui() ) {
if ( id != -1 )
......@@ -619,10 +619,10 @@ void Core::slotAddEmptyObjectMenu() {
}
// filePlugin
for ( uint j = 0 ; j < supportedTypes_.size(); j++) {
for ( uint j = 0 ; j < supportedTypes().size(); j++) {
// Check if a plugin supports the current Type
if ( supportedTypes_[j].type & currentType ) {
if ( supportedTypes()[j].type & currentType ) {
// Avoid duplicates
bool duplicate = false;
......@@ -649,7 +649,7 @@ void Core::slotAddEmptyObjectMenu() {
static addEmptyWidget* widget = 0;
if (supportedTypes_.size() != 0) {
if (supportedTypes().size() != 0) {
if ( !widget ){
widget = new addEmptyWidget(types,typeNames);
......@@ -673,8 +673,8 @@ void Core::loadObject() {
if ( OpenFlipper::Options::gui() ){
if (supportedTypes_.size() != 0){
LoadWidget* widget = new LoadWidget(supportedTypes_);
if (supportedTypes().size() != 0){
LoadWidget* widget = new LoadWidget(supportedTypes());
connect(widget,SIGNAL(load(QString, int)),this,SLOT(slotLoad(QString, int)));
connect(widget,SIGNAL(save(int, QString, int)),this,SLOT(saveObject(int, QString, int)));
......
......@@ -49,6 +49,8 @@
#include "OpenFlipper/widgets/loadWidget/loadWidget.hh"
#include <OpenFlipper/common/DataTypes.hh>
//========================================================================================
// === Public Slots (called by CoreWidget's File-Menu / Scripting / Plugins) =========
//========================================================================================
......@@ -62,9 +64,9 @@ bool Core::saveObject( int _id, QString _filename ) {
QString file_extension = QFileInfo(_filename).suffix();
for (int i=0; i < (int)supportedTypes_.size(); i++) {
if ( supportedTypes_[i].type.contains(object->dataType()) &&
( supportedTypes_[i].saveFilters.contains(file_extension) || file_extension.isEmpty() ) ) {
for (int i=0; i < (int)supportedTypes().size(); i++) {
if ( supportedTypes()[i].type.contains(object->dataType()) &&
( supportedTypes()[i].saveFilters.contains(file_extension) || file_extension.isEmpty() ) ) {
if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Saving ") + _filename + " ...");
......@@ -74,14 +76,14 @@ bool Core::saveObject( int _id, QString _filename ) {
//save object
bool ok = supportedTypes_[i].plugin->saveObject(_id,_filename);
bool ok = supportedTypes()[i].plugin->saveObject(_id,_filename);
if ( OpenFlipper::Options::gui() ) {
if (ok)
coreWidget_->statusMessage( tr("Saving ") + _filename + tr(" ... done"), 4000 );
else{
emit log(LOGERR, tr("Unable to save '%1'. Plugin failed. DataType %2").arg(_filename, dataTypeName(object->dataType()) ) );
emit log(LOGERR, tr("Plugin was: '%1'. File Extension was: %2").arg(supportedTypes_[i].name, file_extension ) );
emit log(LOGERR, tr("Plugin was: '%1'. File Extension was: %2").arg(supportedTypes()[i].name, file_extension ) );
coreWidget_->statusMessage( tr("Saving ") + _filename + tr(" ... failed!"), 4000 );
}
......@@ -124,7 +126,7 @@ void Core::saveObject( int _id, QString _filename, int _pluginID ) {
}
//save object
bool ok = supportedTypes_[_pluginID].plugin->saveObject(_id,_filename);
bool ok = supportedTypes()[_pluginID].plugin->saveObject(_id,_filename);
if ( OpenFlipper::Options::gui() ) {
if (ok)
......@@ -167,12 +169,12 @@ void Core::saveObjects( IdList _ids, QString _filename, int _pluginID ) {
}
//save objects
if ( !supportedTypes_[_pluginID].saveMultipleObjects){
if ( !supportedTypes()[_pluginID].saveMultipleObjects){
emit log(LOGERR, tr("Unable to save objects. Plugin does not allow multiple objects."));
return;
}
bool ok = supportedTypes_[_pluginID].plugin->saveObjects(_ids,_filename);
bool ok = supportedTypes()[_pluginID].plugin->saveObjects(_ids,_filename);
if ( OpenFlipper::Options::gui() ) {
if (ok)
......@@ -201,12 +203,12 @@ bool Core::saveObjectTo( int _id, QString _filename ) {
if ( OpenFlipper::Options::gui() ){
//init widget
LoadWidget* widget = new LoadWidget(supportedTypes_);
LoadWidget* widget = new LoadWidget(supportedTypes());
widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(widget,SIGNAL(save(int, QString, int)),this,SLOT(saveObject(int, QString, int)));
if (supportedTypes_.size() != 0)
if (supportedTypes().size() != 0)
result = widget->showSave(_id,_filename);
else
emit log(LOGERR,tr("Could not show 'save objects' dialog. Missing file-plugins."));
......@@ -229,12 +231,12 @@ bool Core::saveObjectsTo( IdList _ids, QString _filename ) {
if ( OpenFlipper::Options::gui() ){
//init widget
LoadWidget* widget = new LoadWidget(supportedTypes_);
LoadWidget* widget = new LoadWidget(supportedTypes());
widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(widget,SIGNAL(save(IdList, QString, int)),this,SLOT(saveObjects(IdList, QString, int)));
if (supportedTypes_.size() != 0)
if (supportedTypes().size() != 0)
result = widget->showSave(_ids,_filename);
else
emit log(LOGERR,tr("Could not show 'save objects' dialog. Missing file-plugins."));
......@@ -254,8 +256,8 @@ void Core::saveAllObjects(){
if ( OpenFlipper::Options::gui() ){
//ensure that all options are on their default values
for (int i=0; i < (int)supportedTypes_.size(); i++)
supportedTypes_[i].plugin->saveOptionsWidget("");
for (int i=0; i < (int)supportedTypes().size(); i++)
supportedTypes()[i].plugin->saveOptionsWidget("");
//iterate over all target objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ;
......@@ -280,8 +282,8 @@ void Core::saveAllObjectsTo(){
if ( OpenFlipper::Options::gui() ){
//ensure that all options are on their default values
for (int i=0; i < (int)supportedTypes_.size(); i++)
supportedTypes_[i].plugin->saveOptionsWidget("");
for (int i=0; i < (int)supportedTypes().size(); i++)
supportedTypes()[i].plugin->saveOptionsWidget("");
//get all dataTypes that want to be saved
DataType types = DATA_UNKNOWN;
......@@ -296,8 +298,8 @@ void Core::saveAllObjectsTo(){
//check if a plugin can save all types to one file
bool multiSave = false;
for (int i=0; i < (int)supportedTypes_.size(); i++)
if ( (supportedTypes_[i].saveMultipleObjects) && (supportedTypes_[i].type.contains(types)) )
for (int i=0; i < (int)supportedTypes().size(); i++)
if ( (supportedTypes()[i].saveMultipleObjects) && (supportedTypes()[i].type.contains(types)) )
multiSave = true;
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Types
//
//=============================================================================
/**
* \file FileTypes.cc
* This File contains the management of file plugins.
*/
//== INCLUDES =================================================================
#include <OpenFlipper/common/FileTypes.hh>
#include <vector>
static std::vector<fileTypes> supportedTypes_;
std::vector<fileTypes>& supportedTypes() {
return supportedTypes_;
}
//=============================================================================
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Types
//
//=============================================================================
/**
* \file FileTypes.hh
* This File contains the management of file plugins.
*/
#ifndef FILETYPES_HH
#define FILETYPES_HH
#include <QString>
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/common/DataTypes.hh>
#include <OpenFlipper/BasePlugin/FileInterface.hh>
//== INCLUDES =================================================================
struct fileTypes {
QString name;
DataType type;
QString loadFilters;
QString saveFilters;
FileInterface* plugin;
QObject* object;
bool saveMultipleObjects;
};
// Get vector of supported types
DLLEXPORT
std::vector<fileTypes>&
supportedTypes();
//=============================================================================
#endif // FILETYPES_HH defined
//=============================================================================
......@@ -53,6 +53,7 @@
//== INCLUDES =================================================================
#include "CoreWidget.hh"
#include <OpenFlipper/common/FileTypes.hh>
#include <QGLFormat>
......@@ -484,12 +485,10 @@ void CoreWidget::showAboutWidget( ) {
aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
aboutWidget_->OpenFlipperAbout->append(tr("Currently used Version:\t") + qVersion() );
aboutWidget_->OpenFlipperAbout->append(tr("Link time Version:\t\t") + QT_VERSION_STR );
aboutWidget_->OpenFlipperAbout->append("\n");
aboutWidget_->OpenFlipperAbout->append(tr("Currently used Library paths:\n") );
aboutWidget_->OpenFlipperAbout->append(tr("Currently used Library paths:\n") );
QStringList libPaths = QCoreApplication::libraryPaths();
for(int i = 0 ; i < libPaths.size() ; ++i)
aboutWidget_->OpenFlipperAbout->append(libPaths[i]);
aboutWidget_->OpenFlipperAbout->append("\t" + libPaths[i]);
// =====================================================================================
// Compiler information
......@@ -523,6 +522,23 @@ void CoreWidget::showAboutWidget( ) {
aboutWidget_->OpenFlipperAbout->append( types );
// =====================================================================================
// List The File Plugins with their filters
// =====================================================================================
aboutWidget_->OpenFlipperAbout->append("\n");
aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
aboutWidget_->OpenFlipperAbout->append(tr("Registered File Plugins:"));
aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
for ( uint i = 0 ; i < supportedTypes().size() ; ++i ) {
aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
aboutWidget_->OpenFlipperAbout->append( "\t" + supportedTypes()[i].name );
aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont);
aboutWidget_->OpenFlipperAbout->append( "\t\t Load: " + supportedTypes()[i].loadFilters );
aboutWidget_->OpenFlipperAbout->append( "\t\t Save: " + supportedTypes()[i].saveFilters );
}
aboutWidget_->show();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment