Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

mpsi.cpp

Go to the documentation of this file.
00001 /*
00002  Modular Psi - A graph tracker of the Parapsychologcal scientific development
00003  Copyright (C) 2005 Leonardo Stern
00004 
00005  This program is free software; you can redistribute it and/or modify it under
00006  the terms of the Common Public License Version 1.0 or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00009  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  See the Common Public License for more details.
00011 
00012  You should have received a copy of the Common Public License along with this program;
00013 */
00014 
00015 
00016 #include "mpsi.hpp"
00017 #include "core/category.hpp"
00018 #include "../edgelist.hpp"
00019 #include <qfile.h>
00020 #include <qregexp.h>
00021 #include <qiodevice.h>
00022 #include <qxml.h>
00023 
00024 Mpsi::Mpsi(PropositionGraph* cl, QString pn)
00025 {
00026    caller = cl;
00027    pname = pn;
00028 }
00029 
00030 Mpsi::~Mpsi()
00031 {
00032 }
00033 
00034 
00035 bool Mpsi::startElement(const QString &, const QString &,
00036                               const QString &qName,
00037                               const QXmlAttributes &attribs)
00038 {
00039         if (qName == "edge") {
00040                 target = attribs.value("target");
00041         }
00042         currentText ="";
00043     return true;
00044 }
00045 
00046 bool Mpsi::characters(const QString &str)
00047 {
00048     currentText += str;
00049     return true;
00050 }
00051 
00052 bool Mpsi::endElement(const QString &, const QString &,
00053                             const QString &qName)
00054 {
00055     if (qName == "name") {
00056         caller->operator[](pname)->setPublicName(currentText);
00057     } else if (qName == "description") {
00058         caller->operator[](pname)->setDescription(currentText);
00059     } else if (qName == "category") {
00060         caller->operator[](pname)->setCategoryId(currentText);
00061     } else if (qName == "references") {
00062         caller->operator[](pname)->setReferences(currentText);
00063     } else if (qName == "edge") {
00064 //      e = caller->connect(pname,target);
00065     } else if (qName == "trust") {
00066         e = caller->connect(pname,target,currentText);
00067 //      e->setTrust(currentText);
00068 //              e->setTrust("1.0");
00069     }
00070     return true;
00071 }
00072 
00073 bool Mpsi::fatalError(const QXmlParseException &exception)
00074 {
00075     qWarning("Line %d, column %d: %s", exception.lineNumber(),
00076              exception.columnNumber(), exception.message().ascii());
00077 
00078     return false;
00079 
00080 }
00081 
00082 void Mpsi::ioError(const QFile file, const QString message)
00083 {
00084     caller->error(file.name() + message + ": " + file.errorString());
00085 }
Untitled Document Pesquisa Psi SourceForge.net Logo