author | zautrix <zautrix> | 2005-07-30 16:17:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-30 16:17:54 (UTC) |
commit | 6a32c95e5f0a36cd9a681a3f3302bec6e83acce5 (patch) (unidiff) | |
tree | 3f8da30f9fe779ae697c97e16eb4dd6f47c3ed00 | |
parent | 9ca2cd947f22d33543e065f54c6487e86d80befa (diff) | |
download | kdepimpi-6a32c95e5f0a36cd9a681a3f3302bec6e83acce5.zip kdepimpi-6a32c95e5f0a36cd9a681a3f3302bec6e83acce5.tar.gz kdepimpi-6a32c95e5f0a36cd9a681a3f3302bec6e83acce5.tar.bz2 |
fixx
-rw-r--r-- | libkcal/attachment.cpp | 38 | ||||
-rw-r--r-- | libkcal/attachment.h | 71 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 4 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 12 |
4 files changed, 96 insertions, 29 deletions
diff --git a/libkcal/attachment.cpp b/libkcal/attachment.cpp index 1ead923..520ac95 100644 --- a/libkcal/attachment.cpp +++ b/libkcal/attachment.cpp | |||
@@ -1,86 +1,120 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | |||
3 | Copyright (c) 2002 Michael Brade <brade@kde.org> | 4 | Copyright (c) 2002 Michael Brade <brade@kde.org> |
4 | 5 | ||
5 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
9 | 10 | ||
10 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 14 | Library General Public License for more details. |
14 | 15 | ||
15 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
19 | */ | 20 | */ |
20 | 21 | ||
21 | #include "attachment.h" | 22 | #include "attachment.h" |
22 | 23 | ||
23 | using namespace KCal; | 24 | using namespace KCal; |
24 | 25 | ||
26 | Attachment::Attachment( const Attachment &attachment) | ||
27 | { | ||
28 | mMimeType = attachment.mMimeType; | ||
29 | mData = attachment.mData; | ||
30 | mBinary = attachment.mBinary; | ||
31 | mShowInline = attachment.mShowInline; | ||
32 | mLabel = attachment.mLabel; | ||
33 | } | ||
34 | |||
25 | Attachment::Attachment(const QString& uri, const QString& mime) | 35 | Attachment::Attachment(const QString& uri, const QString& mime) |
26 | { | 36 | { |
27 | mMimeType = mime; | 37 | mMimeType = mime; |
28 | mData = uri; | 38 | mData = uri; |
29 | mBinary = false; | 39 | mBinary = false; |
40 | mShowInline = false; | ||
41 | mLabel = QString::null; | ||
30 | } | 42 | } |
31 | 43 | ||
32 | Attachment::Attachment(const char *base64, const QString& mime) | 44 | Attachment::Attachment(const char *base64, const QString& mime) |
33 | { | 45 | { |
34 | mMimeType = mime; | 46 | mMimeType = mime; |
35 | mData = QString::fromUtf8(base64); | 47 | mData = QString::fromUtf8(base64); |
36 | mBinary = true; | 48 | mBinary = true; |
49 | mShowInline = false; | ||
50 | mLabel = QString::null; | ||
37 | } | 51 | } |
38 | 52 | ||
39 | bool Attachment::isURI() const | 53 | bool Attachment::isUri() const |
40 | { | 54 | { |
41 | return !mBinary; | 55 | return !mBinary; |
42 | } | 56 | } |
43 | 57 | ||
44 | QString Attachment::uri() const | 58 | QString Attachment::uri() const |
45 | { | 59 | { |
46 | if (!mBinary) | 60 | if (!mBinary) |
47 | return mData; | 61 | return mData; |
48 | else | 62 | else |
49 | return QString::null; | 63 | return QString::null; |
50 | } | 64 | } |
51 | 65 | ||
52 | void Attachment::setURI(const QString& uri) | 66 | void Attachment::setUri(const QString& uri) |
53 | { | 67 | { |
54 | mData = uri; | 68 | mData = uri; |
55 | mBinary = false; | 69 | mBinary = false; |
56 | } | 70 | } |
57 | 71 | ||
58 | bool Attachment::isBinary() const | 72 | bool Attachment::isBinary() const |
59 | { | 73 | { |
60 | return mBinary; | 74 | return mBinary; |
61 | } | 75 | } |
62 | 76 | ||
63 | char *Attachment::data() const | 77 | char *Attachment::data() const |
64 | { | 78 | { |
65 | if (mBinary) | 79 | if (mBinary) |
66 | return mData.utf8().data(); | 80 | return mData.utf8().data(); |
67 | else | 81 | else |
68 | return 0; | 82 | return 0; |
69 | } | 83 | } |
70 | 84 | ||
71 | void Attachment::setData(const char *base64) | 85 | void Attachment::setData(const char *base64) |
72 | { | 86 | { |
73 | mData = QString::fromUtf8(base64); | 87 | mData = QString::fromUtf8(base64); |
74 | mBinary = true; | 88 | mBinary = true; |
75 | } | 89 | } |
76 | 90 | ||
77 | QString Attachment::mimeType() const | 91 | QString Attachment::mimeType() const |
78 | { | 92 | { |
79 | return mMimeType; | 93 | return mMimeType; |
80 | } | 94 | } |
81 | 95 | ||
82 | void Attachment::setMimeType(const QString& mime) | 96 | void Attachment::setMimeType(const QString& mime) |
83 | { | 97 | { |
84 | mMimeType = mime; | 98 | mMimeType = mime; |
85 | } | 99 | } |
86 | 100 | ||
101 | bool Attachment::showInline() const | ||
102 | { | ||
103 | return mShowInline; | ||
104 | } | ||
105 | |||
106 | void Attachment::setShowInline( bool showinline ) | ||
107 | { | ||
108 | mShowInline = showinline; | ||
109 | } | ||
110 | |||
111 | QString Attachment::label() const | ||
112 | { | ||
113 | return mLabel; | ||
114 | } | ||
115 | |||
116 | void Attachment::setLabel( const QString& label ) | ||
117 | { | ||
118 | mLabel = label; | ||
119 | } | ||
120 | |||
diff --git a/libkcal/attachment.h b/libkcal/attachment.h index cdf2458..5301420 100644 --- a/libkcal/attachment.h +++ b/libkcal/attachment.h | |||
@@ -1,69 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | |||
3 | Copyright (c) 2002 Michael Brade <brade@kde.org> | 4 | Copyright (c) 2002 Michael Brade <brade@kde.org> |
4 | 5 | ||
5 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
9 | 10 | ||
10 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 14 | Library General Public License for more details. |
14 | 15 | ||
15 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
19 | */ | 20 | */ |
21 | #ifndef KCAL_ATTACHMENT_H | ||
22 | #define KCAL_ATTACHMENT_H | ||
20 | 23 | ||
21 | #ifndef _ATTACHMENT_H | ||
22 | #define _ATTACHMENT_H | ||
23 | 24 | ||
24 | #include <qstring.h> | ||
25 | 25 | ||
26 | #include <qstring.h> | ||
26 | 27 | ||
27 | namespace KCal { | 28 | namespace KCal { |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * This class represents information related to an attachment. | 31 | This class represents information related to an attachment. |
31 | */ | 32 | */ |
32 | class Attachment | 33 | class Attachment |
33 | { | 34 | { |
34 | public: | 35 | public: |
36 | |||
35 | /** | 37 | /** |
36 | * Create a Reference to some URI. | 38 | Create a Reference to some URI by copying an existing Attachment. |
37 | * @param uri the uri this attachment refers to | 39 | |
38 | * @param mime the mime type of the resource being linked to | 40 | @param attachment the attachment to be duplicated |
39 | */ | 41 | */ |
40 | Attachment(const QString& uri, const QString& mime = QString::null); | 42 | Attachment( const Attachment &attachment ); |
41 | 43 | ||
42 | /** | 44 | /** |
43 | * Create a binary attachment. | 45 | Create a Reference to some URI. |
44 | * @param base64 the attachment in base64 format | 46 | |
45 | * @param mime the mime type of the attachment | 47 | @param uri the uri this attachment refers to |
46 | */ | 48 | @param mime the mime type of the resource being linked to |
47 | Attachment(const char *base64, const QString& mime = QString::null); | 49 | */ |
48 | 50 | Attachment( const QString &uri, const QString &mime = QString::null ); | |
49 | /* The VALUE parameter in Cal */ | 51 | |
50 | bool isURI() const; | 52 | /** |
53 | Create a binary attachment. | ||
54 | |||
55 | @param base64 the attachment in base64 format | ||
56 | @param mime the mime type of the attachment | ||
57 | */ | ||
58 | Attachment( const char *base64, const QString &mime = QString::null ); | ||
59 | |||
60 | /* The VALUE parameter in iCal */ | ||
61 | bool isUri() const; | ||
51 | QString uri() const; | 62 | QString uri() const; |
52 | void setURI(const QString& uri); | 63 | void setUri( const QString &uri ); |
53 | 64 | ||
54 | bool isBinary() const; | 65 | bool isBinary() const; |
55 | char *data() const; | 66 | char *data() const; |
56 | void setData(const char *base64); | 67 | void setData( const char *base64 ); |
57 | 68 | ||
58 | /* The optional FMTTYPE parameter in iCal */ | 69 | /* The optional FMTTYPE parameter in iCal */ |
59 | QString mimeType() const; | 70 | QString mimeType() const; |
60 | void setMimeType(const QString& mime); | 71 | void setMimeType( const QString &mime ); |
61 | private: | 72 | |
73 | /* The custom X-CONTENT-DISPOSITION parameter, used by OGo etc. */ | ||
74 | bool showInline() const; | ||
75 | void setShowInline( bool showinline ); | ||
76 | |||
77 | /* The custom X-LABEL parameter to show a human-readable title */ | ||
78 | QString label() const; | ||
79 | void setLabel( const QString &label ); | ||
80 | |||
81 | private: | ||
62 | QString mMimeType; | 82 | QString mMimeType; |
63 | QString mData; | 83 | QString mData; |
64 | bool mBinary; | 84 | bool mBinary; |
85 | bool mShowInline; | ||
86 | QString mLabel; | ||
87 | |||
88 | class Private; | ||
89 | Private *d; | ||
65 | }; | 90 | }; |
66 | 91 | ||
67 | } | 92 | } |
68 | 93 | ||
69 | #endif | 94 | #endif |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 53aa039..65eabc8 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -469,103 +469,103 @@ icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | |||
469 | status = ICAL_PARTSTAT_DECLINED; | 469 | status = ICAL_PARTSTAT_DECLINED; |
470 | break; | 470 | break; |
471 | case Attendee::Tentative: | 471 | case Attendee::Tentative: |
472 | status = ICAL_PARTSTAT_TENTATIVE; | 472 | status = ICAL_PARTSTAT_TENTATIVE; |
473 | break; | 473 | break; |
474 | case Attendee::Delegated: | 474 | case Attendee::Delegated: |
475 | status = ICAL_PARTSTAT_DELEGATED; | 475 | status = ICAL_PARTSTAT_DELEGATED; |
476 | break; | 476 | break; |
477 | case Attendee::Completed: | 477 | case Attendee::Completed: |
478 | status = ICAL_PARTSTAT_COMPLETED; | 478 | status = ICAL_PARTSTAT_COMPLETED; |
479 | break; | 479 | break; |
480 | case Attendee::InProcess: | 480 | case Attendee::InProcess: |
481 | status = ICAL_PARTSTAT_INPROCESS; | 481 | status = ICAL_PARTSTAT_INPROCESS; |
482 | break; | 482 | break; |
483 | } | 483 | } |
484 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); | 484 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); |
485 | 485 | ||
486 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 486 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; |
487 | switch (attendee->role()) { | 487 | switch (attendee->role()) { |
488 | case Attendee::Chair: | 488 | case Attendee::Chair: |
489 | role = ICAL_ROLE_CHAIR; | 489 | role = ICAL_ROLE_CHAIR; |
490 | break; | 490 | break; |
491 | default: | 491 | default: |
492 | case Attendee::ReqParticipant: | 492 | case Attendee::ReqParticipant: |
493 | role = ICAL_ROLE_REQPARTICIPANT; | 493 | role = ICAL_ROLE_REQPARTICIPANT; |
494 | break; | 494 | break; |
495 | case Attendee::OptParticipant: | 495 | case Attendee::OptParticipant: |
496 | role = ICAL_ROLE_OPTPARTICIPANT; | 496 | role = ICAL_ROLE_OPTPARTICIPANT; |
497 | break; | 497 | break; |
498 | case Attendee::NonParticipant: | 498 | case Attendee::NonParticipant: |
499 | role = ICAL_ROLE_NONPARTICIPANT; | 499 | role = ICAL_ROLE_NONPARTICIPANT; |
500 | break; | 500 | break; |
501 | } | 501 | } |
502 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 502 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
503 | 503 | ||
504 | if (!attendee->uid().isEmpty()) { | 504 | if (!attendee->uid().isEmpty()) { |
505 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 505 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
506 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 506 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
507 | icalproperty_add_parameter(p,icalparameter_uid); | 507 | icalproperty_add_parameter(p,icalparameter_uid); |
508 | } | 508 | } |
509 | 509 | ||
510 | return p; | 510 | return p; |
511 | } | 511 | } |
512 | 512 | ||
513 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 513 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
514 | { | 514 | { |
515 | #if 0 | 515 | #if 0 |
516 | icalattachtype* attach = icalattachtype_new(); | 516 | icalattachtype* attach = icalattachtype_new(); |
517 | if (att->isURI()) | 517 | if (att->isUri()) |
518 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 518 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
519 | else | 519 | else |
520 | icalattachtype_set_base64(attach, att->data(), 0); | 520 | icalattachtype_set_base64(attach, att->data(), 0); |
521 | #endif | 521 | #endif |
522 | icalattach *attach; | 522 | icalattach *attach; |
523 | if (att->isURI()) | 523 | if (att->isUri()) |
524 | attach = icalattach_new_from_url( att->uri().utf8().data()); | 524 | attach = icalattach_new_from_url( att->uri().utf8().data()); |
525 | else | 525 | else |
526 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | 526 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); |
527 | icalproperty *p = icalproperty_new_attach(attach); | 527 | icalproperty *p = icalproperty_new_attach(attach); |
528 | if (!att->mimeType().isEmpty()) | 528 | if (!att->mimeType().isEmpty()) |
529 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 529 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
530 | 530 | ||
531 | if (att->isBinary()) { | 531 | if (att->isBinary()) { |
532 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 532 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
533 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 533 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
534 | } | 534 | } |
535 | return p; | 535 | return p; |
536 | } | 536 | } |
537 | 537 | ||
538 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 538 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
539 | { | 539 | { |
540 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 540 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
541 | 541 | ||
542 | icalrecurrencetype r; | 542 | icalrecurrencetype r; |
543 | 543 | ||
544 | icalrecurrencetype_clear(&r); | 544 | icalrecurrencetype_clear(&r); |
545 | 545 | ||
546 | int index = 0; | 546 | int index = 0; |
547 | int index2 = 0; | 547 | int index2 = 0; |
548 | 548 | ||
549 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 549 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
550 | QPtrList<int> tmpDays; | 550 | QPtrList<int> tmpDays; |
551 | int *tmpDay; | 551 | int *tmpDay; |
552 | Recurrence::rMonthPos *tmpPos; | 552 | Recurrence::rMonthPos *tmpPos; |
553 | bool datetime = false; | 553 | bool datetime = false; |
554 | int day; | 554 | int day; |
555 | int i; | 555 | int i; |
556 | 556 | ||
557 | switch(recur->doesRecur()) { | 557 | switch(recur->doesRecur()) { |
558 | case Recurrence::rMinutely: | 558 | case Recurrence::rMinutely: |
559 | r.freq = ICAL_MINUTELY_RECURRENCE; | 559 | r.freq = ICAL_MINUTELY_RECURRENCE; |
560 | datetime = true; | 560 | datetime = true; |
561 | break; | 561 | break; |
562 | case Recurrence::rHourly: | 562 | case Recurrence::rHourly: |
563 | r.freq = ICAL_HOURLY_RECURRENCE; | 563 | r.freq = ICAL_HOURLY_RECURRENCE; |
564 | datetime = true; | 564 | datetime = true; |
565 | break; | 565 | break; |
566 | case Recurrence::rDaily: | 566 | case Recurrence::rDaily: |
567 | r.freq = ICAL_DAILY_RECURRENCE; | 567 | r.freq = ICAL_DAILY_RECURRENCE; |
568 | break; | 568 | break; |
569 | case Recurrence::rWeekly: | 569 | case Recurrence::rWeekly: |
570 | r.freq = ICAL_WEEKLY_RECURRENCE; | 570 | r.freq = ICAL_WEEKLY_RECURRENCE; |
571 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); | 571 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 549014e..39c14f5 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -11,100 +11,107 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = 0;//new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | QPtrListIterator<Attachment> itat( i.mAttachments ); |
63 | Attachment *at; | ||
64 | while( (at = itat.current()) ) { | ||
65 | Attachment *a = new Attachment( *at ); | ||
66 | mAttachments.append( a ); | ||
67 | ++itat; | ||
68 | } | ||
69 | mAttachments.setAutoDelete( true ); | ||
63 | mResources = i.mResources; | 70 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 71 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 72 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 73 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 74 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 75 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 76 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 77 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 78 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 79 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 80 | b->setParent( this ); |
74 | mAlarms.append( b ); | 81 | mAlarms.append( b ); |
75 | 82 | ||
76 | ++it; | 83 | ++it; |
77 | } | 84 | } |
78 | mAlarms.setAutoDelete(true); | 85 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 86 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 87 | mRecurrenceID = i.mRecurrenceID; |
81 | if ( i.mRecurrence ) | 88 | if ( i.mRecurrence ) |
82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
83 | else | 90 | else |
84 | mRecurrence = 0; | 91 | mRecurrence = 0; |
85 | mHoliday = i.mHoliday ; | 92 | mHoliday = i.mHoliday ; |
86 | mBirthday = i.mBirthday; | 93 | mBirthday = i.mBirthday; |
87 | mAnniversary = i.mAnniversary; | 94 | mAnniversary = i.mAnniversary; |
88 | } | 95 | } |
89 | 96 | ||
90 | Incidence::~Incidence() | 97 | Incidence::~Incidence() |
91 | { | 98 | { |
92 | 99 | ||
93 | Incidence *ev; | 100 | Incidence *ev; |
94 | QPtrList<Incidence> Relations = relations(); | 101 | QPtrList<Incidence> Relations = relations(); |
95 | for (ev=Relations.first();ev;ev=Relations.next()) { | 102 | for (ev=Relations.first();ev;ev=Relations.next()) { |
96 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 103 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
97 | } | 104 | } |
98 | if (relatedTo()) relatedTo()->removeRelation(this); | 105 | if (relatedTo()) relatedTo()->removeRelation(this); |
99 | if ( mRecurrence ) | 106 | if ( mRecurrence ) |
100 | delete mRecurrence; | 107 | delete mRecurrence; |
101 | 108 | ||
102 | } | 109 | } |
103 | QString Incidence::durationText() | 110 | QString Incidence::durationText() |
104 | { | 111 | { |
105 | return "---"; | 112 | return "---"; |
106 | } | 113 | } |
107 | QString Incidence::durationText4Time( int offset ) | 114 | QString Incidence::durationText4Time( int offset ) |
108 | { | 115 | { |
109 | int min = offset/60; | 116 | int min = offset/60; |
110 | int hours = min /60; | 117 | int hours = min /60; |
@@ -712,96 +719,97 @@ QStringList Incidence::secrecyList() | |||
712 | 719 | ||
713 | 720 | ||
714 | QPtrList<Alarm> Incidence::alarms() const | 721 | QPtrList<Alarm> Incidence::alarms() const |
715 | { | 722 | { |
716 | return mAlarms; | 723 | return mAlarms; |
717 | } | 724 | } |
718 | 725 | ||
719 | Alarm* Incidence::newAlarm() | 726 | Alarm* Incidence::newAlarm() |
720 | { | 727 | { |
721 | Alarm* alarm = new Alarm(this); | 728 | Alarm* alarm = new Alarm(this); |
722 | mAlarms.append(alarm); | 729 | mAlarms.append(alarm); |
723 | // updated(); | 730 | // updated(); |
724 | return alarm; | 731 | return alarm; |
725 | } | 732 | } |
726 | 733 | ||
727 | void Incidence::addAlarm(Alarm *alarm) | 734 | void Incidence::addAlarm(Alarm *alarm) |
728 | { | 735 | { |
729 | mAlarms.append(alarm); | 736 | mAlarms.append(alarm); |
730 | updated(); | 737 | updated(); |
731 | } | 738 | } |
732 | 739 | ||
733 | void Incidence::removeAlarm(Alarm *alarm) | 740 | void Incidence::removeAlarm(Alarm *alarm) |
734 | { | 741 | { |
735 | mAlarms.removeRef(alarm); | 742 | mAlarms.removeRef(alarm); |
736 | updated(); | 743 | updated(); |
737 | } | 744 | } |
738 | 745 | ||
739 | void Incidence::clearAlarms() | 746 | void Incidence::clearAlarms() |
740 | { | 747 | { |
741 | mAlarms.clear(); | 748 | mAlarms.clear(); |
742 | updated(); | 749 | updated(); |
743 | } | 750 | } |
744 | 751 | ||
745 | bool Incidence::isAlarmEnabled() const | 752 | bool Incidence::isAlarmEnabled() const |
746 | { | 753 | { |
747 | Alarm* alarm; | 754 | Alarm* alarm; |
748 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 755 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
749 | if (alarm->enabled()) | 756 | if (alarm->enabled()) |
750 | return true; | 757 | return true; |
751 | } | 758 | } |
752 | return false; | 759 | return false; |
753 | } | 760 | } |
754 | #include <stdlib.h> | 761 | #include <stdlib.h> |
755 | Recurrence *Incidence::recurrence() | 762 | Recurrence *Incidence::recurrence() |
756 | { | 763 | { |
757 | if ( ! mRecurrence ) { | 764 | if ( ! mRecurrence ) { |
758 | mRecurrence = new Recurrence(this); | 765 | mRecurrence = new Recurrence(this); |
759 | mRecurrence->setRecurStart( dtStart() ); | 766 | mRecurrence->setRecurStart( dtStart() ); |
767 | mRecurrence->setRecurReadOnly( isReadOnly()); | ||
760 | //qDebug("creating new recurence "); | 768 | //qDebug("creating new recurence "); |
761 | //abort(); | 769 | //abort(); |
762 | } | 770 | } |
763 | return mRecurrence; | 771 | return mRecurrence; |
764 | } | 772 | } |
765 | void Incidence::setRecurrence( Recurrence * r) | 773 | void Incidence::setRecurrence( Recurrence * r) |
766 | { | 774 | { |
767 | if ( mRecurrence ) | 775 | if ( mRecurrence ) |
768 | delete mRecurrence; | 776 | delete mRecurrence; |
769 | mRecurrence = r; | 777 | mRecurrence = r; |
770 | } | 778 | } |
771 | 779 | ||
772 | void Incidence::setLocation(const QString &location) | 780 | void Incidence::setLocation(const QString &location) |
773 | { | 781 | { |
774 | if (mReadOnly) return; | 782 | if (mReadOnly) return; |
775 | mLocation = location; | 783 | mLocation = location; |
776 | updated(); | 784 | updated(); |
777 | } | 785 | } |
778 | 786 | ||
779 | QString Incidence::location() const | 787 | QString Incidence::location() const |
780 | { | 788 | { |
781 | return mLocation; | 789 | return mLocation; |
782 | } | 790 | } |
783 | QString Incidence::recurrenceText() const | 791 | QString Incidence::recurrenceText() const |
784 | { | 792 | { |
785 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | 793 | if ( mRecurrence ) return mRecurrence->recurrenceText(); |
786 | return i18n("No"); | 794 | return i18n("No"); |
787 | } | 795 | } |
788 | 796 | ||
789 | ushort Incidence::doesRecur() const | 797 | ushort Incidence::doesRecur() const |
790 | { | 798 | { |
791 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 799 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
792 | else return Recurrence::rNone; | 800 | else return Recurrence::rNone; |
793 | } | 801 | } |
794 | 802 | ||
795 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 803 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
796 | { | 804 | { |
797 | QDateTime incidenceStart = dt; | 805 | QDateTime incidenceStart = dt; |
798 | *ok = false; | 806 | *ok = false; |
799 | if ( doesRecur() ) { | 807 | if ( doesRecur() ) { |
800 | bool last; | 808 | bool last; |
801 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); | 809 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); |
802 | int count = 0; | 810 | int count = 0; |
803 | if ( !last ) { | 811 | if ( !last ) { |
804 | while ( !last ) { | 812 | while ( !last ) { |
805 | ++count; | 813 | ++count; |
806 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); | 814 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); |
807 | if ( recursOn( incidenceStart.date() ) ) { | 815 | if ( recursOn( incidenceStart.date() ) ) { |