bool IniFile::Save(){
  if (filename.isEmpty()) return false;
  file.setName(filename);
  if (! file.open(QIODevice::WriteOnly)){
#ifdef DEBUG
    cerr << "\nCannot write File: " << filename.latin1();
#else

#endif
    return false;
  }

  IniSection* section;
  IniVar* var;
  QString line;

  // Durchgehen und alles reinschreiben
  file.writeBlock(comment.latin1(),comment.length());
  for(section=sections.first();section!=0;section=sections.next()){
    line="\n[";
    line.append(section->getName());
    line.append("]\n");
    file.writeBlock(line.latin1(),line.length());
    line=section->getComment();
    if (!line.isEmpty()) {
      line += "\n";
      file.writeBlock(line.latin1(),line.length());
    }
    for(var=section->vars.first();var!=0;var=section->vars.next()){
      line=var->getName();
      if (! var->getValue().isEmpty()){
        line.append("=");
        line.append(var->getValue());
        line.append(var->getComment());
//      }else{
        line.append("\n");
      }
      file.writeBlock(line.latin1(),line.length());
    }
  }

  file.close();

  return true;
}
bool IniFile::getSection(IniSection& _section,QString _name,bool _next){
  static QString lastname;
  IniSection* sec;
  if (_next==false || (_next==true && _name!=lastname) ) {
    lastname ="";
    sec=sections.first();

  }else{
    sec=sections.next();
  }

  lastname=_name;

  for(;sec!=0;sec=sections.next()){
      if (sec->getName()==_name){  // gefunden
        sec->copy(_section);
        return true;
      }
  }
  return false;
}
bool IniSection::operator== (IniSection& _section){
  return name==_section.getName();
}