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

cat.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 "cat.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 Cat::Cat(PropositionGraph* cl)
00025 {
00026    caller = cl;
00027 }
00028 
00029 Cat::~Cat()
00030 {
00031 }
00032 
00033 
00034 bool Cat::startElement(const QString &, const QString &,
00035                               const QString &qName,
00036                               const QXmlAttributes &attribs)
00037 {
00038         if (qName == "category") {
00039                 current = new Category();
00040         }
00041         currentText ="";
00042     return true;
00043 }
00044 
00045 bool Cat::characters(const QString &str)
00046 {
00047     currentText += str;
00048     return true;
00049 }
00050 
00051 bool Cat::endElement(const QString &, const QString &,
00052                             const QString &qName)
00053 {
00054      if (qName == "id") {
00055         current->setId(currentText);
00056     } else if (qName == "name") {
00057         current->setName(currentText);
00058     } else if (qName == "color") {
00059                 QRegExp rz("(\\d*),(\\d*),(\\d*)");
00060                 rz.search(currentText);
00061                 current->setColor(QColor(rz.cap(1).toInt(),rz.cap(2).toInt(),rz.cap(3).toInt()));
00062     } else if (qName == "description") {
00063                 current->setDescription(currentText);
00064     } else if (qName == "category") {
00065         caller->categories->insert(current->name(), current);
00066     }
00067     return true;
00068 }
00069 
00070 bool Cat::fatalError(const QXmlParseException &exception)
00071 {
00072     qWarning("Line %d, column %d: %s", exception.lineNumber(),
00073              exception.columnNumber(), exception.message().ascii());
00074 
00075     return false;
00076 
00077 }
00078 
00079 void Cat::ioError(const QFile file, const QString message)
00080 {
00081     caller->error(file.name() + message + ": " + file.errorString());
00082 }
Untitled Document Pesquisa Psi SourceForge.net Logo