Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > media > contrib-release-debug > by-pkgid > 0b102c0e3d0c39a3855aaf976204ce5c > files > 40

associationsubscribersmanager-debug-3.2.0-2mdv2011.0.i586.rpm


//  Copyright (C) 2009 by Arnaud Dupuis
//  a.dupuis@infinityperl.org
//  http://www.infinityperl.org
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the
//  Free Software Foundation, Inc.,
//  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

#ifndef ADBHANDLER_H
#define ADBHANDLER_H

#include <QXmlDefaultHandler>
#include <QMap>
class QString;
class QTreeWidget;
class QTreeWidgetItem;
/*! \class AdbHandler
* \brief the XML handler for the database files.
*
* This class is the XML handler for the Association Subscribers Manager's database files.
* 
*/
class AdbHandler : public QXmlDefaultHandler
{
	public:
		/*!
		Constructs a new handler.
		*/
		AdbHandler( QTreeWidget* );
		/*!
		The reader calls this function when it has parsed a start element tag.

		There is a corresponding endElement() call when the corresponding end element tag is read. The startElement() and endElement() calls are always nested correctly. Empty element tags (e.g. <x/>) cause a startElement() call to be immediately followed by an endElement() call.

		The attribute list provided only contains attributes with explicit values. The attribute list contains attributes used for namespace declaration (i.e. attributes starting with xmlns) only if the namespace-prefix property of the reader is true.

		The argument namespaceURI is the namespace URI, or an empty string if the element has no namespace URI or if no namespace processing is done. localName is the local name (without prefix), or an empty string if no namespace processing is done, qName is the qualified name (with prefix) and atts are the attributes attached to the element. If there are no attributes, atts is an empty attributes object.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		\sa endElement
		*/
		bool startElement( const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes );
		/*!
		The reader calls this function when it has parsed an end element tag with the qualified name qName, the local name localName and the namespace URI namespaceURI.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		*/
		bool endElement( const QString &namespaceURI, const QString &localName, const QString &qName );
		/*!
		The reader calls this function when it has parsed a chunk of character data (either normal character data or character data inside a CDATA section; if you need to distinguish between those two types you must use QXmlLexicalHandler::startCDATA() and QXmlLexicalHandler::endCDATA()). The character data is reported in ch.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		*/
		bool characters(const QString &str);
		/*!
		A reader must use this function to report a non-recoverable error. Details of the error are stored in exception.

		If this function returns true the reader might try to go on parsing and reporting further errors, but no regular parsing events are reported.
		*/
		bool fatalError(const QXmlParseException &exception);
		/*!
		Return the embded serialized courses list.
		*/
		QString getCoursesList();
		/*!
		Return the embded static cost.
		*/
		QString getStaticCost();
		/*!
		Return the embded trimester count.
		*/
		QString getTrimesterCount();
		/*!
		Return the embded federation name.
		*/
		QString getFederationName();
		/*!
		The reader calls this function to get an error string, e.g. if any of the handler functions returns false.
		*/
		QString errorString() const;
		/*!
		Set the map that will be used to convert custom fields ids into column labels.
		*/
		void setCustomFieldsMap( const QMap<QString,QString> & );
	private:
		enum ParserError {
			AdbVersionMismatch,
		};
		ParserError m_error;
		int elementColumn(const QString&);
		QString currentText;
		bool currentPictureIsEmbed;
		QTreeWidget *treeWidget;
		QTreeWidgetItem *currentItem;
		QString coursesList;
		QString trimesterCount;
		QString staticCost;
		QString federationName;
		QMap<QString,QString>m_cfMap;
		QString m_cfCurrentId;
};

#endif