void FRXMLCharDataReader::parseSingleImageFile(const std::string fileName, const std::string resultFileName, GrayImage<> *pImage, std::vector<ImageChar> &imageCharVec, const int imageId /*= 0*/) const
{
	// create the finereader xml output handler object need for parsing the files
	FineReaderXMLOutputHandler *pXMLHandler = new FineReaderXMLOutputHandler();
	// create simple reader and set the content/error handler
    QXmlSimpleReader reader;
    reader.setContentHandler(pXMLHandler);
    reader.setErrorHandler(pXMLHandler);

	// create QFile object
    QFile file( QString::fromStdString(resultFileName) );
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
     	throw Exception("Error openening xml-file in FRXMLCharDataReader::parseXMLFiles!");
     }
     // create xml input source from file object
     QXmlInputSource xmlInputSource(&file);
     // parse the file using the simple reader
     reader.parse(xmlInputSource);
     std::cout << "Successfully parsed xml data of file " << resultFileName << std::endl;
 	// store results
     SimpleFineReaderXMLData* pData = pXMLHandler->getFineReaderData();
//     imageCharVec.clear();
     for (int j=0; j<pData->parsedBBoxes.size(); ++j) {
     	ImageChar imChar(pData->parsedBBoxes[j], pImage, imageId, imageCharVec.size());
     	imChar.text = pData->parsedChars[j];
     	imChar.suspicious = pData->isSuspicious[j];

     	imageCharVec.push_back(imChar);
     } // end for j
     pXMLHandler->clearData();
     delete pXMLHandler;

     return;
} // end parseSingleImageFile
Exemplo n.º 2
0
	void DemoGameLogic::loadScene(QString filename)
	{
		//The QtOgre DotScene loading code will clear the existing scene except for cameras, as these
		//could be used by existing viewports. Therefore we clear and viewports and cameras before
		//calling the loading code.
		mApplication->ogreRenderWindow()->removeAllViewports();
		mSceneManager->destroyAllCameras();

		//Now load the scene.
		DotSceneHandler handler(mSceneManager);
		QXmlSimpleReader reader;
		reader.setContentHandler(&handler);
		reader.setErrorHandler(&handler);

		QFile file(filename);
		file.open(QFile::ReadOnly | QFile::Text);
		QXmlInputSource xmlInputSource(&file);
		reader.parse(xmlInputSource);

		//Now create a viewport, using the first camera in the scene.
		mCamera = mSceneManager->getCameraIterator().peekNextValue();

		//mCamera->setPosition(0, 0, 20);
		//mCamera->lookAt(0, 0, 0);
		mCamera->setNearClipDistance(1.0);
		mCamera->setFarClipDistance(1000.0);
		//mCamera->setFOVy(Ogre::Radian(1.0f));

		Ogre::Viewport* viewport = mApplication->ogreRenderWindow()->addViewport(mCamera);
		viewport->setBackgroundColour(Ogre::ColourValue::Black);
	}
Exemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->lineEdit,SIGNAL(textChanged( const QString&)),this,SLOT(search(const QString&)));

       connect(ui->lineEdit,SIGNAL(returnPressed()),this,SLOT(enter()));

    ui->treeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);
    ui->treeWidget->clear();

    XmlHandler handler(ui->treeWidget);

    /* XML Parsing and Showing */
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);

    QFile f("/Users/maluta/Downloads/google-reader-subscriptions.xml");
    f.open(QFile::ReadOnly | QFile::Text);

    qDebug() << "-- entrou" ;

    QXmlInputSource xmlInputSource(&f);

    if (reader.parse(xmlInputSource))
        statusBar()->showMessage(tr("Search Finished"), 3000);

    f.close();

}
Exemplo n.º 4
0
void MainWindow::open()
{
    QString fileName =
            QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
                                         QDir::currentPath(),
                                         tr("XBEL Files (*.xbel *.xml)"));
    if (fileName.isEmpty())
        return;

    treeWidget->clear();

    XbelHandler handler(treeWidget);
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);

    QFile file(fileName);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
        QMessageBox::warning(this, tr("SAX Bookmarks"),
                             tr("Cannot read file %1:\n%2.")
                             .arg(fileName)
                             .arg(file.errorString()));
        return;
    }

    QXmlInputSource xmlInputSource(&file);
    if (reader.parse(xmlInputSource))
        statusBar()->showMessage(tr("File loaded"), 2000);
}
Exemplo n.º 5
0
void BDHServerController::loadConfiguration()
{
    QFile file;

    //! Set XML dir
    file.setFileName(QString("./hmi.xml"));

    //! Open file
    if (!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug() << "Not hmi.xml file present and can't configure. \n CLOSING...";
        exit(-1);
    }

    //! Set XML reader
    QXmlSimpleReader reader;
    reader.setContentHandler(m_configurationLoader);
    reader.setErrorHandler(m_configurationLoader);
    QXmlInputSource xmlInputSource(&file);

    //! Parse hmi.xml file for proyect configuration
    if (!reader.parse(xmlInputSource))
    {
        //!Show error parsing hmi.xml
        qDebug() << QString("There was an error while loading the configuration: %1. \n CLOSING...").arg(m_configurationLoader->errorString());
        exit(-1);
    }

}
Exemplo n.º 6
0
Prototype::Prototype(const QString& xmlfilepath) :
        QObject(0),
        _elementsParType(),
        _mode_generation_bagage(AUTOMATIQUE),
        _id_bagage_genere(ID_BAGAGE_GENERE_INITIAL),
        _dt (INTERVALLE_RAFRAICHISSEMENT_MODELE / 1000.0)
{
    qsrand(time(0));
    // Désérialise le fichier XML.
    // Extrait et classe par type des pointeurs d'éléments.
    XmlConfigFactory handler;
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);

    QFile file(xmlfilepath);
    if (!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug() << "Cannot read XML file." << endl;
        exit(1);
    }

    QXmlInputSource xmlInputSource(&file);
    if (reader.parse(xmlInputSource))
    {
        _elementsParType = handler.resultat();

        qDebug() << _elementsParType;
    }

    _horloge.setInterval(INTERVALLE_RAFRAICHISSEMENT_MODELE);

    connect(&_horloge, SIGNAL(timeout()), this, SLOT(ajouterBagageAleatoire()));
    connect(&_horloge, SIGNAL(timeout()), this, SLOT(maj()));
}
Exemplo n.º 7
0
XMLGenerator::XMLGenerator(const QString &baseDir)
{
    QList<QEngine*> qengines = QtEngines::self()->engines();
    foreach(QEngine *engine, qengines) {
        QString engineDir = engine->name();
        QString fileName = engineDir + "/" + "data.xml";

        if (!baseDir.isEmpty()) {
            engineDir = QString("%1/%2").arg(baseDir).arg(engineDir);
            fileName = QString("%1/%2").arg(baseDir).arg(fileName);
        }

        if (!QFile::exists(fileName))
            continue;


        XMLReader handler;
        QXmlSimpleReader reader;
        reader.setContentHandler(&handler);
        reader.setErrorHandler(&handler);

        QFile file(fileName);
        if (!file.open(QFile::ReadOnly | QFile::Text)) {
            qWarning("Cannot open file '%s', because: %s",
                     qPrintable(fileName), qPrintable(file.errorString()));
            continue;
        }

        QXmlInputSource xmlInputSource(&file);
        if (reader.parse(xmlInputSource)) {
            XMLEngine *engine = handler.xmlEngine();
            checkDirs(engine->generationDate, engineDir);
            engines.insert(engine->name, engine);
        }
    }
Exemplo n.º 8
0
void IsoCodesPrivate::buildIsoEntryList()
{
	loaded = true;

	QFile file(QString("%1/iso_%2.xml").arg(isoCodesXmlDir, isoCode));
	if( !file.open(QFile::ReadOnly | QFile::Text) ) {
		kError() << "Can't open the xml file" << file.fileName();
		return;
	}

	XmlHandler xmlHandler(isoCode, isoEntryList);

	QXmlSimpleReader reader;
	reader.setContentHandler(&xmlHandler);
	reader.setErrorHandler(&xmlHandler);

	QXmlInputSource xmlInputSource(&file);

	if( ! reader.parse(xmlInputSource) ) {
		kError() << "Failed to parse the xml file" << file.fileName();
		return;
	}

	kDebug() << "Loaded" << isoEntryList.count() << ("iso entry definitions for iso"+isoCode) << "from" << file.fileName();
}
Exemplo n.º 9
0
TrackReader::TrackReadResult TrackReader::loadTrackFile(const QUrl& url)
{
    // TODO: store some kind of error message
    TrackReadResult parsedData;
    parsedData.track.url = url;
    parsedData.isValid   = false;

    QFile file(url.toLocalFile());

    if (!file.open(QFile::ReadOnly | QFile::Text))
    {
        parsedData.loadError = i18n("Could not open: %1", file.errorString());
        return parsedData;
    }

    if (file.size() == 0)
    {
        parsedData.loadError = i18n("File is empty.");
        return parsedData;
    }

    // TODO: load the file
    TrackReader trackReader(&parsedData);
    QXmlSimpleReader reader;
    reader.setContentHandler(&trackReader);
    reader.setErrorHandler(&trackReader);
    QXmlInputSource xmlInputSource(&file);

    // TODO: error handling
    parsedData.isValid = reader.parse(xmlInputSource);

    if (!parsedData.isValid)
    {
        parsedData.loadError = i18n("Parsing error: %1", trackReader.errorString());
        return parsedData;
    }

    parsedData.isValid = !parsedData.track.points.isEmpty();

    if (!parsedData.isValid)
    {
        if (!trackReader.d->verifyFoundGPXElement)
        {
            parsedData.loadError = i18n("No GPX element found - probably not a GPX file.");
        }
        else
        {
            parsedData.loadError = i18n("File is a GPX file, but no datapoints were found.");
        }

        return parsedData;
    }

    // the correlation algorithm relies on sorted data, therefore sort now
    qSort(parsedData.track.points.begin(), parsedData.track.points.end(), TrackManager::TrackPoint::EarlierThan);

    return parsedData;
}
void Im2CharRectsCharDataReader::parseFiles(Document *pDocument, std::vector<ImageChar> &imageCharVec, std::vector<std::string> &charVec) const
{
	imageCharVec.clear(); charVec.clear();

	// load document images if not done yet:
	if (!pDocument->isDocumentImagesLoaded()) {
		pDocument->openDocumentImages();
	}
	// create XML filenames:
//	pDocument->createSegmentationResultFileNames();
	pDocument->createSegmentationResultFileNames("xml", pDocument->parsingParameters().filenamePrefix,  pDocument->parsingParameters().filenameSuffix);

	// create the finereader xml output handler object need for parsing the files
	Im2CharRectsXMLOutputHandler *pXMLHandler = new Im2CharRectsXMLOutputHandler();
	// create simple reader and set the content/error handler
    QXmlSimpleReader reader;
    reader.setContentHandler(pXMLHandler);
    reader.setErrorHandler(pXMLHandler);

    int parsedCharsCount = 0;
    for (int i=0; i < pDocument->nFiles(); ++i) {
    	const std::string& xmlFileName = pDocument->segmentationResultFileName(i);
    	// create QFile object
        QFile file( QString::fromStdString(xmlFileName) );
        if (!file.open(QFile::ReadOnly | QFile::Text)) {
        	throw Exception("Error openening xml-file in FRXMLCharDataReader::parseXMLFiles!");
        }
        // create xml input source from file object
        QXmlInputSource xmlInputSource(&file);
        // parse the file using the simple reader
        reader.parse(xmlInputSource);
        std::cout << "Successfully parsed xml data of file " << xmlFileName << std::endl;
    	// store results
        Im2CharRectsData* pData = pXMLHandler->parsedData();
        GrayImage<>* pImage = pDocument->imagePointer(i);
        for (int j=0; j<pData->parsedBBoxes.size(); ++j) {
        	ImageChar imChar(pData->parsedBBoxes[j], pImage, i, parsedCharsCount);
        	imChar.text = pData->parsedChars[j];
        	++parsedCharsCount;
        	imageCharVec.push_back(imChar);
        	charVec.push_back(pData->parsedChars[j]);

        } // end for j
        pXMLHandler->clearData();
    } // end for all xml files
    std::cout << "Successfully parsed " << pDocument->nFiles() << " xml files!" << std::endl;
    delete pXMLHandler;

	return;
}
Exemplo n.º 11
0
/**
  * TODO: Use a stream reader
  *
  */
void CAMProfileSettingsList::loadPreferences() {
    QString location = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + QDir::separator() + "rvtcam" + QDir::separator() + "profile.xml";

    QFile file(location);
    if (file.open(QIODevice::ReadOnly)) {
        camProfileDataModel->clear();
        CAMProfileDataParser parser(camProfileDataModel);
        QXmlSimpleReader reader;
        reader.setContentHandler(&parser);
        QXmlInputSource xmlInputSource(&file);
        reader.parse(xmlInputSource);
    }
    file.close();
}
Exemplo n.º 12
0
QtSkin::QtSkin(QFile& aFile) throw (QtSkinException)
		: pictureSize(-1, -1), screenRectangle(-1, -1, -1, -1), screenForeground(), screenBackground(), hShiftHeight(0),
		  numberFontSize(-1), exponentFontSize(-1), fontSize(-1), smallFontSize(-1),
		  keys(MAX_KEY_CODE, NULL), dotPainters(DOT_PAINTERS_COUNT, NULL), pastePainters(PASTE_PAINTERS_COUNT, NULL),
		  insertedKeys(0), insertedDotPainters(0), insertedPastePainters(0)
{
	pushHandlers(documentHandlers);
	characterMethodsStack.push(NULL);
	QXmlSimpleReader reader;
	reader.setContentHandler(this);
	reader.setErrorHandler(this);

    QXmlInputSource xmlInputSource(&aFile);
    if(!reader.parse(xmlInputSource) || !checkSkin())
    {
    	throw *(new QtSkinException(errorString()));
    }
}
Exemplo n.º 13
0
void AnnoqtConfEditor::loadAnnotationConfigurationFile(const QString& fileName)
{
  if (fileName.isEmpty())
      return;

  QFile file(fileName);
  if (!file.open(QFile::ReadOnly | QFile::Text)) {
      QMessageBox::warning(this, tr("Annotation Tool"),
                            tr("Cannot read file %1:\n%2.")
                            .arg(fileName)
                            .arg(file.errorString()));
      return;
  }

  m_currentAnnotationConfigurationFile = fileName;

  m_listWidget->clear();
  m_colors.clear();
  setWindowModified( false );

  QList<QString> recursiveEntityTypes;
  AnnotationConfigurationHandler handler(m_listWidget, &m_colors, &m_colorNames2EntityTypes, &recursiveEntityTypes, true);
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);

  QXmlInputSource xmlInputSource(&file);
  if (reader.parse(xmlInputSource))
      statusBar()->showMessage(tr("Annotation Configuration File loaded"), 2000);

  for (QMap<QString, QString>::const_iterator it=m_colorNames2EntityTypes.begin();
        it != m_colorNames2EntityTypes.end(); it++)
  {
    m_entityNames2Types.insert(it.value(),m_entityNames2Types.size());
    m_entityTypes2Names.insert(m_entityNames2Types.size()-1,it.value());
    m_entityTypes2ColorNames.insert(m_entityNames2Types[it.value()],it.key());
  }
  statusBar()->showMessage( tr( "Loaded configuration file " ) + fileName );
}
Exemplo n.º 14
0
void MainWindow::open()
{
#if defined(Q_OS_SYMBIAN)
    // Look for bookmarks on the same drive where the application is installed to,
    // if drive is not read only. QDesktopServices::DataLocation does this check,
    // and returns writable drive.
    QString bookmarksFolder =
        QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1);
    bookmarksFolder.append(":/Data/qt/saxbookmarks");
    QDir::setCurrent(bookmarksFolder);
