author | zecke <zecke> | 2002-06-15 16:46:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-15 16:46:37 (UTC) |
commit | ff47b17768607d8819ef5cd3316a1cab0abdcf3a (patch) (side-by-side diff) | |
tree | addbc4d7d8826ce2952aca872e67e3575d77cda7 | |
parent | 9f41969610f9db5d60d6080abae0b21e54a549e2 (diff) | |
download | opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.zip opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.gz opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.bz2 |
Summary support
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/todoentry.ui | 370 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 11 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 3 | ||||
-rw-r--r-- | libopie/tododb.cpp | 12 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 43 | ||||
-rw-r--r-- | libopie/todoevent.h | 67 | ||||
-rw-r--r-- | libopie/todovcalresource.cpp | 23 |
9 files changed, 353 insertions, 185 deletions
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 @@ -585,25 +585,25 @@ void TodoWindow::setDocument( const QString &filename ) static const char * beamfile = "/tmp/obex/todo.vcs"; void TodoWindow::slotBeam() { unlink( beamfile ); // delete if exists ToDoEvent c = table->currentEntry(); mkdir("/tmp/obex/", 0755); ToDoDB todoDB( beamfile, new ToDoVCalResource() ); todoDB.addEvent( c ); 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" ); } void TodoWindow::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } void TodoWindow::showDeadline( bool s ) { table->setPaintingEnabled( false ); 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 @@ -21,224 +21,284 @@ *********************************************************************</comment> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>NewTaskDialogBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>249</width> + <width>245</width> <height>321</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>New Task</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> - <vbox> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> - <name>margin</name> - <number>0</number> + <name>name</name> + <cstring>Layout3</cstring> </property> <property stdset="1"> - <name>spacing</name> - <number>0</number> + <name>geometry</name> + <rect> + <x>1</x> + <y>25</y> + <width>243</width> + <height>17</height> + </rect> </property> - <widget> - <class>QLayoutWidget</class> + <hbox> <property stdset="1"> - <name>name</name> - <cstring>Layout4</cstring> + <name>margin</name> + <number>0</number> </property> - <hbox> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> <property stdset="1"> - <name>margin</name> - <number>0</number> + <name>name</name> + <cstring>TextLabel3</cstring> </property> <property stdset="1"> - <name>spacing</name> - <number>6</number> + <name>frameShape</name> + <enum>NoFrame</enum> </property> - <widget> - <class>QLabel</class> + <property stdset="1"> + <name>text</name> + <string>Category:</string> + </property> + </widget> + <widget> + <class>CategorySelect</class> + <property stdset="1"> + <name>name</name> + <cstring>comboCategory</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout6</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>240</width> + <height>320</height> + </rect> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="2" column="0" > + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> + <name>margin</name> + <number>0</number> </property> <property stdset="1"> - <name>text</name> - <string>Priority:</string> + <name>spacing</name> + <number>6</number> </property> - </widget> - <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>1 - Very High</string> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> </property> - </item> - <item> - <property> + <property stdset="1"> <name>text</name> - <string>2 - High</string> + <string>Summary:</string> </property> - </item> - <item> - <property> - <name>text</name> - <string>3 - Normal</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>4 - Low</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>5 - Very Low</string> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>lneSum</cstring> </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>comboPriority</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>0</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>currentItem</name> - <number>2</number> - </property> - </widget> - </hbox> - </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout3</cstring> - </property> - <hbox> + </widget> + </hbox> + </widget> + <widget row="3" column="0" > + <class>QMultiLineEdit</class> <property stdset="1"> - <name>margin</name> - <number>0</number> + <name>name</name> + <cstring>txtTodo</cstring> </property> + </widget> + <widget row="1" column="0" > + <class>QLayoutWidget</class> <property stdset="1"> - <name>spacing</name> - <number>6</number> + <name>name</name> + <cstring>Layout4</cstring> </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>NoFrame</enum> - </property> + <hbox> <property stdset="1"> - <name>text</name> - <string>Category:</string> + <name>margin</name> + <number>0</number> </property> - </widget> - <widget> - <class>CategorySelect</class> <property stdset="1"> - <name>name</name> - <cstring>comboCategory</cstring> + <name>spacing</name> + <number>6</number> </property> - </widget> - </hbox> - </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout4</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>checkCompleted</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Completed</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>checkDate</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>D&ue</string> + </property> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>buttonDate</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>1 Jan 2001</string> + </property> + </widget> + </hbox> + </widget> + <widget row="0" column="0" > + <class>QLayoutWidget</class> <property stdset="1"> - <name>spacing</name> - <number>6</number> + <name>name</name> + <cstring>Layout4</cstring> </property> - <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>checkCompleted</cstring> - </property> + <hbox> <property stdset="1"> - <name>text</name> - <string>&Completed</string> + <name>margin</name> + <number>0</number> </property> - </widget> - <widget> - <class>QCheckBox</class> <property stdset="1"> - <name>name</name> - <cstring>checkDate</cstring> + <name>spacing</name> + <number>6</number> </property> - <property stdset="1"> - <name>text</name> - <string>D&ue</string> - </property> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>buttonDate</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>1 Jan 2001</string> - </property> - </widget> - </hbox> - </widget> - <widget> - <class>QMultiLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>txtTodo</cstring> - </property> - </widget> - </vbox> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Priority:</string> + </property> + </widget> + <widget> + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>1 - Very High</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>2 - High</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>3 - Normal</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>4 - Low</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>5 - Very Low</string> + </property> + </item> + <property stdset="1"> + <name>name</name> + <cstring>comboPriority</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>currentItem</name> + <number>2</number> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> </widget> <customwidgets> <customwidget> <class>CategorySelect</class> <header location="global">qpe/categoryselect.h</header> <sizehint> <width>-1</width> <height>-1</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> 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,14 +1,15 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2002 zecke ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. @@ -52,24 +53,25 @@ NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, date = todo.date(); else date = QDate::currentDate(); init(); comboPriority->setCurrentItem( task.priority() - 1 ); checkCompleted->setChecked( task.isCompleted() ); checkDate->setChecked( task.hasDate() ); buttonDate->setText( TimeString::longDateString( date ) ); txtTodo->setText( task.description() ); + lneSum->setText( task.summary() ); } /* * Constructs a NewTaskDialog which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, WFlags fl ) : NewTaskDialogBase( parent, name, modal, fl ), @@ -121,27 +123,28 @@ ToDoEvent NewTaskDialog::todoEntry() todo.setHasDate( true ); }else{ todo.setHasDate( false ); } if ( comboCategory->currentCategory() != -1 ) { QArray<int> arr = comboCategory->currentCategories(); QStringList list; list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; todo.setCategories( list ); } todo.setPriority( comboPriority->currentItem() + 1 ); todo.setCompleted( checkCompleted->isChecked() ); - + todo.setDescription( txtTodo->text() ); - + todo.setSummary( lneSum->text() ); + return todo; } /*! */ void NewTaskDialog::accept() { QString strText = txtTodo->text(); if ( strText.isEmpty() ) { 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 @@ -563,24 +563,25 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; QArray<int> arrat = todo.categories(); QString attr; for(uint i=0; i < arrat.count(); i++ ){ attr.append(QString::number(arrat[i])+";" ); } if(!attr.isEmpty() ) // remove the last ; 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() ) + "\""; buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; } buf += "/>\n"; str = buf.utf8(); f.writeBlock( str.data(), str.length() ); f.close(); } void TodoTable::rowHeightChanged( int row ) @@ -601,26 +602,29 @@ void TodoTable::loadFile( const QString &/*we use the standard*/ ) } vaList.clear(); // qDebug("parsing done=%d", t.elapsed() ); if ( list.count() > 0 ) { internalAddEntries( list ); list.clear(); } // qDebug("loading done: t=%d", t.elapsed() ); } 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<CheckItem*, ToDoEvent *> it; for ( it = todoList.begin(); it != todoList.end(); ++it ) { if ( *(*it) == todo ) { row = it.key()->row(); it.key()->setChecked( todo.isCompleted() ); static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); item( row, 2 )->setText( strTodo ); if (showDeadl){ static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); } @@ -899,24 +903,27 @@ static ToDoEvent xmlToEvent( XMLElement *element ) if(ok ) day = dumInt; // set the date QDate date( year, month, day ); event.setDate( date); } dummy = element->attribute("Priority" ); dumInt = dummy.toInt(&ok ); if(!ok ) dumInt = ToDoEvent::NORMAL; event.setPriority( dumInt ); //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 ); event.setCategories( ids ); //uid dummy = element->attribute("Uid" ); dumInt = dummy.toInt(&ok ); if(ok ) event.setUid( dumInt ); return event; } 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 @@ -190,25 +190,26 @@ private: }; inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) { QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') + todo->priority() ) + Qtopia::buildSortKey( todo->description() ); CheckItem *chk = new CheckItem( this, sortKey ); 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 ); setItem( row, 3, due); setItem( row, 0, chk ); setItem( row, 1, cmb ); setItem( row, 2, ti ); todoList.insert( chk, todo ); } diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index fe8b8bf..6b10ec2 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp @@ -4,34 +4,36 @@ #include <opie/xmltree.h> #include <opie/todoresource.h> #include <qpe/palmtoprecord.h> #include <qpe/global.h> 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 ; attr.remove(attr.length()-1, 1 ); map.insert( "Categories", attr ); //else //map.insert( "Categories", QString::null ); map.insert( "Description", (*it).description() ); if( (*it).hasDate() ){ @@ -102,29 +104,31 @@ public: if(ok ) day = dumInt; // set the date QDate date( year, month, day ); event.setDate( date); } dummy = element->attribute("Priority" ); 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 ); - + event.setCategories( ids ); + //uid dummy = element->attribute("Uid" ); dumInt = dummy.toInt(&ok ); if(ok ) event.setUid( dumInt ); m_todos.append( event ); element = element->nextChild(); // next element } //} }else { qWarning("could not load" ); } delete root; @@ -172,25 +176,25 @@ QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, } } return events; } QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, bool all) { return effectiveToDos( from, QDate::currentDate(), all ); } QValueList<ToDoEvent> ToDoDB::overDue() { QValueList<ToDoEvent> events; - for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ + for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ if( (*it).isOverdue() ) events.append((*it) ); } return events; } QValueList<ToDoEvent> ToDoDB::rawToDos() { return m_todos; } void ToDoDB::addEvent( const ToDoEvent &event ) { m_todos.append( event ); @@ -229,25 +233,25 @@ void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) } } void ToDoDB::setFileName(const QString &file ) { m_fileName =file; } QString ToDoDB::fileName()const { return m_fileName; } void ToDoDB::load() { - m_todos = m_res->load( m_fileName ); + m_todos = m_res->load( m_fileName ); } bool ToDoDB::save() { return m_res->save( m_fileName, m_todos ); } diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index aa348a2..fb7073c 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp @@ -8,39 +8,43 @@ #include <qpe/stringutil.h> #include <qpe/categories.h> #include <qpe/categoryselect.h> #include <qobject.h> 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<int> ToDoEvent::categories()const { QArray<int> array(m_category.count() ); // currently the datebook can be only in one category array = Qtopia::Record::idsFromString( m_category.join(";") ); return array; } bool ToDoEvent::match( const QRegExp ®Exp )const { if( QString::number( m_priority ).find( regExp ) != -1 ){ return true; }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ @@ -57,24 +61,32 @@ bool ToDoEvent::isCompleted() const bool ToDoEvent::hasDate() const { return m_hasDate; } 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() { m_category.clear(); } void ToDoEvent::setCategories(const QStringList &list ) { m_category = list; } @@ -90,24 +102,32 @@ QString ToDoEvent::description()const void ToDoEvent::setCompleted( bool completed ) { m_isCompleted = completed; } 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; } void ToDoEvent::setPriority(int prio ) { m_priority = prio; } void ToDoEvent::setDate( QDate date ) { @@ -118,47 +138,49 @@ bool ToDoEvent::isOverdue( ) if( m_hasDate ) return QDate::currentDate() > m_date; return false; } /*! Returns a richt text string */ 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() ){ text += "<b>" + QObject::tr( "Deadline:") + " </b>"; text += date().toString(); text += "<br>"; } - + // Open database of all categories and get the list of // the categories this todoevent belongs to. // Then print them... // I am not sure whether there is no better way doing this !? Categories catdb; bool firstloop = true; catdb.load( categoryFileName() ); catlist = allCategories(); - + text += "<b>" + QObject::tr( "Category:") + "</b> "; for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { if (!firstloop){ text += ", "; } firstloop = false; text += catdb.label ("todo", (*it).toInt()); } text += "<br>"; return text; } @@ -206,35 +228,42 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const if( !hasDate() && toDoEvent.hasDate() ) return false; if( hasDate() && toDoEvent.hasDate() ){ if( date() == toDoEvent.date() ){ // let's the priority decide return priority() > toDoEvent.priority(); }else{ return date() > toDoEvent.date(); } } 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,92 +1,151 @@ #ifndef todoevent_h #define todoevent_h +#include <qmap.h> #include <qregexp.h> #include <qstringlist.h> #include <qdatetime.h> class ToDoEvent { friend class ToDoDB; public: // 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 &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 **/ ToDoEvent(const ToDoEvent & ); /* Is this event completed? **/ bool isCompleted() const; /* Does this Event have a deadline **/ 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 + // 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; bool operator<=(const ToDoEvent &toDoEvent )const; bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; bool operator>(const ToDoEvent &toDoEvent )const; bool operator>=(const ToDoEvent &toDoEvent)const; bool operator==(const ToDoEvent &toDoEvent )const; ToDoEvent &operator=(const ToDoEvent &toDoEvent ); private: class ToDoEventPrivate; ToDoEventPrivate *d; 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 @@ -1,34 +1,34 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> .>+-= 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_,=:_. -<s. This library is distributed in the hope that + .%`+i> _;_. + .i_,=:_. -<s. This library 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 ..}^=.= = ; 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. */ #include <qfile.h> #include <qvaluelist.h> #include <opie/todoevent.h> #include <opie/todovcalresource.h> #include "../library/backend/vobject_p.h" @@ -41,71 +41,76 @@ static VObject *vobjByEvent( const ToDoEvent &event ) if( task == 0 ) return 0l; if( event.hasDate() ) addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); if( event.isCompleted() ) 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; QCString name; // 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{ event.setCompleted( false ); } }else event.setCompleted( false ); // priority if ((ob = isAPropertyOf(obj, VCPriorityProp))) { name = vObjectStringZValue( ob ); bool ok; event.setPriority(name.toInt(&ok) ); } //due date if((ob = isAPropertyOf(obj, VCDueProp)) ){ event.setHasDate( true ); name = vObjectStringZValue( ob ); event.setDate( TimeConversion::fromISO8601( name).date() ); - } + } // categories if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ name = vObjectStringZValue( ob ); qWarning("Categories:%s", name.data() ); } return event; }; -QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) +QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) { QValueList<ToDoEvent> events; VObject *vcal = 0l; vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject if(!vcal ) return events; // start parsing VObjectIterator it; VObject *vobj; initPropIterator(&it, vcal); |