-rw-r--r-- | core/pim/datebook/holiday/national/nationalcfg.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/holiday/national/nationalcfg.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/datebook/holiday/national/nationalcfg.cpp b/core/pim/datebook/holiday/national/nationalcfg.cpp index 33e9db3..5e8ec29 100644 --- a/core/pim/datebook/holiday/national/nationalcfg.cpp +++ b/core/pim/datebook/holiday/national/nationalcfg.cpp @@ -183,189 +183,189 @@ bool NHcfg::parsevalue(const QString&name,const QXmlAttributes&attr) if (e.count()!=2){err=QString("Datestring %1 is invalid (entry %2)").arg(dstring).arg(counter);return false;}
QDate d(0,e[0].toInt(),e[1].toInt());
m_currentEntry.setDate(d);
return true;
}
bool NHcfg::parseCalc(const QString&name,const QXmlAttributes&attr)
{
++level;
int vindex = attr.index(_content_value);
if (vindex == -1) {
err = QString("Value for element %1 on entry %2 is missing").arg(name).arg(counter);
return false;
}
int what_c =0;
QString what = name.lower();
QString value;
if (what == _content_date) {
what_c = 1;
} else if (what == _content_weekd) {
what_c = 2;
} else if (what == _content_offset) {
what_c = 3;
} else if (what == _content_dayofmonth) {
what_c = 4;
} else if (what == _content_datedep) {
what_c = 5;
} else if (what == _content_month) {
what_c = 6;
}
if (what_c == 0) {
err = QString("Unknown element %1 on entry %2").arg(name).arg(counter);
return false;
}
value = attr.value(vindex).lower();
QStringList e;
QDate d;
bool dotformat = false;
switch (what_c) {
case 1:
if (value != "easter") {
e = QStringList::split("-",value);
if (e.count()!=2) {
e = QStringList::split(".",value);
dotformat = true;
}
if (e.count()!=2){err=QString("Datestring %1 is invalid (entry %2)").arg(value).arg(counter);return false;}
if (!dotformat) {
d=QDate(0,e[0].toInt(),e[1].toInt());
} else {
d=QDate(0,e[1].toInt(),e[0].toInt());
}
} else {
d=QDate(9999,1,1);
}
m_currentEntry.setDate(d);
break;
case 2:
m_currentEntry.setWeekday(value);
break;
case 3:
m_currentEntry.setOffet(value.toInt());
break;
case 4:
m_currentEntry.setDayofmonth(value);
break;
case 5:
m_currentEntry.setDaydep(value);
break;
case 6:
m_currentEntry.setMonth(value);
break;
}
return true;
}
bool NHcfg::endElement(const QString&, const QString&,const QString& name)
{
// odebug << "End element: " << name << oendl;
if (name==_key_entry) {
if (m_currentEntry.type()==NHentry::fix) {
currentFixList.append(m_currentEntry);
} else {
currentFloatList.append(m_currentEntry);
// odebug << "Floatlist count " << currentFloatList.count() << oendl;
}
} else if (name==_key_calc) {
}
if (stage>=3) {
--level;
}
// odebug << "Level == " << level << oendl;
return true;
}
-QString NHcfg::errorString() const
+QString NHcfg::errorString()
{
return err;
}
NHentry::NHentry()
:m_Type(fix)
{
m_Offset=0;
}
NHentry::~NHentry()
{}
void NHentry::setName(const QString&aName)
{
m_Name = aName;
}
const QString&NHentry::name()const
{
return m_Name;
}
void NHentry::setType(NHentry::entry_type aType)
{
m_Type = aType;
}
NHentry::entry_type NHentry::type()const
{
return m_Type;
}
void NHentry::setDate(const QDate&aDate)
{
m_Date = aDate;
}
const QDate&NHentry::date()const
{
return m_Date;
}
void NHentry::setWeekday(const QString&aDay)
{
m_Weekday = aDay;
}
const QString&NHentry::weekday()const
{
return m_Weekday;
}
void NHentry::setDayofmonth(const QString&aDay)
{
m_Dayofmonth = aDay;
}
const QString&NHentry::dayofmonth()const
{
return m_Dayofmonth;
}
void NHentry::setDaydep(const QString&dep)
{
m_Depth = dep;
}
const QString&NHentry::daydep()const
{
return m_Depth;
}
void NHentry::setMonth(const QString&month)
{
m_Month = month;
}
const QString&NHentry::month()const
{
return m_Month;
}
void NHentry::setOffet(int aOffset)
{
m_Offset = aOffset;
}
const int NHentry::offset()const
{
return m_Offset;
}
diff --git a/core/pim/datebook/holiday/national/nationalcfg.h b/core/pim/datebook/holiday/national/nationalcfg.h index 2aedd95..28e1fdd 100644 --- a/core/pim/datebook/holiday/national/nationalcfg.h +++ b/core/pim/datebook/holiday/national/nationalcfg.h @@ -1,75 +1,75 @@ #ifndef _NATIONAL_CFG_H
#define _NATIONAL_CFG_H
#include <qxml.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <qmap.h>
#include <qdatetime.h>
typedef QMap<QDate,QStringList> tholidaylist;
class NHentry
{
public:
enum entry_type{fix,floating};
NHentry();
virtual ~NHentry();
void setName(const QString&);
const QString&name()const;
void setType(entry_type);
entry_type type()const;
void setDate(const QDate&);
const QDate&date()const;
void setWeekday(const QString&);
const QString&weekday()const;
void setDayofmonth(const QString&);
const QString&dayofmonth()const;
void setDaydep(const QString&);
const QString&daydep()const;
void setMonth(const QString&);
const QString&month()const;
void setOffet(int);
const int offset()const;
protected:
entry_type m_Type;
QString m_Name,m_Weekday,m_Dayofmonth,m_Depth,m_Month;
QDate m_Date;
int m_Offset;
};
typedef QValueList<NHentry> tentrylist;
class NHcfg:public QXmlDefaultHandler
{
public:
NHcfg();
virtual ~NHcfg();
bool load(const QString&);
const tentrylist&fixDates()const;
const tentrylist&floatingDates()const;
virtual bool warning(const QXmlParseException& e);
virtual bool error(const QXmlParseException& e);
virtual bool fatalError(const QXmlParseException& e);
virtual bool startElement(const QString&, const QString&,const QString& name, const QXmlAttributes& attr);
virtual bool endElement(const QString&, const QString&,const QString& name);
- virtual QString errorString()const;
+ virtual QString errorString();
protected:
QString err,_contentname;
QString _path;
NHentry m_currentEntry;
bool setName(const QXmlAttributes&);
bool parsevalue(const QString&,const QXmlAttributes&);
bool parseCalc(const QString&,const QXmlAttributes&);
int stage,counter,level;
tentrylist currentFloatList,currentFixList;
};
#endif
|