Commit 1f9da75a 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@2772 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 18212dca
......@@ -85,11 +85,29 @@ class FileInterface {
* 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
*
* Return 0 when you dont need one, OpenFlipper then uses saveOptionsWidget() if available
*/
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
*
* Return 0 when you dont need one, OpenFlipper then uses loadOptionsWidget() if available
*/
virtual QWidget* loadOptionsWidget(QString _currentFilter) = 0;
public slots:
......
......@@ -89,12 +89,65 @@ LoadWidget::LoadWidget(std::vector<fileTypes>& _supportedTypes , QWidget *parent
}
}
connect(this, SIGNAL(filterSelected(QString)), this, SLOT(currentFilterChanged(QString)));
//overwrite dialog shouldn't be handled by the qfiledialog
setConfirmOverwrite(false);
setDirectory(OpenFlipper::Options::currentDirStr());
}
/// 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);
}
}
const DataType type = (DataType) typeBox_->itemData( typeBox_->currentIndex() ).toInt();
if ( loadMode_ ){
for (int i=0; i < (int)supportedTypes_.size(); i++)
if (supportedTypes_[i].type == type){
//add Widget for new Filter
QWidget* nuWidget = 0;
nuWidget = supportedTypes_[i].plugin->loadOptionsWidget(_currentFilter);
if (nuWidget != 0){
boxLayout_->addWidget( nuWidget );
box_->show();
}else
if ( supportedTypes_[i].loadWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].loadWidget);
box_->show();
}
}
}else{
for (int i=0; i < (int)supportedTypes_.size(); i++)
if (supportedTypes_[i].type == type){
//add Widget for new Filter
QWidget* nuWidget = 0;
nuWidget = supportedTypes_[i].plugin->saveOptionsWidget(_currentFilter);
if (nuWidget != 0){
boxLayout_->addWidget( nuWidget );
box_->show();
}else
if ( supportedTypes_[i].saveWidget != 0 ) {
boxLayout_->addWidget(supportedTypes_[i].saveWidget);
box_->show();
}
}
}
}
/// adjust load-filters to current datatype
void LoadWidget::slotSetLoadFilters(int _typeIndex){
box_->setTitle("Load Options");
......
......@@ -50,7 +50,8 @@ class LoadWidget : public QFileDialog
private slots:
void slotSetLoadFilters(int _typeIndex);
void slotSetSaveFilters(int _typeIndex);
void currentFilterChanged(QString _currentFilter);
private:
int id_;
bool loadMode_;
......
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