-rw-r--r-- | core/pim/todo/mainwindow.cpp | 8 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 3 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 2 | ||||
-rw-r--r-- | libopie/libopie.pro | 2 | ||||
-rw-r--r-- | libopie/tododb.cpp | 8 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 6 | ||||
-rw-r--r-- | libopie/todovcalresource.cpp | 153 |
7 files changed, 175 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index fb85a09..6709811 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -9,24 +9,26 @@ | |||
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_FD | ||
22 | |||
21 | #include "mainwindow.h" | 23 | #include "mainwindow.h" |
22 | #include "todoentryimpl.h" | 24 | #include "todoentryimpl.h" |
23 | #include "todotable.h" | 25 | #include "todotable.h" |
24 | 26 | ||
25 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
27 | #include <qpe/finddialog.h> | 29 | #include <qpe/finddialog.h> |
28 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
29 | #include <qpe/ir.h> | 31 | #include <qpe/ir.h> |
30 | #include <qpe/qpemenubar.h> | 32 | #include <qpe/qpemenubar.h> |
31 | #include <qpe/qpemessagebox.h> | 33 | #include <qpe/qpemessagebox.h> |
32 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
@@ -113,33 +115,35 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
113 | catMenu = new QPopupMenu( this ); | 115 | catMenu = new QPopupMenu( this ); |
114 | QPopupMenu *edit = new QPopupMenu( this ); | 116 | QPopupMenu *edit = new QPopupMenu( this ); |
115 | contextMenu = new QPopupMenu( this ); | 117 | contextMenu = new QPopupMenu( this ); |
116 | 118 | ||
117 | bar = new QPEToolBar( this ); | 119 | bar = new QPEToolBar( this ); |
118 | 120 | ||
119 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 121 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
120 | QString::null, 0, this, 0 ); | 122 | QString::null, 0, this, 0 ); |
121 | connect( a, SIGNAL( activated() ), | 123 | connect( a, SIGNAL( activated() ), |
122 | this, SLOT( slotNew() ) ); | 124 | this, SLOT( slotNew() ) ); |
123 | a->addTo( bar ); | 125 | a->addTo( bar ); |
124 | a->addTo( edit ); | 126 | a->addTo( edit ); |
127 | |||
125 | a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), | 128 | a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), |
126 | QString::null, 0, this, 0 ); | 129 | QString::null, 0, this, 0 ); |
127 | connect( a, SIGNAL( activated() ), | 130 | connect( a, SIGNAL( activated() ), |
128 | this, SLOT( slotEdit() ) ); | 131 | this, SLOT( slotEdit() ) ); |
129 | a->addTo( bar ); | 132 | a->addTo( bar ); |
130 | a->addTo( edit ); | 133 | a->addTo( edit ); |
131 | a->addTo( contextMenu ); | 134 | a->addTo( contextMenu ); |
132 | a->setEnabled( FALSE ); | 135 | a->setEnabled( FALSE ); |
133 | editAction = a; | 136 | editAction = a; |
137 | |||
134 | a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), | 138 | a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), |
135 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
136 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
137 | this, SLOT( slotDelete() ) ); | 141 | this, SLOT( slotDelete() ) ); |
138 | a->addTo( bar ); | 142 | a->addTo( bar ); |
139 | a->addTo( edit ); | 143 | a->addTo( edit ); |
140 | a->addTo( contextMenu ); | 144 | a->addTo( contextMenu ); |
141 | a->setEnabled( FALSE ); | 145 | a->setEnabled( FALSE ); |
142 | deleteAction = a; | 146 | deleteAction = a; |
143 | 147 | ||
144 | if ( Ir::supported() ) { | 148 | if ( Ir::supported() ) { |
145 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 149 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
@@ -317,47 +321,47 @@ void TodoWindow::currentEntryChanged( int r, int ) | |||
317 | } | 321 | } |
318 | 322 | ||
319 | void TodoWindow::setCategory( int c ) | 323 | void TodoWindow::setCategory( int c ) |
320 | { | 324 | { |
321 | if ( c <= 0 ) return; | 325 | if ( c <= 0 ) return; |
322 | if ( !table->isUpdatesEnabled() ) | 326 | if ( !table->isUpdatesEnabled() ) |
323 | return; | 327 | return; |
324 | table->setPaintingEnabled( false ); | 328 | table->setPaintingEnabled( false ); |
325 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 329 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
326 | catMenu->setItemChecked( i, c == (int)i ); | 330 | catMenu->setItemChecked( i, c == (int)i ); |
327 | if ( c == 1 ) { | 331 | if ( c == 1 ) { |
328 | table->setShowCategory( QString::null ); | 332 | table->setShowCategory( QString::null ); |
329 | setCaption( tr("Todo") + " - " + tr( "All" ) ); | 333 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
330 | } else if ( c == (int)catMenu->count() - 1 ) { | 334 | } else if ( c == (int)catMenu->count() - 1 ) { |
331 | table->setShowCategory( tr( "Unfiled" ) ); | 335 | table->setShowCategory( tr( "Unfiled" ) ); |
332 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 336 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
333 | } else { | 337 | } else { |
334 | QString cat = table->categories()[c - 2]; | 338 | QString cat = table->categories()[c - 2]; |
335 | table->setShowCategory( cat ); | 339 | table->setShowCategory( cat ); |
336 | setCaption( tr("Todo") + " - " + cat ); | 340 | setCaption( tr("Todo") + " - " + cat ); |
337 | } | 341 | } |
338 | table->setPaintingEnabled( true ); | 342 | table->setPaintingEnabled( true ); |
339 | } | 343 | } |
340 | 344 | ||
341 | void TodoWindow::populateCategories() | 345 | void TodoWindow::populateCategories() |
342 | { | 346 | { |
343 | catMenu->clear(); | 347 | catMenu->clear(); |
344 | 348 | ||
345 | completedAction->addTo( catMenu ); | 349 | completedAction->addTo( catMenu ); |
346 | completedAction->setOn( table->showCompleted() ); | 350 | completedAction->setOn( table->showCompleted() ); |
347 | 351 | ||
348 | int id, | 352 | int id, |
349 | rememberId; | 353 | rememberId; |
350 | id = 1; | 354 | id = 1; |
351 | catMenu->insertItem( tr( "All" ), id++ ); | 355 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
352 | // catMenu->insertSeparator(); | 356 | // catMenu->insertSeparator(); |
353 | QStringList categories = table->categories(); | 357 | QStringList categories = table->categories(); |
354 | categories.append( tr( "Unfiled" ) ); | 358 | categories.append( tr( "Unfiled" ) ); |
355 | for ( QStringList::Iterator it = categories.begin(); | 359 | for ( QStringList::Iterator it = categories.begin(); |
356 | it != categories.end(); ++it ) { | 360 | it != categories.end(); ++it ) { |
357 | catMenu->insertItem( *it, id ); | 361 | catMenu->insertItem( *it, id ); |
358 | if ( *it == table->showCategory() ) | 362 | if ( *it == table->showCategory() ) |
359 | rememberId = id; | 363 | rememberId = id; |
360 | ++id; | 364 | ++id; |
361 | } | 365 | } |
362 | if ( table->showCategory().isEmpty() ) | 366 | if ( table->showCategory().isEmpty() ) |
363 | setCategory( 1 ); | 367 | setCategory( 1 ); |
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index f4fcd1b..856dcb4 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,16 +1,17 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia and Opi Environment. |
5 | ** | 6 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index 79206de..c957715 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -124,19 +124,19 @@ Task NewTaskDialog::todoEntry() | |||
124 | 124 | ||
125 | return todo; | 125 | return todo; |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | /*! | 129 | /*! |
130 | 130 | ||
131 | */ | 131 | */ |
132 | 132 | ||
133 | void NewTaskDialog::accept() | 133 | void NewTaskDialog::accept() |
134 | { | 134 | { |
135 | QString strText = txtTodo->text(); | 135 | QString strText = txtTodo->text(); |
136 | if ( !strText || strText == "") { | 136 | if ( strText.isEmpty() ) { |
137 | // hmm... just decline it then, the user obviously didn't care about it | 137 | // hmm... just decline it then, the user obviously didn't care about it |
138 | QDialog::reject(); | 138 | QDialog::reject(); |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | QDialog::accept(); | 141 | QDialog::accept(); |
142 | } | 142 | } |
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index fb00422..1c0bf7b 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,7 +1,7 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = $(OPIEDIR)/include/opie/xmltree.h | 3 | HEADERS = $(OPIEDIR)/include/opie/xmltree.h |
4 | SOURCES = xmltree.cc tododb.cpp todoevent.cpp | 4 | SOURCES = xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp |
5 | TARGET = opie | 5 | TARGET = opie |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index b1b35d0..f9756c6 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -129,24 +129,32 @@ public: | |||
129 | ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ | 129 | ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ |
130 | m_fileName = fileName; | 130 | m_fileName = fileName; |
131 | if( fileName.isEmpty() && res == 0 ){ | 131 | if( fileName.isEmpty() && res == 0 ){ |
132 | m_fileName = Global::applicationFileName("todolist","todolist.xml"); | 132 | m_fileName = Global::applicationFileName("todolist","todolist.xml"); |
133 | res = new FileToDoResource(); | 133 | res = new FileToDoResource(); |
134 | //qWarning("%s", m_fileName.latin1() ); | 134 | //qWarning("%s", m_fileName.latin1() ); |
135 | }else if(res == 0 ){ // let's create a ToDoResource for xml | 135 | }else if(res == 0 ){ // let's create a ToDoResource for xml |
136 | res = new FileToDoResource(); | 136 | res = new FileToDoResource(); |
137 | } | 137 | } |
138 | m_res = res; | 138 | m_res = res; |
139 | load(); | 139 | load(); |
140 | } | 140 | } |
141 | ToDoResource* ToDoDB::resource(){ | ||
142 | return m_res; | ||
143 | }; | ||
144 | void ToDoDB::setResource( ToDoResource *res ) | ||
145 | { | ||
146 | delete m_res; | ||
147 | m_res = res; | ||
148 | } | ||
141 | ToDoDB::~ToDoDB() | 149 | ToDoDB::~ToDoDB() |
142 | { | 150 | { |
143 | delete m_res; | 151 | delete m_res; |
144 | } | 152 | } |
145 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, | 153 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, |
146 | bool all ) | 154 | bool all ) |
147 | { | 155 | { |
148 | QValueList<ToDoEvent> events; | 156 | QValueList<ToDoEvent> events; |
149 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 157 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
150 | if( (*it).hasDate() ){ | 158 | if( (*it).hasDate() ){ |
151 | if( (*it).date() >= from && (*it).date() <= to ) | 159 | if( (*it).date() >= from && (*it).date() <= to ) |
152 | events.append( (*it) ); | 160 | events.append( (*it) ); |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 4cfe1c0..5fa4472 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,26 +1,28 @@ | |||
1 | 1 | ||
2 | #include <opie/todoevent.h> | 2 | #include <opie/todoevent.h> |
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/stringutil.h> | ||
5 | //#include <qpe/palmtoprecord.h> | ||
4 | 6 | ||
5 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | 7 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, |
6 | const QString &description, bool hasDate, QDate date, int uid ) | 8 | const QString &description, bool hasDate, QDate date, int uid ) |
7 | { | 9 | { |
8 | qWarning("todoEvent c'tor" ); | 10 | qWarning("todoEvent c'tor" ); |
9 | m_date = date; | 11 | m_date = date; |
10 | m_isCompleted = completed; | 12 | m_isCompleted = completed; |
11 | m_hasDate = hasDate; | 13 | m_hasDate = hasDate; |
12 | m_priority = priority; | 14 | m_priority = priority; |
13 | m_category = category; | 15 | m_category = category; |
14 | m_desc = description; | 16 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
15 | if (uid == -1 ) { | 17 | if (uid == -1 ) { |
16 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 18 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
17 | uid = uidgen->generate(); | 19 | uid = uidgen->generate(); |
18 | delete uidgen; | 20 | delete uidgen; |
19 | }// generate the ids | 21 | }// generate the ids |
20 | m_uid = uid; | 22 | m_uid = uid; |
21 | } | 23 | } |
22 | bool ToDoEvent::isCompleted() const | 24 | bool ToDoEvent::isCompleted() const |
23 | { | 25 | { |
24 | return m_isCompleted; | 26 | return m_isCompleted; |
25 | } | 27 | } |
26 | bool ToDoEvent::hasDate() const | 28 | bool ToDoEvent::hasDate() const |
@@ -44,25 +46,25 @@ QString ToDoEvent::description()const | |||
44 | return m_desc; | 46 | return m_desc; |
45 | } | 47 | } |
46 | void ToDoEvent::setCompleted( bool completed ) | 48 | void ToDoEvent::setCompleted( bool completed ) |
47 | { | 49 | { |
48 | m_isCompleted = completed; | 50 | m_isCompleted = completed; |
49 | } | 51 | } |
50 | void ToDoEvent::setHasDate( bool hasDate ) | 52 | void ToDoEvent::setHasDate( bool hasDate ) |
51 | { | 53 | { |
52 | m_hasDate = hasDate; | 54 | m_hasDate = hasDate; |
53 | } | 55 | } |
54 | void ToDoEvent::setDescription(const QString &desc ) | 56 | void ToDoEvent::setDescription(const QString &desc ) |
55 | { | 57 | { |
56 | m_desc = desc; | 58 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
57 | } | 59 | } |
58 | void ToDoEvent::setCategory( const QString &cat ) | 60 | void ToDoEvent::setCategory( const QString &cat ) |
59 | { | 61 | { |
60 | m_category = cat; | 62 | m_category = cat; |
61 | } | 63 | } |
62 | void ToDoEvent::setPriority(int prio ) | 64 | void ToDoEvent::setPriority(int prio ) |
63 | { | 65 | { |
64 | m_priority = prio; | 66 | m_priority = prio; |
65 | } | 67 | } |
66 | void ToDoEvent::setDate( QDate date ) | 68 | void ToDoEvent::setDate( QDate date ) |
67 | { | 69 | { |
68 | m_date = date; | 70 | m_date = date; |
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp new file mode 100644 index 0000000..a6afe68 --- a/dev/null +++ b/libopie/todovcalresource.cpp | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> | ||
4 | .>+-= the use of vobject was inspired by libkcal | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <qfile.h> | ||
30 | #include <qvaluelist.h> | ||
31 | #include <opie/todoevent.h> | ||
32 | #include <opie/todovcalresource.h> | ||
33 | |||
34 | #include "../library/backend/vobject_p.h" | ||
35 | #include "../library/backend/timeconversion.h" | ||
36 | #include "../library/backend/qfiledirect_p.h" | ||
37 | |||
38 | static VObject *vobjByEvent( const ToDoEvent &event ) | ||
39 | { | ||
40 | VObject *task = newVObject( VCTodoProp ); | ||
41 | if( task == 0 ) | ||
42 | return 0l; | ||
43 | if( event.hasDate() ) | ||
44 | addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); | ||
45 | |||
46 | if( event.isCompleted() ) | ||
47 | addPropValue( task, VCStatusProp, "COMPLETED"); | ||
48 | |||
49 | QString string = QString::number(event.priority() ); | ||
50 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | ||
51 | addPropValue( task, VCCategoriesProp, event.category().local8Bit() ); | ||
52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); | ||
53 | addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); | ||
54 | return task; | ||
55 | }; | ||
56 | |||
57 | static ToDoEvent eventByVObj( VObject *obj ){ | ||
58 | ToDoEvent event; | ||
59 | VObject *ob; | ||
60 | QCString name; | ||
61 | // no uid, attendees, ... and no fun | ||
62 | // description | ||
63 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | ||
64 | name = vObjectStringZValue( ob ); | ||
65 | event.setDescription( name ); | ||
66 | } | ||
67 | // completed | ||
68 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | ||
69 | name = vObjectStringZValue( ob ); | ||
70 | if( name == "COMPLETED" ){ | ||
71 | event.setCompleted( true ); | ||
72 | }else{ | ||
73 | event.setCompleted( false ); | ||
74 | } | ||
75 | }else | ||
76 | event.setCompleted( false ); | ||
77 | // priority | ||
78 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | ||
79 | name = vObjectStringZValue( ob ); | ||
80 | bool ok; | ||
81 | event.setPriority(name.toInt(&ok) ); | ||
82 | } | ||
83 | //due date | ||
84 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | ||
85 | event.setHasDate( true ); | ||
86 | name = vObjectStringZValue( ob ); | ||
87 | event.setDate( TimeConversion::fromISO8601( name).date() ); | ||
88 | } | ||
89 | // categories | ||
90 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | ||
91 | name = vObjectStringZValue( ob ); | ||
92 | qWarning("Categories:%s", name.data() ); | ||
93 | } | ||
94 | |||
95 | return event; | ||
96 | }; | ||
97 | |||
98 | |||
99 | QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) | ||
100 | { | ||
101 | QValueList<ToDoEvent> events; | ||
102 | VObject *vcal = 0l; | ||
103 | vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject | ||
104 | if(!vcal ) | ||
105 | return events; | ||
106 | // start parsing | ||
107 | |||
108 | VObjectIterator it; | ||
109 | VObject *vobj; | ||
110 | initPropIterator(&it, vcal); | ||
111 | |||
112 | while( moreIteration( &it ) ) { | ||
113 | vobj = ::nextVObject( &it ); | ||
114 | QCString name = ::vObjectName( vobj ); | ||
115 | //QCString objVal = ::vObjectStringZValue( vobj ); | ||
116 | // let's find out the type | ||
117 | if( name == VCTodoProp ){ | ||
118 | events.append( eventByVObj( vobj ) ); | ||
119 | |||
120 | } // parse the value | ||
121 | } | ||
122 | return events; | ||
123 | } | ||
124 | bool ToDoVCalResource::save(const QString &fileName, const QValueList<ToDoEvent>&list ) | ||
125 | { | ||
126 | QFileDirect file ( fileName ); | ||
127 | if(!file.open(IO_WriteOnly ) ) | ||
128 | return false; | ||
129 | // obj | ||
130 | VObject *obj; | ||
131 | obj = newVObject( VCCalProp ); | ||
132 | addPropValue( obj, VCVersionProp, "1.0" ); | ||
133 | VObject *vo; | ||
134 | for(QValueList<ToDoEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ){ | ||
135 | vo = vobjByEvent( (*it) ); | ||
136 | addVObjectProp(obj, vo ); | ||
137 | } | ||
138 | writeVObject( file.directHandle(), obj ); | ||
139 | cleanVObject( obj ); | ||
140 | cleanStrTbl(); | ||
141 | |||
142 | return true; | ||
143 | } | ||
144 | |||
145 | |||
146 | |||
147 | |||
148 | |||
149 | |||
150 | |||
151 | |||
152 | |||
153 | |||