Skip to content
Snippets Groups Projects
Commit c8549245 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

added targetOnly option to SaveSettings dialog

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@3388 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6467aa55
Branches
Tags
No related merge requests found
......@@ -442,13 +442,13 @@ private:
*
* Writes the complete status to an ini file ( All open objects and their Information )
*/
void writeIniFile(QString _filename, bool _relativePaths);
void writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly);
/** \brief Write current status to obj file (Application and File Options)
*
* Writes the complete status to an obj file ( All open objects and their Information )
*/
void writeObjFile(QString _filename, bool _relativePaths);
void writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly);
/// Called if app is closed and writes all information to ini file
void writeOnExit();
......
......@@ -494,7 +494,7 @@ void Core::openIniFile(QString _filename) {
}
void Core::writeIniFile(QString _filename, bool _relativePaths) {
void Core::writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly) {
INIFile ini;
if ( ! ini.connect(_filename,true) ) {
......@@ -512,9 +512,16 @@ void Core::writeIniFile(QString _filename, bool _relativePaths) {
// This vector will hold the file sections to open
QStringList openFiles;
PluginFunctions::IteratorRestriction restriction;
if ( _targetOnly )
restriction = PluginFunctions::TARGET_OBJECTS;
else
restriction = PluginFunctions::ALL_OBJECTS;
QString keyName;
QString sectionName;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ;
for ( PluginFunctions::ObjectIterator o_it(restriction) ;
o_it != PluginFunctions::objects_end(); ++o_it) {
QString file = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
if (QFile(file).exists()){
......
......@@ -248,7 +248,7 @@ void Core::preprocessObjFile(QString _filename)
//-----------------------------------------------------------------------------
void Core::writeObjFile(QString _filename, bool _relativePaths)
void Core::writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly)
{
// open file
std::string fname = _filename.toStdString();
......@@ -266,9 +266,14 @@ void Core::writeObjFile(QString _filename, bool _relativePaths)
coreWidget_->setStatus(ApplicationStatus::BLOCKED );
}
PluginFunctions::IteratorRestriction restriction;
if ( _targetOnly )
restriction = PluginFunctions::TARGET_OBJECTS;
else
restriction = PluginFunctions::ALL_OBJECTS;
// write all objects to a separate obj file and save external references in the global obj file
for ( PluginFunctions::ObjectIterator o_it (PluginFunctions::ALL_OBJECTS) ;
for ( PluginFunctions::ObjectIterator o_it (restriction) ;
o_it != PluginFunctions::objects_end(); ++o_it)
{
QString file = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
......
......@@ -201,9 +201,15 @@ void Core::slotSaveIniMenu(){
askOverwrite->setToolTip("If a file exists you will get asked what to do");
askOverwrite->setCheckState( Qt::Checked );
QCheckBox *targetOnly = new QCheckBox(optionsBox);
targetOnly->setText("Save only target objects");
targetOnly->setToolTip("Only objects with target flag will be handled");
targetOnly->setCheckState( Qt::Unchecked );
QBoxLayout* frameLayout = new QBoxLayout(QBoxLayout::TopToBottom,optionsBox);
frameLayout->addWidget( saveAllBox , 0 , 0);
frameLayout->addWidget( askOverwrite , 1 , 0);
frameLayout->addWidget( targetOnly , 2 , 0);
frameLayout->addStretch();
QStringList fileNames;
......@@ -234,8 +240,14 @@ void Core::slotSaveIniMenu(){
connect(widget,SIGNAL(save(int, QString)),this,SLOT(slotSave(int, QString)));
}
PluginFunctions::IteratorRestriction restriction;
if ( targetOnly->isChecked() )
restriction = PluginFunctions::TARGET_OBJECTS;
else
restriction = PluginFunctions::ALL_OBJECTS;
//iterate over opened objects and save them
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ;
for ( PluginFunctions::ObjectIterator o_it(restriction);
o_it != PluginFunctions::objects_end(); ++o_it)
{
if ( saveAllBox->isChecked() )
......@@ -309,10 +321,10 @@ void Core::slotSaveIniMenu(){
if ( complete_name.endsWith("ini") ) {
//write to ini
writeIniFile(complete_name, saveAllBox->isChecked());
writeIniFile(complete_name, saveAllBox->isChecked(), targetOnly->isChecked() );
} else if ( complete_name.endsWith("obj") ) {
//write to obj
writeObjFile(complete_name, saveAllBox->isChecked());
writeObjFile(complete_name, saveAllBox->isChecked(), targetOnly->isChecked() );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment