Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

void FileCache::loadCacheIndex ( QString  filename  )  [protected]

Loads the cache from the given XML file and adds it to the cached files list. So one can load several lists and they will be merged.

Definition at line 59 of file fileCache.cpp.

Referenced by loadCache().

                                               {
  // try to load from filename

#ifdef DEBUG
  cout << "Cache path: " << filename.latin1() << endl;
#endif
  cacheIndexFilename = filename;

  // parse the document
  QDomDocument doc;
  QFile *file = new QFile(cacheIndexFilename);
  if (doc.setContent(file)) {
    /* search for earth3dcache tag */
    QDomNode nform = doc.documentElement();
    while( !nform.isNull() ) {
      QDomElement e = nform.toElement(); // try to convert the node to an element.
      if( !e.isNull() && e.tagName() == QString("earth3dcache")) {
        /* iterate through attribute tags */
        QDomNode ninput = nform.firstChild();
        while( !ninput.isNull() ) {
          e = ninput.toElement(); // try to convert the node to an element.
          if( !e.isNull() && e.tagName() == QString("cacheentry")) {
#ifdef DEBUG
            cout << "filename: " << e.attribute("filename", "").latin1() << endl;
#endif
          
            /* insert into cache list  */
            QString newfilename = e.attribute("filename", "");
            if (newfilename != "" && !files.contains(newfilename)) {
              files.append(newfilename);
            }
          }
        
          ninput = ninput.nextSibling();
        }
      }
      nform = nform.nextSibling();      
    }
  }
  
  file->close();
  delete(file);
}


Generated by  Doxygen 1.6.0   Back to index