Diffstat (limited to 'libopie2/opiepim/core/orecur.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index f46f22e..033f264 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -1,57 +1,87 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
1 | #include <time.h> | 30 | #include <time.h> |
2 | 31 | ||
3 | #include <qshared.h> | 32 | #include <qshared.h> |
4 | 33 | ||
5 | #include <qtopia/timeconversion.h> | 34 | #include <qtopia/timeconversion.h> |
6 | 35 | ||
7 | #include "otimezone.h" | 36 | #include <opie2/otimezone.h> |
8 | #include "orecur.h" | 37 | #include <opie2/orecur.h> |
9 | 38 | ||
39 | namespace Opie { | ||
10 | struct ORecur::Data : public QShared { | 40 | struct ORecur::Data : public QShared { |
11 | Data() : QShared() { | 41 | Data() : QShared() { |
12 | type = ORecur::NoRepeat; | 42 | type = ORecur::NoRepeat; |
13 | freq = -1; | 43 | freq = -1; |
14 | days = 0; | 44 | days = 0; |
15 | pos = 0; | 45 | pos = 0; |
16 | create = QDateTime::currentDateTime(); | 46 | create = QDateTime::currentDateTime(); |
17 | hasEnd = FALSE; | 47 | hasEnd = FALSE; |
18 | end = QDate::currentDate(); | 48 | end = QDate::currentDate(); |
19 | } | 49 | } |
20 | char days; // Q_UINT8 for 8 seven days;) | 50 | char days; // Q_UINT8 for 8 seven days;) |
21 | ORecur::RepeatType type; | 51 | ORecur::RepeatType type; |
22 | int freq; | 52 | int freq; |
23 | int pos; | 53 | int pos; |
24 | bool hasEnd : 1; | 54 | bool hasEnd : 1; |
25 | QDate end; | 55 | QDate end; |
26 | QDateTime create; | 56 | QDateTime create; |
27 | int rep; | 57 | int rep; |
28 | QString app; | 58 | QString app; |
29 | ExceptionList list; | 59 | ExceptionList list; |
30 | QDate start; | 60 | QDate start; |
31 | }; | 61 | }; |
32 | 62 | ||
33 | 63 | ||
34 | ORecur::ORecur() { | 64 | ORecur::ORecur() { |
35 | data = new Data; | 65 | data = new Data; |
36 | } | 66 | } |
37 | 67 | ||
38 | ORecur::ORecur( const QMap<int, QString>& map ) | 68 | ORecur::ORecur( const QMap<int, QString>& map ) |
39 | { | 69 | { |
40 | ORecur(); | 70 | ORecur(); |
41 | fromMap( map ); | 71 | fromMap( map ); |
42 | } | 72 | } |
43 | 73 | ||
44 | 74 | ||
45 | ORecur::ORecur( const ORecur& rec) | 75 | ORecur::ORecur( const ORecur& rec) |
46 | : data( rec.data ) | 76 | : data( rec.data ) |
47 | { | 77 | { |
48 | data->ref(); | 78 | data->ref(); |
49 | } | 79 | } |
50 | ORecur::~ORecur() { | 80 | ORecur::~ORecur() { |
51 | if ( data->deref() ) { | 81 | if ( data->deref() ) { |
52 | delete data; | 82 | delete data; |
53 | data = 0l; | 83 | data = 0l; |
54 | } | 84 | } |
55 | } | 85 | } |
56 | void ORecur::deref() { | 86 | void ORecur::deref() { |
57 | if ( data->deref() ) { | 87 | if ( data->deref() ) { |
@@ -546,48 +576,50 @@ QMap<int, QString> ORecur::toMap() const | |||
546 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); | 576 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); |
547 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); | 577 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); |
548 | 578 | ||
549 | if ( data->list.isEmpty() ) return retMap; | 579 | if ( data->list.isEmpty() ) return retMap; |
550 | 580 | ||
551 | // save exceptions list here!! | 581 | // save exceptions list here!! |
552 | ExceptionList::ConstIterator it; | 582 | ExceptionList::ConstIterator it; |
553 | ExceptionList list = data->list; | 583 | ExceptionList list = data->list; |
554 | QString exceptBuf; | 584 | QString exceptBuf; |
555 | QDate date; | 585 | QDate date; |
556 | for ( it = list.begin(); it != list.end(); ++it ) { | 586 | for ( it = list.begin(); it != list.end(); ++it ) { |
557 | date = (*it); | 587 | date = (*it); |
558 | if ( it != list.begin() ) exceptBuf += " "; | 588 | if ( it != list.begin() ) exceptBuf += " "; |
559 | 589 | ||
560 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); | 590 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); |
561 | } | 591 | } |
562 | 592 | ||
563 | retMap.insert( ORecur::Exceptions, exceptBuf ); | 593 | retMap.insert( ORecur::Exceptions, exceptBuf ); |
564 | 594 | ||
565 | return retMap; | 595 | return retMap; |
566 | } | 596 | } |
567 | 597 | ||
568 | void ORecur::fromMap( const QMap<int, QString>& map ) | 598 | void ORecur::fromMap( const QMap<int, QString>& map ) |
569 | { | 599 | { |
570 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); | 600 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); |
571 | 601 | ||
572 | data -> type = repTypeMap[ map [ORecur::RType] ]; | 602 | data -> type = repTypeMap[ map [ORecur::RType] ]; |
573 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); | 603 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); |
574 | data -> pos = map[ ORecur::RPosition ].toInt(); | 604 | data -> pos = map[ ORecur::RPosition ].toInt(); |
575 | data -> freq = map[ ORecur::RFreq ].toInt(); | 605 | data -> freq = map[ ORecur::RFreq ].toInt(); |
576 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; | 606 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; |
577 | OTimeZone utc = OTimeZone::utc(); | 607 | OTimeZone utc = OTimeZone::utc(); |
578 | if ( data -> hasEnd ){ | 608 | if ( data -> hasEnd ){ |
579 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); | 609 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); |
580 | } | 610 | } |
581 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); | 611 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); |
582 | 612 | ||
583 | #if 0 | 613 | #if 0 |
584 | // FIXME: Exceptions currently not supported... | 614 | // FIXME: Exceptions currently not supported... |
585 | // Convert the list of exceptions from QString into ExceptionList | 615 | // Convert the list of exceptions from QString into ExceptionList |
586 | data -> list.clear(); | 616 | data -> list.clear(); |
587 | QString exceptStr = map[ ORecur::Exceptions ]; | 617 | QString exceptStr = map[ ORecur::Exceptions ]; |
588 | QStringList exceptList = QStringList::split( " ", exceptStr ); | 618 | QStringList exceptList = QStringList::split( " ", exceptStr ); |
589 | ... | 619 | ... |
590 | #endif | 620 | #endif |
591 | 621 | ||
592 | 622 | ||
593 | } | 623 | } |
624 | |||
625 | } \ No newline at end of file | ||