#endif
    QString fileName =
        QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
                                     QDir::currentPath(),
                                     tr("XBEL Files (*.xbel *.xml)"));
    if (fileName.isEmpty())
        return;

    treeWidget->clear();

    XbelHandler handler(treeWidget);
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);

    QFile file(fileName);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
        QMessageBox::warning(this, tr("SAX Bookmarks"),
                             tr("Cannot read file %1:\n%2.")
                             .arg(fileName)
                             .arg(file.errorString()));
        return;
    }

    QXmlInputSource xmlInputSource(&file);
    if (reader.parse(xmlInputSource))
        statusBar()->showMessage(tr("File loaded"), 2000);
}
Exemplo n.º 15
0
void TimersModel::readTimers(const QString &file)
{
    TimersHandler *handler = new TimersHandler();

    QXmlSimpleReader reader;
    reader.setContentHandler(handler);
    reader.setErrorHandler(handler);

    QFile f(file);
    if (!f.open(QFile::ReadOnly | QFile::Text))
        return;

    QXmlInputSource xmlInputSource(&f);
    if (!reader.parse(xmlInputSource))
        return;

    QList<Timer *> timers = handler->timersList();
    for(int i = 0; i < timers.size(); i++) {
        appendRow(timers[i]);
    }

    delete handler;
}
Exemplo n.º 16
0
//bool Parser::parse(ParserTypes which, QFile &file, MusicCollection *collection) {
bool MusicCollectionIO::parse(QFile &file, MusicCollection *collection) {

  /*
  switch ( which ) {
  case ITUNES: {
  */
  iTunesXmlHandler parser(collection);
  QXmlSimpleReader reader;
  reader.setContentHandler(&parser);
  reader.setErrorHandler(&parser);

  QXmlInputSource xmlInputSource(&file);

  return reader.parse(xmlInputSource);
  /*
  }
  case MARCSV:
  case MARXML:
  default:
  	return false;
  }
  */
}
void FRXMLCharDataReader::parseFiles(Document *pDocument, std::vector<ImageChar> &imageCharVec, std::vector<std::string> &charVec) const
{
	imageCharVec.clear(); charVec.clear();

	// load document images if not done yet:
	if (!pDocument->isDocumentImagesLoaded()) {
		std::cout << "opening document images" << std::endl;
		pDocument->openDocumentImages();
	}
	// create XML filenames:
//	pDocument->createSegmentationResultFileNames();
	pDocument->createSegmentationResultFileNames("xml", pDocument->parsingParameters().filenamePrefix,  pDocument->parsingParameters().filenameSuffix);

	// create the finereader xml output handler object need for parsing the files
	FineReaderXMLOutputHandler *pXMLHandler = new FineReaderXMLOutputHandler();
	// create simple reader and set the content/error handler
    QXmlSimpleReader reader;
    reader.setContentHandler(pXMLHandler);
    reader.setErrorHandler(pXMLHandler);

    int parsedCharsCount = 0;
    for (int i=0; i < pDocument->nFiles(); ++i) {
    	const std::string& xmlFileName = pDocument->segmentationResultFileName(i);
    	// create QFile object
        QFile file( QString::fromStdString(xmlFileName) );
        if (!file.open(QFile::ReadOnly | QFile::Text)) {
        	throw Exception("Error openening xml-file in FRXMLCharDataReader::parseXMLFiles!");
        }
        // create xml input source from file object
        QXmlInputSource xmlInputSource(&file);
        // parse the file using the simple reader
        reader.parse(xmlInputSource);
        std::cout << "Successfully parsed xml data of file " << xmlFileName << std::endl;
    	// store results
        SimpleFineReaderXMLData* pData = pXMLHandler->getFineReaderData();
        GrayImage<>* pImage = pDocument->imagePointer(i);
//        const int pType = pDocument->parsingParameters().parsingType;
        const ParseSubsetType pType = pDocument->parsingParameters().parsingType;
        std::cout << "Parsing type is: " << pType << std::endl;
        for (int j=0; j<pData->parsedBBoxes.size(); ++j) {
        	ImageChar imChar(pData->parsedBBoxes[j], pImage, i, parsedCharsCount);
        	imChar.text = pData->parsedChars[j];
        	imChar.suspicious = pData->isSuspicious[j];
        	//        	std::cout << "isSusp = " << imChar.suspicious << std::endl;
			// add imagechar to list, depending on parsing type:
        	// 0-->parse all chars, 1-->parse all non-susp. chars, 2-->parse all susp. chars

        	if (pType == UNKNOWN_PARSESUBSET_TYPE) {
        		throw Exception("An invalid parsing type was given!");
        	}
        	else if ((pType == 0) || (pType == PARSE_ONLY_NON_SUSP && !imChar.suspicious) || (pType == PARSE_ONLY_SUSP && imChar.suspicious)) {
				++parsedCharsCount;
				imageCharVec.push_back(imChar);
				charVec.push_back(pData->parsedChars[j]);
			}
        	else if (pType == PARSE_SUBSET) {

        	}
        } // end for j
        pXMLHandler->clearData();
    } // end for all xml files
    std::cout << "Successfully parsed " << pDocument->nFiles() << " xml files!" << std::endl;
    delete pXMLHandler;

	return;
} // end parseXMLFiles
Exemplo n.º 18
0
void MainWindow::queueStepBegin()
{
    if(queue.isEmpty()) return;

    currentAct = queue.dequeue();

    switch(currentAct.type)
    {
    case ACT_LOCK_CONFIG_PAGE:
        qDebug() << "ACT: lock config page";
        ui->refresh->setEnabled(false);
        statusBar()->clearMessage();
        cancelStatusBarButton->hide();
        ui->progressBar->show();
        queueStepBegin();
        break;

    case ACT_DOWNLOAD_FILE:
        qDebug() << "ACT: Download file" << currentAct.param1 << currentAct.param2 << currentAct.param3;
        curstep++;
        downloader.downloadFile(currentAct.param1, currentAct.param2);
        statusBar()->showMessage(tr("Step %1/%2 Downloading file %3...").arg(curstep).arg(totalSteps).arg(currentAct.param1));
        cancelStatusBarButton->show();
        break;

    case ACT_PARSE_CPACK_LIST_XML:
    {
        qDebug() << "ACT: parse XML file";
        XMLCpackList handler;
        QXmlSimpleReader reader;
        reader.setContentHandler(&handler);
        reader.setErrorHandler(&handler);
        QFile file(tempDir + "/configs.index");

        if(!file.open(QFile::ReadOnly | QFile::Text))
        {
            queueStepBegin();
            break;
        }

        QXmlInputSource xmlInputSource(&file);

        if(reader.parse(xmlInputSource))
        {}

        queueStepBegin();
    }
    break;

    case ACT_REBUILD_CPACK_LIST:
        buildConfigPackList();
        queueStepBegin();
        break;

    case ACT_UNLOCK_CONFIG_PAGE:
        qDebug() << "ACT: unlock config page";
        ui->refresh->setEnabled(true);
        ui->progressBar->hide();
        cancelStatusBarButton->hide();
        queueStepBegin();
        break;

    case ACT_SHOWMSG:
        qDebug() << "ACT: show msg" << currentAct.param1 << currentAct.param2;
        statusBar()->showMessage(currentAct.param1, currentAct.param2.toInt());
        queueStepBegin();
        break;

    default:
        queueStepBegin();
        break;
    }
}
Exemplo n.º 19
0
Engine::Engine(QFileInfo& fileAlbum) throw(EngineException*) :
    m_dirty(false),
    m_fileAlbum(new QFileInfo(fileAlbum)),
    m_uid(0),

    m_fileSystemScanner(new FileSystemScanner(this)),

    m_nextSourceDirId(1),
    m_sourceDirDict(new QIntDict<Folder>()),
    m_sourceDirs(new QPtrList<Folder>()),

    m_nextTagNodeId(1),
    m_tagNodeDict(new QIntDict<TagNode>()),
    m_tagForest(new QPtrList<TagNode>()),
    m_exifTitleTag(0),

    m_fileDict(new QDict<File>()),
    m_fileList(new QPtrList<File>()),
    m_fileList2display(new QPtrList<File>())
{
    tracer->sinvoked(__func__) << "with file '" << m_fileAlbum->absFilePath() << "'" << endl;

    // if file does not exist, we have nothing to do
    //if (!m_fileAlbum->exists()) {
        QString msg = QString("File '%1' does not exist.").arg(m_fileAlbum->absFilePath());
        tracer->serror(__func__) << msg << endl;
        throw new EngineException(msg, "no detailmessage");
    //}

    QFile file(m_fileAlbum->absFilePath());

    // close the file if it is open already
    if (file.isOpen()) {
        file.close();
    }

    // open the file for reading
    if (!file.open( IO_ReadOnly )) {
        QString msg = QString("Could not open file '%1'.").arg(file.name());
        tracer->serror(__func__) << msg << ": " << file.errorString() << endl;
        throw new EngineException(msg, file.errorString());
    }

    // prepare input source
    QXmlInputSource xmlInputSource(file);

    // instantiate the parser
    XmlParser parser = XmlParser(this);

    // prepare the xml reader
    QXmlSimpleReader reader;

    // set the handler on the reader
    reader.setContentHandler(&parser);
    reader.setErrorHandler(&parser);

    // parse the document
    bool success = reader.parse(&xmlInputSource, false);

    // close the file
    file.close();

    if (!success) {
        tracer->serror(__func__) << "Error occured during parsing the file '" << file.name() << "'" << endl;

        cleanUp();
        if (parser.exception()) {
            tracer->serror(__func__) << "exception occured: " << parser.exception()->message() << endl;

            throw parser.exception();
        } else {
            throw new EngineException(i18n("Unknown error while parsing the xml file occured!"));
        }
    }

    // generate a uid if the file does not contain one (for compatibility reason with version 0.0.5)
    if (!m_uid) {
        m_uid = generateUid();
    }

    // create the EXIF tagnode if it was not contained in the database (for compatibility reason with version 0.0.6)
    if (m_exifTitleTag == 0) {
        createExifTagNode();
    }

    // read the files in all sourcedirectories
    if (Settings::generalRescanWhileStartup()) {
        m_fileSystemScanner->rescan();
    }

    // trace a little
    tracer->sdebug(__func__) << m_fileList->count() << " images added" << endl;
}