summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-06-15 16:46:37 (UTC)
committer zecke <zecke>2002-06-15 16:46:37 (UTC)
commitff47b17768607d8819ef5cd3316a1cab0abdcf3a (patch) (side-by-side diff)
treeaddbc4d7d8826ce2952aca872e67e3575d77cda7 /libopie
parent9f41969610f9db5d60d6080abae0b21e54a549e2 (diff)
downloadopie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.zip
opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.gz
opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.bz2
Summary support
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/tododb.cpp4
-rw-r--r--libopie/todoevent.cpp35
-rw-r--r--libopie/todoevent.h59
-rw-r--r--libopie/todovcalresource.cpp7
4 files changed, 101 insertions, 4 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index fe8b8bf..6b10ec2 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -10,22 +10,24 @@ using namespace Opie;
namespace {
class FileToDoResource : public ToDoResource {
public:
FileToDoResource() {};
+ // FIXME better parsing
bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
// prepare the XML
XMLElement *tasks = new XMLElement( );
tasks->setTagName("Tasks" );
for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){
XMLElement::AttributeMap map;
XMLElement *task = new XMLElement();
map.insert( "Completed", QString::number((int)(*it).isCompleted() ) );
map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
map.insert( "Priority", QString::number( (*it).priority() ) );
+ map.insert( "Summary", (*it).summary() );
QArray<int> arrat = (*it).categories();
QString attr;
for(uint i=0; i < arrat.count(); i++ ){
attr.append(QString::number(arrat[i])+";" );
}
if(!attr.isEmpty() ) // remove the last ;
@@ -108,12 +110,14 @@ public:
dumInt = dummy.toInt(&ok );
if(!ok ) dumInt = ToDoEvent::NORMAL;
event.setPriority( dumInt );
//description
dummy = element->attribute("Description" );
event.setDescription( dummy );
+ dummy = element->attribute("Summary" );
+ event.setSummary( dummy );
// category
dummy = element->attribute("Categories" );
QStringList ids = QStringList::split(";", dummy );
event.setCategories( ids );
//uid
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index aa348a2..fb7073c 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -14,20 +14,24 @@
ToDoEvent::ToDoEvent(const ToDoEvent &event )
{
*this = event;
}
-ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
- const QString &description, bool hasDate, QDate date, int uid )
+ToDoEvent::ToDoEvent(bool completed, int priority,
+ const QStringList &category,
+ const QString& summary,
+ const QString &description,
+ bool hasDate, QDate date, int uid )
{
m_date = date;
m_isCompleted = completed;
m_hasDate = hasDate;
m_priority = priority;
m_category = category;
+ m_sum = summary;
m_desc = Qtopia::simplifyMultiLineSpace(description );
if (uid == -1 ) {
Qtopia::UidGen *uidgen = new Qtopia::UidGen();
uid = uidgen->generate();
delete uidgen;
}// generate the ids
@@ -63,12 +67,20 @@ int ToDoEvent::priority()const
return m_priority;
}
QStringList ToDoEvent::allCategories()const
{
return m_category;
}
+QString ToDoEvent::extra(const QString& )const
+{
+ return QString::null;
+}
+QString ToDoEvent::summary() const
+{
+ return m_sum;
+}
void ToDoEvent::insertCategory(const QString &str )
{
m_category.append( str );
}
void ToDoEvent::clearCategories()
{
@@ -96,12 +108,20 @@ void ToDoEvent::setHasDate( bool hasDate )
m_hasDate = hasDate;
}
void ToDoEvent::setDescription(const QString &desc )
{
m_desc = Qtopia::simplifyMultiLineSpace(desc );
}
+void ToDoEvent::setExtra( const QString&, const QString& )
+{
+
+}
+void ToDoEvent::setSummary( const QString& sum )
+{
+ m_sum = sum;
+}
void ToDoEvent::setCategory( const QString &cat )
{
qWarning("setCategory %s", cat.latin1() );
m_category.clear();
m_category << cat;
}
@@ -127,12 +147,14 @@ QString ToDoEvent::richText() const
{
QString text;
QStringList catlist;
// Description of the todo
if ( !description().isEmpty() ){
+ text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
+ text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
text += "<b>" + QObject::tr( "Priority:") +" </b>"
+ QString::number( priority() ) + "<br>";
if (hasDate() ){
@@ -212,25 +234,32 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
}
}
return true;
}
bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
{
- if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_desc )
+ if( m_priority == toDoEvent.m_priority &&
+ m_isCompleted == toDoEvent.m_isCompleted &&
+ m_hasDate == toDoEvent.m_hasDate &&
+ m_date == toDoEvent.m_date &&
+ m_category == toDoEvent.m_category &&
+ m_sum == toDoEvent.m_sum &&
+ m_desc == toDoEvent.m_desc )
return true;
return false;
}
ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
{
m_date = item.m_date;
m_isCompleted = item.m_isCompleted;
m_hasDate = item.m_hasDate;
m_priority = item.m_priority;
m_category = item.m_category;
m_desc = item.m_desc;
m_uid = item.m_uid;
+ m_sum = item.m_sum;
return *this;
}
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index 8a00f99..7454241 100644
--- a/libopie/todoevent.h
+++ b/libopie/todoevent.h
@@ -1,10 +1,11 @@
#ifndef todoevent_h
#define todoevent_h
+#include <qmap.h>
#include <qregexp.h>
#include <qstringlist.h>
#include <qdatetime.h>
class ToDoEvent {
friend class ToDoDB;
@@ -12,19 +13,21 @@ class ToDoEvent {
// priorities from Very low to very high
enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW };
/* Constructs a new ToDoEvent
@param completed Is the TodoEvent completed
@param priority What is the priority of this ToDoEvent
@param category Which category does it belong( uid )
+ @param summary A small summary of the todo
@param description What is this ToDoEvent about
@param hasDate Does this Event got a deadline
@param date what is the deadline?
@param uid what is the UUID of this Event
**/
ToDoEvent( bool completed = false, int priority = NORMAL,
const QStringList &category = QStringList(),
+ const QString &summary = QString::null ,
const QString &description = QString::null ,
bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 );
/* Copy c'tor
**/
ToDoEvent(const ToDoEvent & );
@@ -40,33 +43,87 @@ class ToDoEvent {
bool hasDate() const;
/*
What is the priority?
**/
int priority()const ;
+
+ /*
+ All category numbers as QString in a List
+ **/
QStringList allCategories()const;
+
+ /*
+ * Same as above but with QArray<int>
+ */
QArray<int> categories() const;
+
+ /**
+ * The end Date
+ */
QDate date()const;
+
+ /**
+ * The description of the todo
+ */
QString description()const;
+ /**
+ * A small summary of the todo
+ */
+ QString summary() const;
+
+ /**
+ * Return this todoevent in a RichText formatted QString
+ */
QString richText() const;
+ /**
+ * Returns the UID of the Todo
+ */
int uid()const { return m_uid;};
+
+
+ QString extra(const QString& )const;
+ /**
+ * Set if this Todo is completed
+ */
void setCompleted(bool completed );
+
+ /**
+ * set if this todo got an end data
+ */
void setHasDate( bool hasDate );
// if the category doesn't exist we will create it
// this sets the the Category after this call category will be the only category
void setCategory( const QString &category );
// adds a category to the Categories of this event
void insertCategory(const QString &category );
+
+ /**
+ * Removes this event from all categories
+ */
void clearCategories();
+
+ /**
+ * This todo belongs to xxx categories
+ */
void setCategories(const QStringList& );
+ /**
+ * Set the priority of the Todo
+ */
void setPriority(int priority );
+
+ /**
+ * set the end date
+ */
void setDate( QDate date );
void setDescription(const QString& );
+ void setSummary(const QString& );
+ void setExtra( const QString&, const QString& );
bool isOverdue();
bool match( const QRegExp &r )const;
void setUid(int id) {m_uid = id; };
bool operator<(const ToDoEvent &toDoEvent )const;
@@ -82,11 +139,13 @@ class ToDoEvent {
QDate m_date;
bool m_isCompleted:1;
bool m_hasDate:1;
int m_priority;
QStringList m_category;
QString m_desc;
+ QString m_sum;
+ QMap<QString, QString> m_extra;
int m_uid;
};
#endif
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
index 75f2197..80f8c60 100644
--- a/libopie/todovcalresource.cpp
+++ b/libopie/todovcalresource.cpp
@@ -47,13 +47,13 @@ static VObject *vobjByEvent( const ToDoEvent &event )
addPropValue( task, VCStatusProp, "COMPLETED");
QString string = QString::number(event.priority() );
addPropValue( task, VCPriorityProp, string.local8Bit() );
addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() );
addPropValue( task, VCDescriptionProp, event.description().local8Bit() );
- addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() );
+ addPropValue( task, VCSummaryProp, event.summary().left(15).local8Bit() );
return task;
};
static ToDoEvent eventByVObj( VObject *obj ){
ToDoEvent event;
VObject *ob;
@@ -61,12 +61,17 @@ static ToDoEvent eventByVObj( VObject *obj ){
// no uid, attendees, ... and no fun
// description
if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
name = vObjectStringZValue( ob );
event.setDescription( name );
}
+ // summary
+ if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
+ name = vObjectStringZValue( ob );
+ event.setSummary( name );
+ }
// completed
if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
name = vObjectStringZValue( ob );
if( name == "COMPLETED" ){
event.setCompleted( true );
}else{