Commit ac0aa0a1 authored by Dirk Wilden's avatar Dirk Wilden

loadWidget no longer used as static object

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4100 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 70066832
......@@ -262,15 +262,15 @@ void Core::loadObject() {
if ( OpenFlipper::Options::gui() ){
if (supportedTypes_.size() != 0){
static LoadWidget* widget = 0;
LoadWidget* widget = new LoadWidget(supportedTypes_);
connect(widget,SIGNAL(load(QString, DataType, int&)),this,SLOT(slotLoad(QString, DataType, int&)));
connect(widget,SIGNAL(save(int, QString)),this,SLOT(saveObject(int, QString)));
// Open Widget
if ( !widget ){
widget = new LoadWidget(supportedTypes_);
connect(widget,SIGNAL(load(QString, DataType, int&)),this,SLOT(slotLoad(QString, DataType, int&)));
connect(widget,SIGNAL(save(int, QString)),this,SLOT(saveObject(int, QString)));
}
widget->showLoad();
widget->disconnect();
delete widget;
}else
emit log(LOGERR,"Could not show 'load objects' dialog. Missing file-plugins.");
......
......@@ -92,6 +92,8 @@ bool Core::saveObject( int _id, QString _filename ) {
/// Show the save-widget to determine a filename, the widget calls slotSave to save the object
bool Core::saveObjectTo( int _id, QString _filename ) {
bool result = false;
if ( OpenFlipper::Options::gui() ){
BaseObjectData* object;
......@@ -104,16 +106,15 @@ bool Core::saveObjectTo( int _id, QString _filename ) {
connect(widget,SIGNAL(save(int, QString)),this,SLOT(saveObject(int, QString)));
if (supportedTypes_.size() != 0)
return widget->showSave(_id,_filename);
else{
result = widget->showSave(_id,_filename);
else
emit log(LOGERR,"Could not show 'save objects' dialog. Missing file-plugins.");
return false;
}
widget->disconnect();
delete widget;
}
}else
return false;
return result;
}
//-----------------------------------------------------------------------------------------------------
......
......@@ -96,6 +96,17 @@ LoadWidget::LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent
setDirectory(OpenFlipper::Options::currentDirStr());
}
/// Desctructor
LoadWidget::~LoadWidget()
{
// remove the optionWidgets so they don't get destroyed
// (the fileplugins control the optionWidgets)
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
}
}
/// adjust the loadWidget / saveWidget when the selected nameFilter changed
void LoadWidget::currentFilterChanged(QString _currentFilter){
......@@ -355,15 +366,6 @@ int LoadWidget::showSave(int _id, QString _filename){
}
}
//workarround to force repaint
if (x() > 0){
if (step_)
setGeometry(x(),y(),width()+1,height());
else
setGeometry(x(),y(),width()-1,height());
}
step_ = !step_;
return this->exec();
}
......
......@@ -43,6 +43,8 @@ class LoadWidget : public QFileDialog
Q_OBJECT
public:
LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent = 0 );
~LoadWidget();
signals:
void load(QString _filename, DataType _type, int& _id);
void save(int _id, QString _filename);
......
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