author | zecke <zecke> | 2003-02-21 16:52:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-21 16:52:49 (UTC) |
commit | 0bb9d0f9e7da80f0ae3b91d4ebbb7aab4d2b9df7 (patch) (unidiff) | |
tree | f3ce9c9441a1073762f3e0c61cc85f0d5a1fd81d /libopie/todovcalresource.cpp | |
parent | a298235aa1489937e7657079e6352adfc8746acf (diff) | |
download | opie-0bb9d0f9e7da80f0ae3b91d4ebbb7aab4d2b9df7.zip opie-0bb9d0f9e7da80f0ae3b91d4ebbb7aab4d2b9df7.tar.gz opie-0bb9d0f9e7da80f0ae3b91d4ebbb7aab4d2b9df7.tar.bz2 |
-Remove old Todo classes they're deprecated and today I already using the
new API
-Guard against self assignment in OTodo
-Add test apps for OPIM
-Opiefied Event classes
-Added TimeZone handling and pinning of TimeZones to OEvent
-Adjust ORecur and the widget to better timezone behaviour
Diffstat (limited to 'libopie/todovcalresource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/todovcalresource.cpp | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp deleted file mode 100644 index 1df5aff..0000000 --- a/libopie/todovcalresource.cpp +++ b/dev/null | |||
@@ -1,158 +0,0 @@ | |||
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/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.allCategories().join(";").local8Bit() ); | ||
52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); | ||
53 | addPropValue( task, VCSummaryProp, event.summary().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 | // summary | ||
68 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | ||
69 | name = vObjectStringZValue( ob ); | ||
70 | event.setSummary( name ); | ||
71 | } | ||
72 | // completed | ||
73 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | ||
74 | name = vObjectStringZValue( ob ); | ||
75 | if( name == "COMPLETED" ){ | ||
76 | event.setCompleted( true ); | ||
77 | }else{ | ||
78 | event.setCompleted( false ); | ||
79 | } | ||
80 | }else | ||
81 | event.setCompleted( false ); | ||
82 | // priority | ||
83 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | ||
84 | name = vObjectStringZValue( ob ); | ||
85 | bool ok; | ||
86 | event.setPriority(name.toInt(&ok) ); | ||
87 | } | ||
88 | //due date | ||
89 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | ||
90 | event.setHasDate( true ); | ||
91 | name = vObjectStringZValue( ob ); | ||
92 | event.setDate( TimeConversion::fromISO8601( name).date() ); | ||
93 | } | ||
94 | // categories | ||
95 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | ||
96 | name = vObjectStringZValue( ob ); | ||
97 | qWarning("Categories:%s", name.data() ); | ||
98 | } | ||
99 | |||
100 | return event; | ||
101 | }; | ||
102 | |||
103 | |||
104 | QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) | ||
105 | { | ||
106 | QValueList<ToDoEvent> events; | ||
107 | VObject *vcal = 0l; | ||
108 | vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject | ||
109 | if(!vcal ) | ||
110 | return events; | ||
111 | // start parsing | ||
112 | |||
113 | VObjectIterator it; | ||
114 | VObject *vobj; | ||
115 | initPropIterator(&it, vcal); | ||
116 | |||
117 | while( moreIteration( &it ) ) { | ||
118 | vobj = ::nextVObject( &it ); | ||
119 | QCString name = ::vObjectName( vobj ); | ||
120 | //QCString objVal = ::vObjectStringZValue( vobj ); | ||
121 | // let's find out the type | ||
122 | if( name == VCTodoProp ){ | ||
123 | events.append( eventByVObj( vobj ) ); | ||
124 | |||
125 | } // parse the value | ||
126 | } | ||
127 | return events; | ||
128 | } | ||
129 | bool ToDoVCalResource::save(const QString &fileName, const QValueList<ToDoEvent>&list ) | ||
130 | { | ||
131 | QFileDirect file ( fileName ); | ||
132 | if(!file.open(IO_WriteOnly ) ) | ||
133 | return false; | ||
134 | // obj | ||
135 | VObject *obj; | ||
136 | obj = newVObject( VCCalProp ); | ||
137 | addPropValue( obj, VCVersionProp, "1.0" ); | ||
138 | VObject *vo; | ||
139 | for(QValueList<ToDoEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ){ | ||
140 | vo = vobjByEvent( (*it) ); | ||
141 | addVObjectProp(obj, vo ); | ||
142 | } | ||
143 | writeVObject( file.directHandle(), obj ); | ||
144 | cleanVObject( obj ); | ||
145 | cleanStrTbl(); | ||
146 | |||
147 | return true; | ||
148 | } | ||
149 | |||
150 | |||
151 | |||
152 | |||
153 | |||
154 | |||
155 | |||
156 | |||
157 | |||
158 | |||