Beispiel #1
0
void KJotsMain::writeBook()
{
  saveFolder();
  QString name;
  while( name.isNull() )
    {
      name =  KFileDialog::getSaveFileName();
      if ( name.isNull() )
	return;
      QFileInfo f_info(name);
      if( f_info.exists() )
	{
	  if( KMsgBox::yesNo(this, klocale->translate("File exists !"),
			     klocale->translate("File already exists. \n Do you want to overwrite it ?")) == 2 )
	    name = "";
	}
    }
  QFile ascii_file(name);
  if( !ascii_file.open(IO_WriteOnly | IO_Truncate) )
    return;
  QTextStream st( (QIODevice *) &ascii_file);
  TextEntry *entry;
  for( entry = entrylist.first(); entry != NULL; entry = entrylist.next() )
    {
      writeEntry( st, entry );
    }
  ascii_file.close();
}
Beispiel #2
0
void KJotsMain::createFolder()
{
  AskFileName *ask = new AskFileName(this);
  if( ask->exec() == QDialog::Rejected )
    return;
  QString name = ask->getName();
  delete ask;
  if( folder_list.contains(name) )
    {
      QMessageBox::message(klocale->translate("Warning"), 
			   klocale->translate("A book with this name already exists."), 
			   klocale->translate("OK"), this);
      return;
    }
  saveFolder();
  entrylist.clear();
  folderOpen = TRUE;
  me_text->setEnabled(TRUE);
  le_subject->setEnabled(TRUE);
  me_text->setFocus();
  me_text->clear();
  me_text->deselect();
  TextEntry *new_entry = new TextEntry;
  entrylist.append(new_entry);
  new_entry->subject = "";
  current = 0;
  s_bar->setRange(0,0);
  s_bar->setValue(0);
  emit folderChanged(&entrylist);
  emit entryMoved(current);
  le_subject->setText(entrylist.first()->subject);

  folder_list.append(name);
  if( folders->text(folders->idAt(0)) == 0 )
    folders->removeItemAt(0);
  folders->insertItem(name, unique_id++);
  //QDir dir = QDir::home();
  //dir.cd(".kde/share/apps/kjots");
  QDir dir = QDir( KApplication::localkdedir().data() );
  dir.cd("share/apps/kjots");
  current_folder_name = dir.absPath();
  current_folder_name += '/';
  current_folder_name += name;
  KConfig *config = KApplication::getKApplication()->getConfig();
  config->setGroup("kjots");
  config->writeEntry( "Folders", folder_list );
  config->sync();
  l_folder->setText(name);
  QPushButton *but;
  for( but = button_list.first(); but != 0; but = button_list.next() )
    but->setOn(FALSE);
}
void stk500SaveFiles::saveFolder(DirectoryEntryPtr dirStartPtr, QString sourceFilePath, QString destFilePath, double progStart, double progTotal) {
    // First of all - create the destination directory before processing
    QDir dir(destFilePath);
    if (!dir.exists()) {
        dir.mkpath(".");
    }

    // Perform a file listing of the current directory
    QList<DirectoryInfo> subFiles = sd_list(dirStartPtr);

    // Filter any VOLUME entries
    int tmpIdx = 0;
    while (tmpIdx < subFiles.length()) {
        DirectoryInfo info = subFiles.at(tmpIdx);
        if (info.isVolume()) {
            subFiles.removeAt(tmpIdx);
        } else {
            tmpIdx++;
        }
    }

    // If cancelled or nothing to go through, stop here
    if (isCancelled() || subFiles.isEmpty()) {
        return;
    }

    // Name to append before the filename to produce a source location
    QString srcPath = sourceFilePath;
    if (!srcPath.isEmpty()) {
        srcPath.append('/');
    }

    // Go by all the files processing them
    int totalFiles = subFiles.length();
    double subProgTotal = progTotal * (1.0 / (double) totalFiles);
    for (int fileIdx = 0; fileIdx < totalFiles && !isCancelled(); fileIdx++) {
        DirectoryInfo info = subFiles.at(fileIdx);
        QString subSrcPath = srcPath + info.name();
        QString subDestPath = destFilePath + '/' + info.name();
        double subProgStart = progStart + progTotal * ((double) fileIdx / (double) totalFiles);
        if (info.isDirectory()) {
            DirectoryEntryPtr dirStartPtr = protocol->sd().getDirPtrFromCluster(info.firstCluster());
            saveFolder(dirStartPtr, subSrcPath, subDestPath, subProgStart, subProgTotal);
        } else {
            saveFile(info.entry(), subSrcPath, subDestPath, subProgStart, subProgTotal);
        }
    }
}
Beispiel #4
0
void KJotsMain::saveProperties(KConfig*)
{
  KConfig *config = KApplication::getKApplication()->getConfig();
  config->setGroup("kjots");
  button_list.clear();
  if( folderOpen )
    {
      QFileInfo fi(current_folder_name);
      config->writeEntry("LastOpenFolder", fi.fileName());
    }
  saveFolder();
  config->writeEntry("Width", width());
  config->writeEntry("Height", height());
  config->writeEntry("ToolBarPos", (int) toolbar->barPos() );
  config->sync();
}
void stk500SaveFiles::run() {
    if (this->sourceFile.endsWith('/')) {
        // Saving a full directory
        // First navigate to this directory
        QString dirPath = this->sourceFile;
        dirPath.remove(dirPath.length() - 1, 1);
        QString destDirPath = this->destFile;
        if (destDirPath.endsWith('/')) {
            destDirPath.remove(destDirPath.length() - 1, 1);
        }

        DirectoryEntryPtr dirStartPtr;
        if (dirPath.isEmpty()) {
            dirStartPtr = protocol->sd().getRootPtr();
        } else {
            DirectoryEntryPtr dirEntryPtr = sd_findEntry(dirPath, true, false);
            if (isCancelled()) {
                return;
            }
            if (!dirEntryPtr.isValid()) {
                // Should not happen, but just in case...
                throw ProtocolException("Folder not found");
            }
            DirectoryEntry folderEntry = protocol->sd().readDirectory(dirEntryPtr);
            if (folderEntry.firstCluster()) {
                dirStartPtr = protocol->sd().getDirPtrFromCluster(folderEntry.firstCluster());
            } else {
                dirStartPtr = DirectoryEntryPtr(0, 0);
            }
        }
        saveFolder(dirStartPtr, dirPath, destDirPath, 0.0, 1.0);
    } else {
        // Saving a single file
        DirectoryEntryPtr filePtr = sd_findEntry(this->sourceFile, false, false);
        if (isCancelled()) {
            return;
        }
        if (!filePtr.isValid()) {
            throw ProtocolException("File not found");
        }
        DirectoryEntry fileEntry = protocol->sd().readDirectory(filePtr);
        saveFile(fileEntry, this->sourceFile, this->destFile, 0.0, 1.0);
    }
}
Beispiel #6
0
void TLevelSet::saveFolder(TOStream &os, TFilePath folder) {
  std::map<std::string, std::string> attr;
  attr["name"]                                   = folder.getName();
  if (folder == getDefaultFolder()) attr["type"] = "default";
  os.openChild("folder", attr);
  std::vector<TFilePath> folders;
  listFolders(folders, folder);
  if (!folders.empty()) {
    for (int i = 0; i < (int)folders.size(); i++) saveFolder(os, folders[i]);
  }
  std::vector<TXshLevel *> levels;
  listLevels(levels, folder);
  if (!levels.empty()) {
    os.openChild("levels");
    for (int i = 0; i < (int)levels.size(); i++)
      if (m_saveSet.empty() || m_saveSet.count(levels[i]) > 0) os << levels[i];
    os.closeChild();
  }
  os.closeChild();
}
Beispiel #7
0
void KJotsMain::openFolder(int id)
{
  QPushButton *but;
  for( but = button_list.first(); but != NULL; but = button_list.next() )
    but->setOn(FALSE);
  but = (QPushButton *) bg_top->find(id);
  if( but )
    but->setOn(TRUE);
  //QDir dir = QDir::home();
  //dir.cd(".kde/share/apps/kjots");
  QDir dir = QDir( KApplication::localkdedir().data() );
  dir.cd("share/apps/kjots");
  QString file_name = dir.absPath();
  file_name += '/';
  file_name += folder_list.at( folders->indexOf(id) );
  if( current_folder_name == file_name )
    return;
  if( folderOpen )
    saveFolder();
  current_folder_name = file_name;
  if( readFile(current_folder_name) < 0)
    {
      folderOpen = FALSE;
      debug("Kjots: Unable to open folder");
      return;
    }
  current = 0;
  me_text->deselect();
  me_text->setText(entrylist.first()->text);
  emit folderChanged(&entrylist);
  emit entryMoved(current);
  le_subject->setText(entrylist.first()->subject);
  folderOpen = TRUE;
  l_folder->setText( folder_list.at(folders->indexOf(id)) );
  me_text->setEnabled(TRUE);
  le_subject->setEnabled(TRUE);
  me_text->setFocus();
  s_bar->setRange(0,entrylist.count()-1);
  s_bar->setValue(0);
}
Beispiel #8
0
KJotsMain::KJotsMain(const char* name)
  : KTopLevelWidget( name )
{
  //create widgets
  f_main = new QFrame( this, "Frame_0" );
  f_main->move(0, 28);
  f_main->setMinimumSize( 500, 180 );
  f_main->setFrameStyle( 0 );

  f_text = new QFrame( f_main, "Frame_1" );
  f_text->setGeometry( 8, 72, 452, 45 );
  f_text->setFrameStyle( 50 );
  
  f_labels = new QFrame( f_main, "Frame_2" );
  f_labels->setMinimumSize( 436, 24 );
  f_labels->setFrameStyle( 0 );
  
  menubar = new KMenuBar( this, "MenuBar_1" );
  // KMenubar is not a FRAME!!! (sven)
  //menubar->setFrameStyle( 34 );
  //menubar->setLineWidth( 2 );

  s_bar = new QScrollBar( f_main, "ScrollBar_1" );
  s_bar->setMinimumSize( 452, 16 );
  s_bar->setOrientation( QScrollBar::Horizontal );
  
  me_text = new MyMultiEdit( f_text, "me_text" );
  me_text->setMinimumSize( 436, 30 );
  me_text->insertLine( "" );

  l_folder = new QLabel( f_labels, "Label_4" );
  l_folder->setMinimumSize( 68, 20 );
  l_folder->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
  l_folder->setText( "" );
  
  le_subject = new QLineEdit( f_labels, "le_subject" );
  le_subject->setMinimumSize( 56, 20 );
  le_subject->setText( "" );
  le_subject->setFocusPolicy(QWidget::ClickFocus);
  
  bg_top = new MyButtonGroup( f_main, "ButtonGroup_2" );
  bg_top->setMinimumSize( 452, 32 );
  bg_top->setFrameStyle( 49 ); 
  bg_top->setTitle( "" );
  bg_top->setAlignment( 1 );
  bg_top->lower();
  
  this->setMinimumSize(500, 211);
  
  KConfig *config = KApplication::getKApplication()->getConfig();

  config->setGroup("kjots");
  entrylist.setAutoDelete(TRUE);
  button_list.setAutoDelete(TRUE);
  folderOpen = FALSE;
  entrylist.append(new TextEntry);
  confdiag = NULL;
  subj_list = new SubjList;
  connect( this, SIGNAL(folderChanged(QList<TextEntry> *)), subj_list,
	   SLOT(rebuildList( QList<TextEntry> *)) );
  connect( this, SIGNAL(entryMoved(int)), subj_list, SLOT( select(int)) );
  connect( subj_list, SIGNAL(entryMoved(int)), this, SLOT( barMoved(int)) );
  connect( le_subject, SIGNAL(textChanged(const char *)), subj_list, 
	   SLOT(entryChanged(const char*)) );
  me_text->setEnabled(FALSE);
  le_subject->setEnabled(FALSE);
  current = 0;
  connect( s_bar, SIGNAL(valueChanged(int)), this, SLOT(barMoved(int)) );
 
  top2bottom = new QGridLayout( f_main, 4, 1, 4 );
  top2bottom->addWidget( f_text, 0, 0, AlignCenter );
  top2bottom->setRowStretch( 0, 1 );
  top2bottom->addWidget( s_bar, 1, 0, AlignCenter );
  top2bottom->addWidget( bg_top, 2, 0, AlignCenter );
  top2bottom->addWidget( f_labels, 3, 0, AlignCenter );
  top2bottom->activate();

  labels_layout = new QGridLayout( f_labels, 1, 2, 0 );
  labels_layout->addWidget( l_folder, 0, 0, AlignVCenter | AlignLeft );
  labels_layout->addWidget( le_subject, 0, 1, AlignVCenter | AlignLeft );
  labels_layout->setColStretch( 1, 1 );
  labels_layout->activate();

  QFont font_label(l_folder->fontInfo().family());
  font_label.setBold(TRUE);
  l_folder->setFont(font_label);

  f_text_layout = new QGridLayout( f_text, 2, 1, 4 );
  f_text_layout->addWidget( me_text, 0, 0, AlignCenter );
  f_text_layout->setRowStretch( 0, 1 );
  f_text_layout->activate();

  s_bar->setRange(0,0);
  s_bar->setValue(0);
  s_bar->setSteps(1,1);

  bg_top->setExclusive(TRUE);
  me_text->setFocusPolicy(QWidget::StrongFocus);

  // read hotlist
  config->readListEntry( "Hotlist", hotlist );
  while( hotlist.count() > HOT_LIST_SIZE )
    hotlist.removeLast();
  // read list of folders
  config->readListEntry( "Folders", folder_list );

  QString temp;
  folders = new QPopupMenu;
  int i = 0;
  QPushButton *temp_button;
  for( temp = folder_list.first(); !temp.isEmpty(); temp = folder_list.next(), i++ )
    { 
      folders->insertItem(temp, i); 
      if( hotlist.contains(temp) )
	{
	  temp_button = new QPushButton(temp, bg_top);
	  temp_button->setFocusPolicy(QWidget::ClickFocus);
	  temp_button->setToggleButton(TRUE);
	  temp_button->setFixedSize(BUTTON_WIDTH,24);
	  bg_top->insert(temp_button, i);
	  button_list.append(temp_button);
	}
    }
  unique_id = i+1;
  connect( folders, SIGNAL(activated(int)), this, SLOT(openFolder(int)) );
  connect( bg_top, SIGNAL(clicked(int)), this, SLOT(openFolder(int)) );

  updateConfiguration();

  // creat keyboard shortcuts
  // CTRL+Key_J := previous page
  // CTRL+Key_K := next page
  // CTRL+Key_L := show subject list
  // CTRL+Key_A := add new page
  // CTRL+Key_M := move focus

  keys = new KAccel( this ); 


  keys->insertStdItem( KAccel::New, klocale->translate("New Book") ); 


  keys->connectItem( KAccel::New, this, SLOT(createFolder()) );
  keys->connectItem( KAccel::Save , this, SLOT(saveFolder()) );
  keys->connectItem( KAccel::Quit, qApp, SLOT(quit()) );
  keys->connectItem( KAccel::Cut , me_text, SLOT(cut()) );
  keys->connectItem( KAccel::Copy , me_text, SLOT(copyText()) );
  keys->connectItem( KAccel::Paste , me_text, SLOT(paste()) );

  keys->insertItem(i18n("PreviousPage"),    "PreviousPage",    CTRL+Key_J);
  keys->insertItem(i18n("NextPage"),        "NextPage",        CTRL+Key_K);
  keys->insertItem(i18n("ShowSubjectList"), "ShowSubjectList", CTRL+Key_L);
  keys->insertItem(i18n("AddNewPage"),      "AddNewPage",      CTRL+Key_A);
  keys->insertItem(i18n("MoveFocus"),       "MoveFocus",       CTRL+Key_M);
  keys->insertItem(i18n("CopySelection"),   "CopySelection",   CTRL+Key_Y);
  keys->connectItem( "PreviousPage", this, SLOT(prevEntry()) );
  keys->connectItem( "NextPage", this, SLOT(nextEntry()) );
  keys->connectItem( "ShowSubjectList", this, SLOT(toggleSubjList()) );
  keys->connectItem( "AddNewPage", this, SLOT(newEntry()) );
  keys->connectItem( "MoveFocus", this, SLOT(moveFocus()) );
  keys->connectItem( "CopySelection", this, SLOT(copySelection()) );
  keys->readSettings();

  // create menu
  int id;
  QPopupMenu *file = new QPopupMenu;
  id = file->insertItem(klocale->translate("&New Book"), this, SLOT(createFolder()));
  keys->changeMenuAccel(file, id, KAccel::New); 

  file->insertSeparator();
  id = file->insertItem(klocale->translate("Save current book"), this, SLOT(saveFolder()) );
  keys->changeMenuAccel(file, id, KAccel::Save); 
  id = file->insertItem(klocale->translate("Save book to ascii file"), this, SLOT(writeBook()) );
  id = file->insertItem(klocale->translate("Save page to ascii file"), this, SLOT(writePage()) );
  file->insertSeparator();
  id = file->insertItem(klocale->translate("Delete current book"), this, SLOT(deleteFolder()) );
  file->insertSeparator();
  id = file->insertItem(klocale->translate("&Quit"), qApp, SLOT( quit() ));
  keys->changeMenuAccel(file, id, KAccel::Quit); 

  QPopupMenu *edit_menu = new QPopupMenu;

  id = edit_menu->insertItem(klocale->translate("C&ut"),me_text, SLOT(cut()));
  keys->changeMenuAccel(edit_menu, id, KAccel::Cut); 
  id = edit_menu->insertItem(klocale->translate("&Copy") , me_text, SLOT(copyText()) );
  keys->changeMenuAccel(edit_menu, id, KAccel::Copy); 
  id = edit_menu->insertItem(klocale->translate("&Paste"), me_text, SLOT(paste()));
  keys->changeMenuAccel(edit_menu, id, KAccel::Paste); 
  edit_menu->insertSeparator();
  id = edit_menu->insertItem(klocale->translate("&New Page"), this, SLOT(newEntry()) );
  keys->changeMenuAccel(edit_menu, id, "AddNewPage"); 
  id = edit_menu->insertItem(klocale->translate("&Delete Page"), this, SLOT(deleteEntry()) );

  QPopupMenu *options = new QPopupMenu;
  options->insertItem(klocale->translate("&Config"), this, SLOT(configure()) );
  options->insertItem(klocale->translate("Configure &Keys"), this, SLOT(configureKeys()) );

  QPopupMenu *hotlist = new QPopupMenu;
  hotlist->insertItem(klocale->translate("Add current book to hotlist"), 
		      this, SLOT(addToHotlist()) );
  hotlist->insertItem(klocale->translate("Remove current book from hotlist"),
		      this, SLOT(removeFromHotlist()) );

  menubar->insertItem( klocale->translate("&File"), file );
  menubar->insertItem( klocale->translate("&Edit"), edit_menu );
  menubar->insertItem( klocale->translate("Hot&list"), hotlist );
  menubar->insertItem( klocale->translate("&Options"), options );
  menubar->insertItem( klocale->translate("&Books"), folders );
  menubar->insertSeparator();
  QString about = "KJots 0.3.1\n\r(C) ";
  about += (QString) klocale->translate("by") +
    " Christoph Neerfeld\n\[email protected]";
  menubar->insertItem( klocale->translate("&Help"),
		       KApplication::getKApplication()->getHelpMenu(TRUE, about ) );


  config->setGroup("kjots");
  // create toolbar
  toolbar = new KToolBar(this);
  QPixmap temp_pix;
  temp_pix = global_pix_loader->loadIcon("filenew.xpm");
  toolbar->insertButton(temp_pix, 0, SIGNAL(clicked()), this,
		      SLOT(newEntry()), TRUE, i18n("New"));
  temp_pix = global_pix_loader->loadIcon("filedel.xpm");
  toolbar->insertButton(temp_pix, 1, SIGNAL(clicked()), this,
		      SLOT(deleteEntry()), TRUE, i18n("Delete"));
  temp_pix = global_pix_loader->loadIcon("back.xpm");
  toolbar->insertButton(temp_pix, 2, SIGNAL(clicked()), this,
		      SLOT(prevEntry()), TRUE, i18n("Previous"));
  temp_pix = global_pix_loader->loadIcon("forward.xpm");
  toolbar->insertButton(temp_pix, 3, SIGNAL(clicked()), this,
		      SLOT(nextEntry()), TRUE, i18n("Next"));
  toolbar->insertSeparator();
  temp_pix = global_pix_loader->loadIcon("openbook.xpm");
  toolbar->insertButton(temp_pix, 4, SIGNAL(clicked()), this,
		      SLOT(toggleSubjList()), TRUE, i18n("Subject List"));
  toolbar->insertSeparator();
  temp_pix = global_pix_loader->loadIcon("exit.xpm");
  toolbar->setBarPos( (KToolBar::BarPosition) config->readNumEntry("ToolBarPos") );
  addToolBar(toolbar);
  setView(f_main, FALSE);
  setMenu(menubar);
  enableToolBar(KToolBar::Show);

  QString last_folder = config->readEntry("LastOpenFolder");
  int nr;
  if( (nr = folder_list.find(last_folder)) >= 0 )
    openFolder(nr);
  int width, height;
  width = config->readNumEntry("Width");
  height = config->readNumEntry("Height");
  if( width < minimumSize().width() )
    width = minimumSize().width();
  if( height < minimumSize().height() )
    height = minimumSize().height();
  resize(width, height);
}
Beispiel #9
0
void Optimization::createSubExecs(QList<QList<ModModelPlus*> > & subModels, QList<BlockSubstitutions*> & subBlocks)
{

    subModels.clear();
    subBlocks.clear();

    QMultiMap<QString,QString> map; // <orgComponent,subcomponent>
    QMap<QString,QString> mapModel; //<orgComponent,model>
    // fill map
    for(int i=0; i < _blockSubstitutions->getSize();i++)
    {
        BlockSubstitution *curBlockSub = _blockSubstitutions->getAt(i);
        if(!curBlockSub->_subComponent.isEmpty())
        {
            map.insert(curBlockSub->_orgComponent,curBlockSub->_subComponent);
            mapModel.insert(curBlockSub->_orgComponent,curBlockSub->_model);
        }
    }

    int nbOrgs = map.uniqueKeys().size();
    //adding non-moving cases for each orgComponent
    for(int i = 0; i<nbOrgs; i ++)
    {
        map.insert(map.uniqueKeys().at(i),map.uniqueKeys().at(i));
    }


    //build first index and maximum index
    QList<int> index, maxIndex;
    nbOrgs = map.uniqueKeys().size();
    for(int i = 0; i<nbOrgs; i ++)
    {
        index.push_back(0);
        QList<QString> subs = map.values(map.uniqueKeys().at(i));
        maxIndex.push_back(subs.size()-1);
    }


    QStringList models = mapModel.values();
    models.removeDuplicates();



    // storing genuine mo file paths
    QStringList oldMoFilePaths;
    for(int iM=0;iM<models.size();iM++)
    {
        oldMoFilePaths.push_back(_omProject->modModelPlus(models.at(iM))->moFilePath());
    }



    int iCase=0;
    bool oneChange;
    while(!index.isEmpty())
    {


        // Display case (for debug)
        QString msg = "CASE " + QString::number(iCase) + "\n";
        for(int i=0; i < index.size(); i++)
        {
            msg += map.uniqueKeys().at(i);
            msg += " -> ";
            msg += map.values(map.uniqueKeys().at(i)).at(index.at(i));
            msg+=",";
        }
        msg.remove(msg.size()-1,1);
        msg +="\n \n";
        InfoSender::instance()->debug(msg);


        // create folder
        QString newName = "case_"+QString::number(iCase);
        QString newFolder = saveFolder()+ QDir::separator() + "SubModels" + QDir::separator() + newName;
        QDir dir(saveFolder());
        dir.mkpath(newFolder);
        QDir newDir(newFolder);


        // clone mo files and load them
        // and create corresponding modmodelplus
        QStringList newMoPaths;
        QStringList newMmoPaths;
        QMap<QString,ModModelPlus*> newModModels;
        for(int iM=0;iM<oldMoFilePaths.size();iM++)
        {
            QFileInfo oldMoFileInfo(oldMoFilePaths.at(iM));
            QFile oldMoFile(oldMoFilePaths.at(iM));

            QString newMoPath = newDir.filePath(oldMoFileInfo.fileName());
            QString newMmoPath = newMoPath;
            newMmoPath = newMmoPath.replace(".mo",".mmo");

            newDir.remove(newMoPath);
            oldMoFile.copy(newMoPath);

            newMoPaths.append(newMoPath);
            newMmoPaths.append(newMmoPath);


            // load file (! will replace previously loaded)
            _omProject->loadMoFile(newMoPath,false,true);

            // create new modModelPlus
            ModModelPlus* newModModelPlus = new ModModelPlus(_omProject,models.at(iM));
            newModModelPlus->setMmoFilePath(newMmoPath);
            newModModels.insert(models.at(iM),newModModelPlus);
        }


        // apply blocksubs
        BlockSubstitutions *curSubBlocks = new BlockSubstitutions();

        QMap<QString,bool> changes; // <model,hasChanged>
        changes.clear();
        for(int i=0; i<index.size();i++)
        {
            QString replacedComp = map.uniqueKeys().at(i);
            QString replacingComp = map.values(map.uniqueKeys().at(i)).at(index.at(i));

            if(replacedComp != replacingComp)
            {
                BlockSubstitution* blockSub = _blockSubstitutions->find(replacedComp,replacingComp);
                if(blockSub)
                {
                    ModModelPlus* corrNewModModelPlus = newModModels.value(blockSub->_model);
                    oneChange =  corrNewModModelPlus->applyBlockSub(blockSub,true) || oneChange ;
                    curSubBlocks->push_back(blockSub);
                    changes.insert(blockSub->_model,true);
                }
            }
        }

        QStringList modelsToCompile = changes.keys(true);// those which have been modified
        bool compilationOk = true;
        for(int iM=0;iM<modelsToCompile.size();iM++)
        {
            ModModelPlus* modelPlus = newModModels.value(modelsToCompile.at(iM));
            compilationOk = modelPlus->compile(ctrl(modelsToCompile.at(iM))) && compilationOk;
        }

        if(compilationOk)
        {

            // store subModel and subBlocks
            subModels.push_back(newModModels.values());
            subBlocks.push_back(curSubBlocks);
            _foldersToCopy << newFolder;

            InfoSender::instance()->send( Info(ListInfo::SUBMODELADDED,newName));
        }
        else
        {
            InfoSender::instance()->send( Info(ListInfo::SUBMODELNOTADDED,newName));
        }


        iCase++;
        index = LowTools::nextIndex(index,maxIndex);
    }

    // reload genuine mo file
    if(iCase>0)
    {
        for(int i=0;i<oldMoFilePaths.size();i++)
            _omProject->loadMoFile(oldMoFilePaths.at(i),false,true);
    }
}