Commit ae59ee16 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

some fixes for ini-file saving

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2612 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a0324571
...@@ -194,7 +194,7 @@ void Core::slotSaveIniMenu(){ ...@@ -194,7 +194,7 @@ void Core::slotSaveIniMenu(){
QCheckBox *saveAllBox = new QCheckBox(optionsBox); QCheckBox *saveAllBox = new QCheckBox(optionsBox);
saveAllBox->setText("Save everything to same folder"); saveAllBox->setText("Save everything to same folder");
saveAllBox->setToolTip("Save all open files to the same folder as the ini file"); saveAllBox->setToolTip("Save all open files to the same folder as the ini file");
saveAllBox->setCheckState( Qt::Unchecked ); saveAllBox->setCheckState( Qt::Checked );
QCheckBox *askOverwrite = new QCheckBox(optionsBox); QCheckBox *askOverwrite = new QCheckBox(optionsBox);
askOverwrite->setText("Ask before overwriting files"); askOverwrite->setText("Ask before overwriting files");
...@@ -243,7 +243,6 @@ void Core::slotSaveIniMenu(){ ...@@ -243,7 +243,6 @@ void Core::slotSaveIniMenu(){
// Use path of ini file for all objects // Use path of ini file for all objects
QString filename = newpath + OpenFlipper::Options::dirSeparator() + o_it->name(); QString filename = newpath + OpenFlipper::Options::dirSeparator() + o_it->name();
// enforce that all files end with obj extension // enforce that all files end with obj extension
if ( complete_name.endsWith("obj") ) if ( complete_name.endsWith("obj") )
{ {
...@@ -270,7 +269,8 @@ void Core::slotSaveIniMenu(){ ...@@ -270,7 +269,8 @@ void Core::slotSaveIniMenu(){
} }
else else
{ {
QString filename = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name(); // QString filename = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
QString filename = newpath + OpenFlipper::Options::dirSeparator() + o_it->name();
std::cerr << "o_it->path : " << o_it->path().toStdString() << std::endl; std::cerr << "o_it->path : " << o_it->path().toStdString() << std::endl;
......
...@@ -117,7 +117,7 @@ void LoadWidget::slotSetLoadFilters(int _typeIndex){ ...@@ -117,7 +117,7 @@ void LoadWidget::slotSetLoadFilters(int _typeIndex){
QStringList filters = supportedTypes_[i].loadFilters.split(";;"); QStringList filters = supportedTypes_[i].loadFilters.split(";;");
for (int f=0; f < filters.size(); f++) for (int f=0; f < filters.size(); f++)
if (filters[f].trimmed() == "") filters.removeAt(f); if (filters[f].trimmed() == "") filters.removeAt(f);
setFilters(filters); setNameFilters(filters);
//add Widget for new Filter //add Widget for new Filter
if ( supportedTypes_[i].loadWidget != 0 ) { if ( supportedTypes_[i].loadWidget != 0 ) {
...@@ -153,7 +153,7 @@ void LoadWidget::slotSetSaveFilters(int _typeIndex){ ...@@ -153,7 +153,7 @@ void LoadWidget::slotSetSaveFilters(int _typeIndex){
QStringList filters = supportedTypes_[i].saveFilters.split(";;"); QStringList filters = supportedTypes_[i].saveFilters.split(";;");
for (int f=0; f < filters.size(); f++) for (int f=0; f < filters.size(); f++)
if (filters[f].trimmed() == "") filters.removeAt(f); if (filters[f].trimmed() == "") filters.removeAt(f);
setFilters(filters); setNameFilters(filters);
//add Widget for new Filter //add Widget for new Filter
if ( supportedTypes_[i].saveWidget != 0 ) { if ( supportedTypes_[i].saveWidget != 0 ) {
...@@ -286,12 +286,17 @@ int LoadWidget::showSave(int _id, QString _filename){ ...@@ -286,12 +286,17 @@ int LoadWidget::showSave(int _id, QString _filename){
return QDialog::Rejected; return QDialog::Rejected;
} }
disconnect(typeBox_, SIGNAL(activated(int)), 0, 0);
connect(typeBox_,SIGNAL(activated(int)),this,SLOT(slotSetSaveFilters(int)));
slotSetSaveFilters(typeBox_->currentIndex());
//display correct path/name //display correct path/name
QFileInfo fi(_filename); QFileInfo fi(_filename);
QFile file(_filename); QFile file(_filename);
if (file.exists()) { if (file.exists()) {
setDirectory( fi.absolutePath() ); setDirectory( fi.absolutePath() );
selectFile ( _filename ); selectFile ( fi.fileName() );
} else { } else {
// setDirectory(OpenFlipper::Options::currentDir().absolutePath() ); // setDirectory(OpenFlipper::Options::currentDir().absolutePath() );
std::cout << "setting filename = " << _filename.toStdString() << std::endl; std::cout << "setting filename = " << _filename.toStdString() << std::endl;
...@@ -299,12 +304,26 @@ int LoadWidget::showSave(int _id, QString _filename){ ...@@ -299,12 +304,26 @@ int LoadWidget::showSave(int _id, QString _filename){
selectFile ( fi.fileName() ); selectFile ( fi.fileName() );
} }
//try to select the best fitting name filter
for (int i=0; i < nameFilters().count(); i++){
int s = nameFilters()[i].indexOf("*")+2;
int e = nameFilters()[i].indexOf(" ", s);
QString ext = nameFilters()[i].mid(s,e-s);
if (ext == fi.completeSuffix()){
selectNameFilter(nameFilters()[i]);
break;
}
}
disconnect(typeBox_, SIGNAL(activated(int)), 0, 0); //workarround to force repaint
connect(typeBox_,SIGNAL(activated(int)),this,SLOT(slotSetSaveFilters(int))); if (x() > 0){
if (step_)
slotSetSaveFilters(typeBox_->currentIndex()); setGeometry(x(),y(),width()+1,height());
else
setGeometry(x(),y(),width()-1,height());
}
step_ = !step_;
return this->exec(); return this->exec();
} }
......
...@@ -76,6 +76,8 @@ class LoadWidget : public QFileDialog ...@@ -76,6 +76,8 @@ class LoadWidget : public QFileDialog
/// QFrame on the right /// QFrame on the right
QGroupBox* box_; QGroupBox* box_;
QHBoxLayout* boxLayout_; QHBoxLayout* boxLayout_;
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