Commit f6867722 authored by Matthias Möller's avatar Matthias Möller

add async loading of files

refs #2421

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@21052 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3b0a5313
......@@ -493,7 +493,7 @@ signals:
void slotLoad(QString _filename, DataType _type, int& _id);
/// the load widget wants to load a given file
void slotLoad(QString _filename, int _pluginID);
void slotLoad(QStringList _filenames, IdList _pluginIDs);
/// Called when a file has been opened
void slotFileOpened ( int _id );
......@@ -804,6 +804,8 @@ public slots:
int loadObject ( QString _filename );
private slots:
void loadObjectFinished(QString _filename);
/** Do a reset of the scenegraph (bounding box update,...)
*
* @param _resetTrackBall Should the rotation center of the trackball be reset to the scene center?
......
#include "OpenFunctionThread.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
/////////////////////////////////////////////////
void LoadFromPluginThread::loadFromPlugin()
{
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
PluginFunctions::viewerProperties(i).lockUpdate();
for (int i = 0; i < infos_.size(); ++i)
{
LoadInfos info = infos_[i];
if (info.type != DATA_UNKNOWN)
loadedIds_[i] = info.plugin->loadObject(info.filename,info.type );
else
loadedIds_[i] = info.plugin->loadObject(info.filename);
emit state(this->jobId(),i);
}
for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i )
PluginFunctions::viewerProperties(i).unLockUpdate();
emit updateView();
}
/////////////////////////////////////////////////
LoadFromPluginThread::~LoadFromPluginThread()
{
}
/////////////////////////////////////////////////
LoadFromPluginThread::LoadFromPluginThread(QVector<LoadInfos> _loadInfos, const QString& _jobName)
: OpenFlipperThread(_jobName), infos_(_loadInfos), loadedIds_(_loadInfos.size(),-1)
{
connect( this ,SIGNAL(function()), this, SLOT(loadFromPlugin()), Qt::DirectConnection) ;
}
/////////////////////////////////////////////////
int LoadFromPluginThread::getObjId(int index)const
{
return loadedIds_[index];
}
/////////////////////////////////////////////////
const QString& LoadFromPluginThread::getFilename(int index) const
{
return infos_[index].filename;
}
#ifndef __OPENFUNCTIONSLOADFROMPLUGINTHREAD_HH__
#define __OPENFUNCTIONSLOADFROMPLUGINTHREAD_HH__
#include <OpenFlipper/threads/OpenFlipperThread.hh>
#include <OpenFlipper/common/DataTypes.hh>
#include <OpenFlipper/BasePlugin/FileInterface.hh>
#include <QString>
class LoadFromPluginThread : public OpenFlipperThread
{
Q_OBJECT
public:
struct LoadInfos
{
FileInterface* plugin;
DataType type;
QString filename;
LoadInfos():plugin(0),type(DATA_UNKNOWN),filename(){}//c'tor for QVector
LoadInfos(FileInterface* _plugin, const QString& _filename):plugin(_plugin),type(DATA_UNKNOWN),filename(_filename){}
LoadInfos(FileInterface* _plugin, DataType _type, const QString& _filename):plugin(_plugin),type(_type),filename(_filename){}
};
signals:
void updateView();
private:
const QVector<LoadInfos>& infos_;
QVector<int> loadedIds_;
public slots:
void loadFromPlugin();
public:
~LoadFromPluginThread();
LoadFromPluginThread(QVector<LoadInfos> _loadInfos, const QString& _jobName);
int getObjId(int index)const;
const QString& getFilename(int index) const;
};
#endif //__OPENFUNCTIONSLOADFROMPLUGINTHREAD_HH__
This diff is collapsed.
......@@ -255,6 +255,8 @@ void LoadWidget::loadFile(){
//load the selected files
QStringList loadableFiles;
IdList pluginIds;
for (int i=0; i < files.size(); i++){
QFileInfo fi(files[i]);
......@@ -286,8 +288,11 @@ void LoadWidget::loadFile(){
//emit load signal
if ( pluginForExtension_.find( ext ) != pluginForExtension_.end() ){
emit load(filename, pluginForExtension_[ ext ]);
loadableFiles.push_back(filename);
pluginIds.push_back(pluginForExtension_[ext]);
}
}
emit loadFiles(loadableFiles, pluginIds);
}
/// find suitable plugin for saving current file
......
......@@ -69,6 +69,7 @@ class LoadWidget : public QFileDialog
signals:
void load(QString _filename, int _pluginID);
void loadFiles(QStringList _filenames, IdList _pluginIds);
void save(int _id, QString _filename, int _pluginID);
void save(IdList _ids, QString _filename, int _pluginID);
......
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