From ff47b17768607d8819ef5cd3316a1cab0abdcf3a Mon Sep 17 00:00:00 2001 From: zecke Date: Sat, 15 Jun 2002 16:46:37 +0000 Subject: Summary support --- diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index b7b1da0..1358f1c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -594,7 +594,7 @@ void TodoWindow::slotBeam() todoDB.save(); Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); - QString description = c.description(); + QString description = c.summary(); ir->send( beamfile, description, "text/x-vCalendar" ); } diff --git a/core/pim/todo/todoentry.ui b/core/pim/todo/todoentry.ui index c735e76..87ee68c 100644 --- a/core/pim/todo/todoentry.ui +++ b/core/pim/todo/todoentry.ui @@ -30,7 +30,7 @@ 0 0 - 249 + 245 321 @@ -44,192 +44,252 @@ layoutSpacing - + + QLayoutWidget - margin - 0 + name + Layout3 - spacing - 0 + geometry + + 1 + 25 + 243 + 17 + - - QLayoutWidget + - name - Layout4 + margin + 0 - + + spacing + 6 + + + QLabel - margin - 0 + name + TextLabel3 - spacing - 6 + frameShape + NoFrame - - QLabel + + text + Category: + + + + CategorySelect + + name + comboCategory + + + + + + QLayoutWidget + + name + Layout6 + + + geometry + + 0 + 0 + 240 + 320 + + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout4 + + - name - TextLabel2 + margin + 0 - text - Priority: + spacing + 6 - - - QComboBox - - - text - 1 - Very High + + QLabel + + name + TextLabel1 - - - + text - 2 - High + Summary: - - - - text - 3 - Normal - - - - - text - 4 - Low - - - - - text - 5 - Very Low + + + QLineEdit + + name + lneSum - - - name - comboPriority - - - sizePolicy - - 7 - 0 - - - - currentItem - 2 - - - - - - QLayoutWidget - - name - Layout3 - - + + + + + QMultiLineEdit - margin - 0 + name + txtTodo + + + QLayoutWidget - spacing - 6 + name + Layout4 - - QLabel - - name - TextLabel3 - - - frameShape - NoFrame - + - text - Category: + margin + 0 - - - CategorySelect - name - comboCategory + spacing + 6 - - - - - QLayoutWidget - - name - Layout4 - - - - margin - 0 - + + QCheckBox + + name + checkCompleted + + + text + &Completed + + + + QCheckBox + + name + checkDate + + + text + D&ue + + + + QPushButton + + name + buttonDate + + + enabled + false + + + text + 1 Jan 2001 + + + + + + QLayoutWidget - spacing - 6 + name + Layout4 - - QCheckBox - - name - checkCompleted - + - text - &Completed + margin + 0 - - - QCheckBox - name - checkDate + spacing + 6 - - text - D&ue - - - - QPushButton - - name - buttonDate - - - enabled - false - - - text - 1 Jan 2001 - - - - - - QMultiLineEdit - - name - txtTodo - - - + + QLabel + + name + TextLabel2 + + + text + Priority: + + + + QComboBox + + + text + 1 - Very High + + + + + text + 2 - High + + + + + text + 3 - Normal + + + + + text + 4 - Low + + + + + text + 5 - Very Low + + + + name + comboPriority + + + sizePolicy + + 7 + 0 + + + + currentItem + 2 + + + + + + diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index 26a685c..dfaf9b4 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp @@ -1,5 +1,6 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2002 zecke ** ** This file is part of Qtopia Environment. ** @@ -61,6 +62,7 @@ NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, buttonDate->setText( TimeString::longDateString( date ) ); txtTodo->setText( task.description() ); + lneSum->setText( task.summary() ); } /* @@ -130,9 +132,10 @@ ToDoEvent NewTaskDialog::todoEntry() } todo.setPriority( comboPriority->currentItem() + 1 ); todo.setCompleted( checkCompleted->isChecked() ); - + todo.setDescription( txtTodo->text() ); - + todo.setSummary( lneSum->text() ); + return todo; } diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 52a3087..779b28c 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp @@ -572,6 +572,7 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) attr.remove(attr.length()-1, 1 ); buf += " Categories=\"" + attr + "\""; buf += " Description=\"" + todo.description() + "\""; + buf += " Summary=\"" + todo.summary() + "\""; if(todo.hasDate() ) { buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; @@ -610,8 +611,11 @@ void TodoTable::loadFile( const QString &/*we use the standard*/ ) void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) { - QString strTodo; - strTodo = todo.description().left(40).simplifyWhiteSpace(); + QString strTodo = todo.summary(); + if( strTodo.isEmpty() ){ + strTodo = todo.description().left(40).simplifyWhiteSpace(); + //todo.setSummary(strTodo ); + } if ( row == -1 ) { QMapIterator it; for ( it = todoList.begin(); it != todoList.end(); ++it ) { @@ -908,6 +912,9 @@ static ToDoEvent xmlToEvent( XMLElement *element ) //description dummy = element->attribute("Description" ); event.setDescription( dummy ); + // summary + dummy = element->attribute("Summary" ); + event.setSummary( dummy ); // category dummy = element->attribute("Categories" ); QStringList ids = QStringList::split(";", dummy ); diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 7672f21..39e00d1 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h @@ -199,7 +199,8 @@ inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) chk->setChecked( todo->isCompleted() ); ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); cmb->setText( QString::number( todo->priority() ) ); - QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); + QString sum = todo->summary(); + QTableItem *ti = new TodoTextItem( this, sum.isEmpty() ? todo->description().left(40).simplifyWhiteSpace() : sum ); ti->setReplaceable( false ); DueTextItem *due = new DueTextItem(this, todo ); diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index fe8b8bf..6b10ec2 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp @@ -13,6 +13,7 @@ namespace { class FileToDoResource : public ToDoResource { public: FileToDoResource() {}; + // FIXME better parsing bool save(const QString &name, const QValueList &m_todos ){ // prepare the XML XMLElement *tasks = new XMLElement( ); @@ -23,6 +24,7 @@ public: 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 arrat = (*it).categories(); QString attr; for(uint i=0; i < arrat.count(); i++ ){ @@ -111,11 +113,13 @@ public: //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 ); - + event.setCategories( ids ); + //uid dummy = element->attribute("Uid" ); dumInt = dummy.toInt(&ok ); @@ -181,7 +185,7 @@ QValueList ToDoDB::effectiveToDos(const QDate &from, QValueList ToDoDB::overDue() { QValueList events; - for( QValueList::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ + for( QValueList::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ if( (*it).isOverdue() ) events.append((*it) ); } @@ -238,7 +242,7 @@ QString ToDoDB::fileName()const } void ToDoDB::load() { - m_todos = m_res->load( m_fileName ); + m_todos = m_res->load( m_fileName ); } bool ToDoDB::save() { diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index aa348a2..fb7073c 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp @@ -17,21 +17,25 @@ 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 - m_uid = uid; + m_uid = uid; } QArray ToDoEvent::categories()const { @@ -66,6 +70,14 @@ 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 ); @@ -99,6 +111,14 @@ 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() ); @@ -127,9 +147,11 @@ QString ToDoEvent::richText() const { QString text; QStringList catlist; - + // Description of the todo if ( !description().isEmpty() ){ + text += "" + QObject::tr( "Summary:") + "
"; + text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "
" ) + "
"; text += "" + QObject::tr( "Description:" ) + "
"; text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "
" ) + "
"; } @@ -140,7 +162,7 @@ QString ToDoEvent::richText() const text += date().toString(); text += "
"; } - + // Open database of all categories and get the list of // the categories this todoevent belongs to. // Then print them... @@ -149,7 +171,7 @@ QString ToDoEvent::richText() const bool firstloop = true; catdb.load( categoryFileName() ); catlist = allCategories(); - + text += "" + QObject::tr( "Category:") + " "; for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { if (!firstloop){ @@ -215,7 +237,13 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const } 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; } @@ -228,6 +256,7 @@ ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) 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 @@ -2,6 +2,7 @@ #ifndef todoevent_h #define todoevent_h +#include #include #include #include @@ -15,14 +16,16 @@ class 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 &description = QString::null , + 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 @@ -43,27 +46,81 @@ class ToDoEvent { What is the priority? **/ int priority()const ; + + /* + All category numbers as QString in a List + **/ QStringList allCategories()const; + + /* + * Same as above but with QArray + */ QArray 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 + // 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; @@ -85,6 +142,8 @@ class ToDoEvent { int m_priority; QStringList m_category; QString m_desc; + QString m_sum; + QMap m_extra; int m_uid; }; diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp index 75f2197..80f8c60 100644 --- a/libopie/todovcalresource.cpp +++ b/libopie/todovcalresource.cpp @@ -2,24 +2,24 @@                =. This file is part of the OPIE Project              .=l. Copyright (c) 2002 Holger Freyther            .>+-= the use of vobject was inspired by libkcal - _;:,     .>    :=|. This library is free software; you can + _;:,     .>    :=|. This library is free software; you can .> <`_,   >  .   <= redistribute it and/or modify it under :`=1 )Y*s>-.--   : the terms of the GNU Library General Public .="- .-=="i,     .._ License as published by the Free Software  - .   .-<_>     .<> Foundation; either version 2 of the License,      ._= =}       : or (at your option) any later version. -    .%`+i>       _;_. -    .i_,=:_.      -       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU ..}^=.=       =       ; Library General Public License for more ++=   -.     .`     .: details. - :     =  ...= . :.=- + :     =  ...= . :.=-  -.   .:....=;==+<; You should have received a copy of the GNU   -_. . .   )=.  = Library General Public License along with -    --        :-=` this library; see the file COPYING.LIB. +    --        :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -50,7 +50,7 @@ static VObject *vobjByEvent( const ToDoEvent &event ) 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; }; @@ -63,7 +63,12 @@ static ToDoEvent eventByVObj( VObject *obj ){ 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 ); @@ -85,7 +90,7 @@ static ToDoEvent eventByVObj( VObject *obj ){ event.setHasDate( true ); name = vObjectStringZValue( ob ); event.setDate( TimeConversion::fromISO8601( name).date() ); - } + } // categories if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ name = vObjectStringZValue( ob ); @@ -96,7 +101,7 @@ static ToDoEvent eventByVObj( VObject *obj ){ }; -QValueList ToDoVCalResource::load(const QString &file) +QValueList ToDoVCalResource::load(const QString &file) { QValueList events; VObject *vcal = 0l; -- cgit v0.9.0.2