Commit 4b98d19d authored by Dirk Wilden's avatar Dirk Wilden

extended FileInterface

it is now possible to provide a special loadWidget/saveWidget for every nameFilter

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2776 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1f9da75a
......@@ -82,11 +82,6 @@ class FileInterface {
virtual QString getSaveFilters() = 0;
/** You can provide a special widget showing options for saving your file types
* Return 0 when you dont need one
*/
virtual QWidget* saveOptionsWidget() = 0;
/** You can also provide a special widget showing options for saving your file types
* depending on the current filter
*
* _currentFilter: one filter from saveFilters
......@@ -96,11 +91,6 @@ class FileInterface {
virtual QWidget* saveOptionsWidget(QString _currentFilter) = 0;
/** You can provide a special widget showing options for loading your file types
* Return 0 when you dont need one
*/
virtual QWidget* loadOptionsWidget() = 0;
/** You can also provide a special widget showing options for loading your file types
* depending on the current filter
*
* _currentFilter: one filter from loadFilters
......
......@@ -96,8 +96,6 @@ struct fileTypes {
QString loadFilters;
QString saveFilters;
FileInterface* plugin;
QWidget* loadWidget;
QWidget* saveWidget;
};
/** Core Widget of the Application
......
......@@ -429,14 +429,6 @@ void Core::loadPlugin(QString filename, bool silent){
ft.saveFilters = filePlugin->getSaveFilters();
ft.plugin = filePlugin;
if ( OpenFlipper::Options::gui() ) {
ft.loadWidget = filePlugin->loadOptionsWidget();
ft.saveWidget = filePlugin->saveOptionsWidget();
} else {
ft.loadWidget = 0;
ft.saveWidget = 0;
}
supportedTypes_.push_back(ft);
filePlugin->setObjectRoot( objectRoot_ );
}
......
......@@ -49,7 +49,6 @@ LoadWidget::LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent
: QFileDialog(parent),
loadMode_(true),
supportedTypes_(_supportedTypes)
{
// Get our layout
......@@ -100,17 +99,13 @@ LoadWidget::LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent
/// adjust the loadWidget / saveWidget when the selected nameFilter changed
void LoadWidget::currentFilterChanged(QString _currentFilter){
for (int i=0; i < (int)supportedTypes_.size(); i++){
if (supportedTypes_[i].loadWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].loadWidget);
supportedTypes_[i].loadWidget->setParent(0);
}
if (supportedTypes_[i].saveWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
supportedTypes_[i].saveWidget->setParent(0);
}
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
const DataType type = (DataType) typeBox_->itemData( typeBox_->currentIndex() ).toInt();
if ( loadMode_ ){
......@@ -122,10 +117,7 @@ void LoadWidget::currentFilterChanged(QString _currentFilter){
if (nuWidget != 0){
boxLayout_->addWidget( nuWidget );
box_->show();
}else
if ( supportedTypes_[i].loadWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].loadWidget);
boxWidgets_.push_back( nuWidget );
box_->show();
}
}
......@@ -138,10 +130,7 @@ void LoadWidget::currentFilterChanged(QString _currentFilter){
if (nuWidget != 0){
boxLayout_->addWidget( nuWidget );
box_->show();
}else
if ( supportedTypes_[i].saveWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].saveWidget);
boxWidgets_.push_back( nuWidget );
box_->show();
}
}
......@@ -152,17 +141,12 @@ void LoadWidget::currentFilterChanged(QString _currentFilter){
void LoadWidget::slotSetLoadFilters(int _typeIndex){
box_->setTitle("Load Options");
for (int i=0; i < (int)supportedTypes_.size(); i++){
if (supportedTypes_[i].loadWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].loadWidget);
supportedTypes_[i].loadWidget->setParent(0);
}
if (supportedTypes_[i].saveWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
supportedTypes_[i].saveWidget->setParent(0);
}
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
const DataType type = (DataType) typeBox_->itemData(_typeIndex).toInt();
for (int i=0; i < (int)supportedTypes_.size(); i++)
......@@ -173,12 +157,14 @@ void LoadWidget::slotSetLoadFilters(int _typeIndex){
setNameFilters(filters);
//add Widget for new Filter
if ( supportedTypes_[i].loadWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].loadWidget);
// boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
QWidget* nuWidget = 0;
nuWidget = supportedTypes_[i].plugin->loadOptionsWidget("");
if ( nuWidget != 0 ) {
boxLayout_->addWidget( nuWidget );
boxWidgets_.push_back( nuWidget );
box_->show();
}
}
if (box_->children().count() == 1) //only the layout is left
......@@ -189,17 +175,13 @@ void LoadWidget::slotSetLoadFilters(int _typeIndex){
void LoadWidget::slotSetSaveFilters(int _typeIndex){
box_->setTitle("Save Options");
for (int i=0; i < (int)supportedTypes_.size(); i++){
if (supportedTypes_[i].loadWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].loadWidget);
supportedTypes_[i].loadWidget->setParent(0);
}
if (supportedTypes_[i].saveWidget != 0){
boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
supportedTypes_[i].saveWidget->setParent(0);
}
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
const DataType type = (DataType) typeBox_->itemData(_typeIndex).toInt();
for (int i=0; i < (int)supportedTypes_.size(); i++)
if (supportedTypes_[i].type == type){
......@@ -209,19 +191,15 @@ void LoadWidget::slotSetSaveFilters(int _typeIndex){
setNameFilters(filters);
//add Widget for new Filter
if ( supportedTypes_[i].saveWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].saveWidget);
// boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
QWidget* nuWidget = 0;
nuWidget = supportedTypes_[i].plugin->saveOptionsWidget("");
if ( nuWidget != 0 ) {
boxLayout_->addWidget( nuWidget );
boxWidgets_.push_back( nuWidget );
box_->show();
}
}
//remove Widget from last Filter
// if ( supportedTypes_[i].loadWidget != 0 ) {
// boxLayout_->removeWidget(supportedTypes_[i].loadWidget);
// boxLayout_->removeWidget(supportedTypes_[i].saveWidget);
// supportedTypes_[i].saveWidget->setParent(0);
// }
if (box_->children().count() == 1) //only the layout is left
box_->hide();
......
......@@ -77,6 +77,7 @@ class LoadWidget : public QFileDialog
/// QFrame on the right
QGroupBox* box_;
QHBoxLayout* boxLayout_;
QVector< QWidget* > boxWidgets_;
bool step_;
......
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