-rw-r--r-- | kabc/addressee.cpp | 17 | ||||
-rw-r--r-- | kabc/addressee.h | 3 | ||||
-rw-r--r-- | kabc/field.cpp | 6 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 28 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 21 |
6 files changed, 36 insertions, 41 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7f592e9..155ce24 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,182 +1,181 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | 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. |
10 | 10 | ||
11 | 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, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | 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 |
17 | 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 |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString defaultFormattedName; | ||
55 | QString familyName; | 54 | QString familyName; |
56 | QString givenName; | 55 | QString givenName; |
57 | QString additionalName; | 56 | QString additionalName; |
58 | QString prefix; | 57 | QString prefix; |
59 | QString suffix; | 58 | QString suffix; |
60 | QString nickName; | 59 | QString nickName; |
61 | QDateTime birthday; | 60 | QDateTime birthday; |
62 | QString mailer; | 61 | QString mailer; |
63 | TimeZone timeZone; | 62 | TimeZone timeZone; |
64 | Geo geo; | 63 | Geo geo; |
65 | QString title; | 64 | QString title; |
66 | QString role; | 65 | QString role; |
67 | QString organization; | 66 | QString organization; |
68 | QString note; | 67 | QString note; |
69 | QString productId; | 68 | QString productId; |
70 | QDateTime revision; | 69 | QDateTime revision; |
71 | QString sortString; | 70 | QString sortString; |
72 | QString externalUID; | 71 | QString externalUID; |
73 | QString originalExternalUID; | 72 | QString originalExternalUID; |
74 | KURL url; | 73 | KURL url; |
75 | Secrecy secrecy; | 74 | Secrecy secrecy; |
76 | Picture logo; | 75 | Picture logo; |
77 | Picture photo; | 76 | Picture photo; |
78 | Sound sound; | 77 | Sound sound; |
79 | Agent agent; | 78 | Agent agent; |
80 | QString mExternalId; | 79 | QString mExternalId; |
81 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
82 | Address::List addresses; | 81 | Address::List addresses; |
83 | Key::List keys; | 82 | Key::List keys; |
84 | QStringList emails; | 83 | QStringList emails; |
85 | QStringList categories; | 84 | QStringList categories; |
86 | QStringList custom; | 85 | QStringList custom; |
87 | int mTempSyncStat; | 86 | int mTempSyncStat; |
88 | Resource *resource; | 87 | Resource *resource; |
89 | 88 | ||
90 | bool empty :1; | 89 | bool empty :1; |
91 | bool changed :1; | 90 | bool changed :1; |
92 | bool tagged :1; | 91 | bool tagged :1; |
93 | }; | 92 | }; |
94 | 93 | ||
95 | Addressee::Addressee() | 94 | Addressee::Addressee() |
96 | { | 95 | { |
97 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
98 | mData->empty = true; | 97 | mData->empty = true; |
99 | mData->changed = false; | 98 | mData->changed = false; |
100 | mData->resource = 0; | 99 | mData->resource = 0; |
101 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
102 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
103 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
104 | } | 103 | } |
105 | 104 | ||
106 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
107 | { | 106 | { |
108 | } | 107 | } |
109 | 108 | ||
110 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
111 | { | 110 | { |
112 | mData = a.mData; | 111 | mData = a.mData; |
113 | } | 112 | } |
114 | 113 | ||
115 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
116 | { | 115 | { |
117 | mData = a.mData; | 116 | mData = a.mData; |
118 | return (*this); | 117 | return (*this); |
119 | } | 118 | } |
120 | 119 | ||
121 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
122 | { | 121 | { |
123 | Addressee a; | 122 | Addressee a; |
124 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
125 | return a; | 124 | return a; |
126 | } | 125 | } |
127 | 126 | ||
128 | void Addressee::detach() | 127 | void Addressee::detach() |
129 | { | 128 | { |
130 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
131 | *this = copy(); | 130 | *this = copy(); |
132 | } | 131 | } |
133 | 132 | ||
134 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
135 | { | 134 | { |
136 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
137 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
138 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
139 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
140 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
141 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
142 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
143 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
144 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
145 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
146 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
147 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
148 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
149 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
150 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
151 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
152 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
153 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
154 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
155 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
156 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
157 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
158 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
159 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
160 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
161 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
162 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
163 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
164 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
165 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
166 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
167 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
168 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
169 | 168 | ||
170 | return true; | 169 | return true; |
171 | } | 170 | } |
172 | 171 | ||
173 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
174 | { | 173 | { |
175 | return !( a == *this ); | 174 | return !( a == *this ); |
176 | } | 175 | } |
177 | 176 | ||
178 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
179 | { | 178 | { |
180 | return mData->empty; | 179 | return mData->empty; |
181 | } | 180 | } |
182 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
@@ -623,283 +622,267 @@ void Addressee::removeID(const QString &prof) | |||
623 | { | 622 | { |
624 | detach(); | 623 | detach(); |
625 | if ( prof.isEmpty() ) | 624 | if ( prof.isEmpty() ) |
626 | mData->mExternalId = ":"; | 625 | mData->mExternalId = ":"; |
627 | else | 626 | else |
628 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 627 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
629 | 628 | ||
630 | } | 629 | } |
631 | void Addressee::setID( const QString & prof , const QString & id ) | 630 | void Addressee::setID( const QString & prof , const QString & id ) |
632 | { | 631 | { |
633 | detach(); | 632 | detach(); |
634 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 633 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
635 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 634 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
636 | } | 635 | } |
637 | void Addressee::setTempSyncStat( int id ) | 636 | void Addressee::setTempSyncStat( int id ) |
638 | { | 637 | { |
639 | if ( mData->mTempSyncStat == id ) return; | 638 | if ( mData->mTempSyncStat == id ) return; |
640 | detach(); | 639 | detach(); |
641 | mData->mTempSyncStat = id; | 640 | mData->mTempSyncStat = id; |
642 | } | 641 | } |
643 | int Addressee::tempSyncStat() const | 642 | int Addressee::tempSyncStat() const |
644 | { | 643 | { |
645 | return mData->mTempSyncStat; | 644 | return mData->mTempSyncStat; |
646 | } | 645 | } |
647 | 646 | ||
648 | const QString Addressee::getID( const QString & prof) const | 647 | const QString Addressee::getID( const QString & prof) const |
649 | { | 648 | { |
650 | return KIdManager::getId ( mData->mExternalId, prof ); | 649 | return KIdManager::getId ( mData->mExternalId, prof ); |
651 | } | 650 | } |
652 | 651 | ||
653 | void Addressee::setCsum( const QString & prof , const QString & id ) | 652 | void Addressee::setCsum( const QString & prof , const QString & id ) |
654 | { | 653 | { |
655 | detach(); | 654 | detach(); |
656 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 655 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
657 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 656 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
658 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 657 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
659 | } | 658 | } |
660 | 659 | ||
661 | const QString Addressee::getCsum( const QString & prof) const | 660 | const QString Addressee::getCsum( const QString & prof) const |
662 | { | 661 | { |
663 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 662 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
664 | } | 663 | } |
665 | 664 | ||
666 | void Addressee::setIDStr( const QString & s ) | 665 | void Addressee::setIDStr( const QString & s ) |
667 | { | 666 | { |
668 | detach(); | 667 | detach(); |
669 | mData->mExternalId = s; | 668 | mData->mExternalId = s; |
670 | } | 669 | } |
671 | 670 | ||
672 | const QString Addressee::IDStr() const | 671 | const QString Addressee::IDStr() const |
673 | { | 672 | { |
674 | return mData->mExternalId; | 673 | return mData->mExternalId; |
675 | } | 674 | } |
676 | 675 | ||
677 | void Addressee::setExternalUID( const QString &id ) | 676 | void Addressee::setExternalUID( const QString &id ) |
678 | { | 677 | { |
679 | if ( id == mData->externalUID ) return; | 678 | if ( id == mData->externalUID ) return; |
680 | detach(); | 679 | detach(); |
681 | mData->empty = false; | 680 | mData->empty = false; |
682 | mData->externalUID = id; | 681 | mData->externalUID = id; |
683 | } | 682 | } |
684 | 683 | ||
685 | const QString Addressee::externalUID() const | 684 | const QString Addressee::externalUID() const |
686 | { | 685 | { |
687 | return mData->externalUID; | 686 | return mData->externalUID; |
688 | } | 687 | } |
689 | void Addressee::setOriginalExternalUID( const QString &id ) | 688 | void Addressee::setOriginalExternalUID( const QString &id ) |
690 | { | 689 | { |
691 | if ( id == mData->originalExternalUID ) return; | 690 | if ( id == mData->originalExternalUID ) return; |
692 | detach(); | 691 | detach(); |
693 | mData->empty = false; | 692 | mData->empty = false; |
694 | //qDebug("*******Set orig uid %s ", id.latin1()); | 693 | //qDebug("*******Set orig uid %s ", id.latin1()); |
695 | mData->originalExternalUID = id; | 694 | mData->originalExternalUID = id; |
696 | } | 695 | } |
697 | 696 | ||
698 | QString Addressee::originalExternalUID() const | 697 | QString Addressee::originalExternalUID() const |
699 | { | 698 | { |
700 | return mData->originalExternalUID; | 699 | return mData->originalExternalUID; |
701 | } | 700 | } |
702 | 701 | ||
703 | void Addressee::setUid( const QString &id ) | 702 | void Addressee::setUid( const QString &id ) |
704 | { | 703 | { |
705 | if ( id == mData->uid ) return; | 704 | if ( id == mData->uid ) return; |
706 | detach(); | 705 | detach(); |
707 | //qDebug("****setuid %s ", id.latin1()); | 706 | //qDebug("****setuid %s ", id.latin1()); |
708 | mData->empty = false; | 707 | mData->empty = false; |
709 | mData->uid = id; | 708 | mData->uid = id; |
710 | } | 709 | } |
711 | 710 | ||
712 | const QString Addressee::uid() const | 711 | const QString Addressee::uid() const |
713 | { | 712 | { |
714 | if ( mData->uid.isEmpty() ) | 713 | if ( mData->uid.isEmpty() ) |
715 | mData->uid = KApplication::randomString( 10 ); | 714 | mData->uid = KApplication::randomString( 10 ); |
716 | 715 | ||
717 | return mData->uid; | 716 | return mData->uid; |
718 | } | 717 | } |
719 | 718 | ||
720 | QString Addressee::uidLabel() | 719 | QString Addressee::uidLabel() |
721 | { | 720 | { |
722 | return i18n("Unique Identifier"); | 721 | return i18n("Unique Identifier"); |
723 | } | 722 | } |
724 | 723 | ||
725 | void Addressee::setName( const QString &name ) | 724 | void Addressee::setName( const QString &name ) |
726 | { | 725 | { |
727 | if ( name == mData->name ) return; | 726 | if ( name == mData->name ) return; |
728 | detach(); | 727 | detach(); |
729 | mData->empty = false; | 728 | mData->empty = false; |
730 | mData->name = name; | 729 | mData->name = name; |
731 | } | 730 | } |
732 | 731 | ||
733 | QString Addressee::name() const | 732 | QString Addressee::name() const |
734 | { | 733 | { |
735 | return mData->name; | 734 | return mData->name; |
736 | } | 735 | } |
737 | 736 | ||
738 | QString Addressee::nameLabel() | 737 | QString Addressee::nameLabel() |
739 | { | 738 | { |
740 | return i18n("Name"); | 739 | return i18n("Name"); |
741 | } | 740 | } |
742 | 741 | ||
743 | 742 | ||
744 | void Addressee::setFormattedName( const QString &formattedName ) | 743 | void Addressee::setFormattedName( const QString &formattedName ) |
745 | { | 744 | { |
746 | if ( formattedName == mData->formattedName ) return; | 745 | if ( formattedName == mData->formattedName ) return; |
747 | detach(); | 746 | detach(); |
748 | mData->empty = false; | 747 | mData->empty = false; |
749 | mData->formattedName = formattedName; | 748 | mData->formattedName = formattedName; |
750 | } | 749 | } |
751 | void Addressee::setDefaultFormattedName( const QString &formattedName ) | ||
752 | { | ||
753 | if ( formattedName == mData->defaultFormattedName ) return; | ||
754 | detach(); | ||
755 | mData->empty = false; | ||
756 | mData->defaultFormattedName = formattedName; | ||
757 | } | ||
758 | 750 | ||
759 | QString Addressee::formattedName() const | 751 | QString Addressee::formattedName() const |
760 | { | 752 | { |
761 | return mData->formattedName; | 753 | return mData->formattedName; |
762 | } | 754 | } |
763 | QString Addressee::defaultFormattedName() const | ||
764 | { | ||
765 | return mData->defaultFormattedName; | ||
766 | } | ||
767 | 755 | ||
768 | QString Addressee::formattedNameLabel() | 756 | QString Addressee::formattedNameLabel() |
769 | { | 757 | { |
770 | return i18n("Formatted Name"); | 758 | return i18n("Formatted Name"); |
771 | } | 759 | } |
772 | 760 | ||
773 | QString Addressee::defaultFormattedNameLabel() | ||
774 | { | ||
775 | return i18n("Def.Formatted Name"); | ||
776 | } | ||
777 | |||
778 | 761 | ||
779 | void Addressee::setFamilyName( const QString &familyName ) | 762 | void Addressee::setFamilyName( const QString &familyName ) |
780 | { | 763 | { |
781 | if ( familyName == mData->familyName ) return; | 764 | if ( familyName == mData->familyName ) return; |
782 | detach(); | 765 | detach(); |
783 | mData->empty = false; | 766 | mData->empty = false; |
784 | mData->familyName = familyName; | 767 | mData->familyName = familyName; |
785 | } | 768 | } |
786 | 769 | ||
787 | QString Addressee::familyName() const | 770 | QString Addressee::familyName() const |
788 | { | 771 | { |
789 | return mData->familyName; | 772 | return mData->familyName; |
790 | } | 773 | } |
791 | 774 | ||
792 | QString Addressee::familyNameLabel() | 775 | QString Addressee::familyNameLabel() |
793 | { | 776 | { |
794 | return i18n("Family Name"); | 777 | return i18n("Family Name"); |
795 | } | 778 | } |
796 | 779 | ||
797 | 780 | ||
798 | void Addressee::setGivenName( const QString &givenName ) | 781 | void Addressee::setGivenName( const QString &givenName ) |
799 | { | 782 | { |
800 | if ( givenName == mData->givenName ) return; | 783 | if ( givenName == mData->givenName ) return; |
801 | detach(); | 784 | detach(); |
802 | mData->empty = false; | 785 | mData->empty = false; |
803 | mData->givenName = givenName; | 786 | mData->givenName = givenName; |
804 | } | 787 | } |
805 | 788 | ||
806 | QString Addressee::givenName() const | 789 | QString Addressee::givenName() const |
807 | { | 790 | { |
808 | return mData->givenName; | 791 | return mData->givenName; |
809 | } | 792 | } |
810 | 793 | ||
811 | QString Addressee::givenNameLabel() | 794 | QString Addressee::givenNameLabel() |
812 | { | 795 | { |
813 | return i18n("Given Name"); | 796 | return i18n("Given Name"); |
814 | } | 797 | } |
815 | 798 | ||
816 | 799 | ||
817 | void Addressee::setAdditionalName( const QString &additionalName ) | 800 | void Addressee::setAdditionalName( const QString &additionalName ) |
818 | { | 801 | { |
819 | if ( additionalName == mData->additionalName ) return; | 802 | if ( additionalName == mData->additionalName ) return; |
820 | detach(); | 803 | detach(); |
821 | mData->empty = false; | 804 | mData->empty = false; |
822 | mData->additionalName = additionalName; | 805 | mData->additionalName = additionalName; |
823 | } | 806 | } |
824 | 807 | ||
825 | QString Addressee::additionalName() const | 808 | QString Addressee::additionalName() const |
826 | { | 809 | { |
827 | return mData->additionalName; | 810 | return mData->additionalName; |
828 | } | 811 | } |
829 | 812 | ||
830 | QString Addressee::additionalNameLabel() | 813 | QString Addressee::additionalNameLabel() |
831 | { | 814 | { |
832 | return i18n("Additional Names"); | 815 | return i18n("Additional Names"); |
833 | } | 816 | } |
834 | 817 | ||
835 | 818 | ||
836 | void Addressee::setPrefix( const QString &prefix ) | 819 | void Addressee::setPrefix( const QString &prefix ) |
837 | { | 820 | { |
838 | if ( prefix == mData->prefix ) return; | 821 | if ( prefix == mData->prefix ) return; |
839 | detach(); | 822 | detach(); |
840 | mData->empty = false; | 823 | mData->empty = false; |
841 | mData->prefix = prefix; | 824 | mData->prefix = prefix; |
842 | } | 825 | } |
843 | 826 | ||
844 | QString Addressee::prefix() const | 827 | QString Addressee::prefix() const |
845 | { | 828 | { |
846 | return mData->prefix; | 829 | return mData->prefix; |
847 | } | 830 | } |
848 | 831 | ||
849 | QString Addressee::prefixLabel() | 832 | QString Addressee::prefixLabel() |
850 | { | 833 | { |
851 | return i18n("Honorific Prefixes"); | 834 | return i18n("Honorific Prefixes"); |
852 | } | 835 | } |
853 | 836 | ||
854 | 837 | ||
855 | void Addressee::setSuffix( const QString &suffix ) | 838 | void Addressee::setSuffix( const QString &suffix ) |
856 | { | 839 | { |
857 | if ( suffix == mData->suffix ) return; | 840 | if ( suffix == mData->suffix ) return; |
858 | detach(); | 841 | detach(); |
859 | mData->empty = false; | 842 | mData->empty = false; |
860 | mData->suffix = suffix; | 843 | mData->suffix = suffix; |
861 | } | 844 | } |
862 | 845 | ||
863 | QString Addressee::suffix() const | 846 | QString Addressee::suffix() const |
864 | { | 847 | { |
865 | return mData->suffix; | 848 | return mData->suffix; |
866 | } | 849 | } |
867 | 850 | ||
868 | QString Addressee::suffixLabel() | 851 | QString Addressee::suffixLabel() |
869 | { | 852 | { |
870 | return i18n("Honorific Suffixes"); | 853 | return i18n("Honorific Suffixes"); |
871 | } | 854 | } |
872 | 855 | ||
873 | 856 | ||
874 | void Addressee::setNickName( const QString &nickName ) | 857 | void Addressee::setNickName( const QString &nickName ) |
875 | { | 858 | { |
876 | if ( nickName == mData->nickName ) return; | 859 | if ( nickName == mData->nickName ) return; |
877 | detach(); | 860 | detach(); |
878 | mData->empty = false; | 861 | mData->empty = false; |
879 | mData->nickName = nickName; | 862 | mData->nickName = nickName; |
880 | } | 863 | } |
881 | 864 | ||
882 | QString Addressee::nickName() const | 865 | QString Addressee::nickName() const |
883 | { | 866 | { |
884 | return mData->nickName; | 867 | return mData->nickName; |
885 | } | 868 | } |
886 | 869 | ||
887 | QString Addressee::nickNameLabel() | 870 | QString Addressee::nickNameLabel() |
888 | { | 871 | { |
889 | return i18n("Nick Name"); | 872 | return i18n("Nick Name"); |
890 | } | 873 | } |
891 | 874 | ||
892 | 875 | ||
893 | void Addressee::setBirthday( const QDateTime &birthday ) | 876 | void Addressee::setBirthday( const QDateTime &birthday ) |
894 | { | 877 | { |
895 | if ( birthday == mData->birthday ) return; | 878 | if ( birthday == mData->birthday ) return; |
896 | detach(); | 879 | detach(); |
897 | mData->empty = false; | 880 | mData->empty = false; |
898 | mData->birthday = birthday; | 881 | mData->birthday = birthday; |
899 | } | 882 | } |
900 | 883 | ||
901 | QDateTime Addressee::birthday() const | 884 | QDateTime Addressee::birthday() const |
902 | { | 885 | { |
903 | return mData->birthday; | 886 | return mData->birthday; |
904 | } | 887 | } |
905 | 888 | ||
diff --git a/kabc/addressee.h b/kabc/addressee.h index 0d688f8..a2fbcf5 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -29,267 +29,264 @@ $Id$ | |||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | const QString IDStr() const; | 103 | const QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | const QString getID( const QString & ) const; | 105 | const QString getID( const QString & ) const; |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | const QString getCsum( const QString & ) const ; | 107 | const QString getCsum( const QString & ) const ; |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | const QString externalUID() const; | 116 | const QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad, bool isSubSet ); | 119 | void mergeContact( const Addressee& ad, bool isSubSet ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | bool containsAdr(const Addressee& addr ); | 125 | bool containsAdr(const Addressee& addr ); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | Set unique identifier. | 128 | Set unique identifier. |
129 | */ | 129 | */ |
130 | void setUid( const QString &uid ); | 130 | void setUid( const QString &uid ); |
131 | /** | 131 | /** |
132 | Return unique identifier. | 132 | Return unique identifier. |
133 | */ | 133 | */ |
134 | const QString uid() const; | 134 | const QString uid() const; |
135 | /** | 135 | /** |
136 | Return translated label for uid field. | 136 | Return translated label for uid field. |
137 | */ | 137 | */ |
138 | static QString uidLabel(); | 138 | static QString uidLabel(); |
139 | 139 | ||
140 | /** | 140 | /** |
141 | Set name. | 141 | Set name. |
142 | */ | 142 | */ |
143 | void setName( const QString &name ); | 143 | void setName( const QString &name ); |
144 | /** | 144 | /** |
145 | Return name. | 145 | Return name. |
146 | */ | 146 | */ |
147 | QString name() const; | 147 | QString name() const; |
148 | /** | 148 | /** |
149 | Return translated label for name field. | 149 | Return translated label for name field. |
150 | */ | 150 | */ |
151 | static QString nameLabel(); | 151 | static QString nameLabel(); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | Set formatted name. | 154 | Set formatted name. |
155 | */ | 155 | */ |
156 | void setFormattedName( const QString &formattedName ); | 156 | void setFormattedName( const QString &formattedName ); |
157 | void setDefaultFormattedName( const QString &formattedName ); | ||
158 | /** | 157 | /** |
159 | Return formatted name. | 158 | Return formatted name. |
160 | */ | 159 | */ |
161 | QString formattedName() const; | 160 | QString formattedName() const; |
162 | QString defaultFormattedName() const; | ||
163 | /** | 161 | /** |
164 | Return translated label for formattedName field. | 162 | Return translated label for formattedName field. |
165 | */ | 163 | */ |
166 | static QString formattedNameLabel(); | 164 | static QString formattedNameLabel(); |
167 | static QString defaultFormattedNameLabel(); | ||
168 | 165 | ||
169 | /** | 166 | /** |
170 | Set family name. | 167 | Set family name. |
171 | */ | 168 | */ |
172 | void setFamilyName( const QString &familyName ); | 169 | void setFamilyName( const QString &familyName ); |
173 | /** | 170 | /** |
174 | Return family name. | 171 | Return family name. |
175 | */ | 172 | */ |
176 | QString familyName() const; | 173 | QString familyName() const; |
177 | /** | 174 | /** |
178 | Return translated label for familyName field. | 175 | Return translated label for familyName field. |
179 | */ | 176 | */ |
180 | static QString familyNameLabel(); | 177 | static QString familyNameLabel(); |
181 | 178 | ||
182 | /** | 179 | /** |
183 | Set given name. | 180 | Set given name. |
184 | */ | 181 | */ |
185 | void setGivenName( const QString &givenName ); | 182 | void setGivenName( const QString &givenName ); |
186 | /** | 183 | /** |
187 | Return given name. | 184 | Return given name. |
188 | */ | 185 | */ |
189 | QString givenName() const; | 186 | QString givenName() const; |
190 | /** | 187 | /** |
191 | Return translated label for givenName field. | 188 | Return translated label for givenName field. |
192 | */ | 189 | */ |
193 | static QString givenNameLabel(); | 190 | static QString givenNameLabel(); |
194 | 191 | ||
195 | /** | 192 | /** |
196 | Set additional names. | 193 | Set additional names. |
197 | */ | 194 | */ |
198 | void setAdditionalName( const QString &additionalName ); | 195 | void setAdditionalName( const QString &additionalName ); |
199 | /** | 196 | /** |
200 | Return additional names. | 197 | Return additional names. |
201 | */ | 198 | */ |
202 | QString additionalName() const; | 199 | QString additionalName() const; |
203 | /** | 200 | /** |
204 | Return translated label for additionalName field. | 201 | Return translated label for additionalName field. |
205 | */ | 202 | */ |
206 | static QString additionalNameLabel(); | 203 | static QString additionalNameLabel(); |
207 | 204 | ||
208 | /** | 205 | /** |
209 | Set honorific prefixes. | 206 | Set honorific prefixes. |
210 | */ | 207 | */ |
211 | void setPrefix( const QString &prefix ); | 208 | void setPrefix( const QString &prefix ); |
212 | /** | 209 | /** |
213 | Return honorific prefixes. | 210 | Return honorific prefixes. |
214 | */ | 211 | */ |
215 | QString prefix() const; | 212 | QString prefix() const; |
216 | /** | 213 | /** |
217 | Return translated label for prefix field. | 214 | Return translated label for prefix field. |
218 | */ | 215 | */ |
219 | static QString prefixLabel(); | 216 | static QString prefixLabel(); |
220 | 217 | ||
221 | /** | 218 | /** |
222 | Set honorific suffixes. | 219 | Set honorific suffixes. |
223 | */ | 220 | */ |
224 | void setSuffix( const QString &suffix ); | 221 | void setSuffix( const QString &suffix ); |
225 | /** | 222 | /** |
226 | Return honorific suffixes. | 223 | Return honorific suffixes. |
227 | */ | 224 | */ |
228 | QString suffix() const; | 225 | QString suffix() const; |
229 | /** | 226 | /** |
230 | Return translated label for suffix field. | 227 | Return translated label for suffix field. |
231 | */ | 228 | */ |
232 | static QString suffixLabel(); | 229 | static QString suffixLabel(); |
233 | 230 | ||
234 | /** | 231 | /** |
235 | Set nick name. | 232 | Set nick name. |
236 | */ | 233 | */ |
237 | void setNickName( const QString &nickName ); | 234 | void setNickName( const QString &nickName ); |
238 | /** | 235 | /** |
239 | Return nick name. | 236 | Return nick name. |
240 | */ | 237 | */ |
241 | QString nickName() const; | 238 | QString nickName() const; |
242 | /** | 239 | /** |
243 | Return translated label for nickName field. | 240 | Return translated label for nickName field. |
244 | */ | 241 | */ |
245 | static QString nickNameLabel(); | 242 | static QString nickNameLabel(); |
246 | 243 | ||
247 | /** | 244 | /** |
248 | Set birthday. | 245 | Set birthday. |
249 | */ | 246 | */ |
250 | void setBirthday( const QDateTime &birthday ); | 247 | void setBirthday( const QDateTime &birthday ); |
251 | /** | 248 | /** |
252 | Return birthday. | 249 | Return birthday. |
253 | */ | 250 | */ |
254 | QDateTime birthday() const; | 251 | QDateTime birthday() const; |
255 | /** | 252 | /** |
256 | Return translated label for birthday field. | 253 | Return translated label for birthday field. |
257 | */ | 254 | */ |
258 | static QString birthdayLabel(); | 255 | static QString birthdayLabel(); |
259 | 256 | ||
260 | /** | 257 | /** |
261 | Return translated label for homeAddressStreet field. | 258 | Return translated label for homeAddressStreet field. |
262 | */ | 259 | */ |
263 | static QString homeAddressStreetLabel(); | 260 | static QString homeAddressStreetLabel(); |
264 | 261 | ||
265 | /** | 262 | /** |
266 | Return translated label for homeAddressLocality field. | 263 | Return translated label for homeAddressLocality field. |
267 | */ | 264 | */ |
268 | static QString homeAddressLocalityLabel(); | 265 | static QString homeAddressLocalityLabel(); |
269 | 266 | ||
270 | /** | 267 | /** |
271 | Return translated label for homeAddressRegion field. | 268 | Return translated label for homeAddressRegion field. |
272 | */ | 269 | */ |
273 | static QString homeAddressRegionLabel(); | 270 | static QString homeAddressRegionLabel(); |
274 | 271 | ||
275 | /** | 272 | /** |
276 | Return translated label for homeAddressPostalCode field. | 273 | Return translated label for homeAddressPostalCode field. |
277 | */ | 274 | */ |
278 | static QString homeAddressPostalCodeLabel(); | 275 | static QString homeAddressPostalCodeLabel(); |
279 | 276 | ||
280 | /** | 277 | /** |
281 | Return translated label for homeAddressCountry field. | 278 | Return translated label for homeAddressCountry field. |
282 | */ | 279 | */ |
283 | static QString homeAddressCountryLabel(); | 280 | static QString homeAddressCountryLabel(); |
284 | 281 | ||
285 | /** | 282 | /** |
286 | Return translated label for homeAddressLabel field. | 283 | Return translated label for homeAddressLabel field. |
287 | */ | 284 | */ |
288 | static QString homeAddressLabelLabel(); | 285 | static QString homeAddressLabelLabel(); |
289 | 286 | ||
290 | /** | 287 | /** |
291 | Return translated label for businessAddressStreet field. | 288 | Return translated label for businessAddressStreet field. |
292 | */ | 289 | */ |
293 | static QString businessAddressStreetLabel(); | 290 | static QString businessAddressStreetLabel(); |
294 | 291 | ||
295 | /** | 292 | /** |
diff --git a/kabc/field.cpp b/kabc/field.cpp index 5c561c3..fd51026 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -1,539 +1,533 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | 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. |
10 | 10 | ||
11 | 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, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | 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 |
17 | 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 |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | 33 | ||
34 | #include "field.h" | 34 | #include "field.h" |
35 | #include "resource.h" | 35 | #include "resource.h" |
36 | 36 | ||
37 | using namespace KABC; | 37 | using namespace KABC; |
38 | 38 | ||
39 | class Field::FieldImpl | 39 | class Field::FieldImpl |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | FieldImpl( int fieldId, int category = 0, | 42 | FieldImpl( int fieldId, int category = 0, |
43 | const QString &label = QString::null, | 43 | const QString &label = QString::null, |
44 | const QString &key = QString::null, | 44 | const QString &key = QString::null, |
45 | const QString &app = QString::null ) | 45 | const QString &app = QString::null ) |
46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), | 46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), |
47 | mKey( key ), mApp( app ) {} | 47 | mKey( key ), mApp( app ) {} |
48 | 48 | ||
49 | enum FieldId | 49 | enum FieldId |
50 | { | 50 | { |
51 | CustomField, | 51 | CustomField, |
52 | FormattedName, | 52 | FormattedName, |
53 | FamilyName, | 53 | FamilyName, |
54 | GivenName, | 54 | GivenName, |
55 | AdditionalName, | 55 | AdditionalName, |
56 | Prefix, | 56 | Prefix, |
57 | Suffix, | 57 | Suffix, |
58 | NickName, | 58 | NickName, |
59 | Birthday, | 59 | Birthday, |
60 | Category, | 60 | Category, |
61 | HomeAddressStreet, | 61 | HomeAddressStreet, |
62 | HomeAddressLocality, | 62 | HomeAddressLocality, |
63 | HomeAddressRegion, | 63 | HomeAddressRegion, |
64 | HomeAddressPostalCode, | 64 | HomeAddressPostalCode, |
65 | HomeAddressCountry, | 65 | HomeAddressCountry, |
66 | HomeAddressLabel, | 66 | HomeAddressLabel, |
67 | BusinessAddressStreet, | 67 | BusinessAddressStreet, |
68 | BusinessAddressLocality, | 68 | BusinessAddressLocality, |
69 | BusinessAddressRegion, | 69 | BusinessAddressRegion, |
70 | BusinessAddressPostalCode, | 70 | BusinessAddressPostalCode, |
71 | BusinessAddressCountry, | 71 | BusinessAddressCountry, |
72 | BusinessAddressLabel, | 72 | BusinessAddressLabel, |
73 | HomePhone, | 73 | HomePhone, |
74 | BusinessPhone, | 74 | BusinessPhone, |
75 | MobilePhone, | 75 | MobilePhone, |
76 | HomeFax, | 76 | HomeFax, |
77 | BusinessFax, | 77 | BusinessFax, |
78 | CarPhone, | 78 | CarPhone, |
79 | Isdn, | 79 | Isdn, |
80 | Pager, | 80 | Pager, |
81 | Email, | 81 | Email, |
82 | Mailer, | 82 | Mailer, |
83 | Title, | 83 | Title, |
84 | Role, | 84 | Role, |
85 | Organization, | 85 | Organization, |
86 | Note, | 86 | Note, |
87 | Url, | 87 | Url, |
88 | Resource, | 88 | Resource, |
89 | Sip, | 89 | Sip, |
90 | DefaultFormattedName, | ||
91 | MobileWorkPhone, | 90 | MobileWorkPhone, |
92 | MobileHomePhone | 91 | MobileHomePhone |
93 | }; | 92 | }; |
94 | 93 | ||
95 | int fieldId() { return mFieldId; } | 94 | int fieldId() { return mFieldId; } |
96 | int category() { return mCategory; } | 95 | int category() { return mCategory; } |
97 | 96 | ||
98 | QString label() { return mLabel; } | 97 | QString label() { return mLabel; } |
99 | QString key() { return mKey; } | 98 | QString key() { return mKey; } |
100 | QString app() { return mApp; } | 99 | QString app() { return mApp; } |
101 | 100 | ||
102 | private: | 101 | private: |
103 | int mFieldId; | 102 | int mFieldId; |
104 | int mCategory; | 103 | int mCategory; |
105 | 104 | ||
106 | QString mLabel; | 105 | QString mLabel; |
107 | QString mKey; | 106 | QString mKey; |
108 | QString mApp; | 107 | QString mApp; |
109 | }; | 108 | }; |
110 | 109 | ||
111 | 110 | ||
112 | Field::List Field::mAllFields; | 111 | Field::List Field::mAllFields; |
113 | Field::List Field::mDefaultFields; | 112 | Field::List Field::mDefaultFields; |
114 | Field::List Field::mCustomFields; | 113 | Field::List Field::mCustomFields; |
115 | 114 | ||
116 | 115 | ||
117 | Field::Field( FieldImpl *impl ) | 116 | Field::Field( FieldImpl *impl ) |
118 | { | 117 | { |
119 | mImpl = impl; | 118 | mImpl = impl; |
120 | } | 119 | } |
121 | 120 | ||
122 | Field::~Field() | 121 | Field::~Field() |
123 | { | 122 | { |
124 | delete mImpl; | 123 | delete mImpl; |
125 | } | 124 | } |
126 | 125 | ||
127 | QString Field::label() | 126 | QString Field::label() |
128 | { | 127 | { |
129 | switch ( mImpl->fieldId() ) { | 128 | switch ( mImpl->fieldId() ) { |
130 | case FieldImpl::FormattedName: | 129 | case FieldImpl::FormattedName: |
131 | return Addressee::formattedNameLabel(); | 130 | return Addressee::formattedNameLabel(); |
132 | case FieldImpl::DefaultFormattedName: | ||
133 | return Addressee::defaultFormattedNameLabel(); | ||
134 | case FieldImpl::FamilyName: | 131 | case FieldImpl::FamilyName: |
135 | return Addressee::familyNameLabel(); | 132 | return Addressee::familyNameLabel(); |
136 | case FieldImpl::GivenName: | 133 | case FieldImpl::GivenName: |
137 | return Addressee::givenNameLabel(); | 134 | return Addressee::givenNameLabel(); |
138 | case FieldImpl::AdditionalName: | 135 | case FieldImpl::AdditionalName: |
139 | return Addressee::additionalNameLabel(); | 136 | return Addressee::additionalNameLabel(); |
140 | case FieldImpl::Prefix: | 137 | case FieldImpl::Prefix: |
141 | return Addressee::prefixLabel(); | 138 | return Addressee::prefixLabel(); |
142 | case FieldImpl::Suffix: | 139 | case FieldImpl::Suffix: |
143 | return Addressee::suffixLabel(); | 140 | return Addressee::suffixLabel(); |
144 | case FieldImpl::NickName: | 141 | case FieldImpl::NickName: |
145 | return Addressee::nickNameLabel(); | 142 | return Addressee::nickNameLabel(); |
146 | case FieldImpl::Birthday: | 143 | case FieldImpl::Birthday: |
147 | return Addressee::birthdayLabel(); | 144 | return Addressee::birthdayLabel(); |
148 | case FieldImpl::HomeAddressStreet: | 145 | case FieldImpl::HomeAddressStreet: |
149 | return Addressee::homeAddressStreetLabel(); | 146 | return Addressee::homeAddressStreetLabel(); |
150 | case FieldImpl::HomeAddressLocality: | 147 | case FieldImpl::HomeAddressLocality: |
151 | return Addressee::homeAddressLocalityLabel(); | 148 | return Addressee::homeAddressLocalityLabel(); |
152 | case FieldImpl::HomeAddressRegion: | 149 | case FieldImpl::HomeAddressRegion: |
153 | return Addressee::homeAddressRegionLabel(); | 150 | return Addressee::homeAddressRegionLabel(); |
154 | case FieldImpl::HomeAddressPostalCode: | 151 | case FieldImpl::HomeAddressPostalCode: |
155 | return Addressee::homeAddressPostalCodeLabel(); | 152 | return Addressee::homeAddressPostalCodeLabel(); |
156 | case FieldImpl::HomeAddressCountry: | 153 | case FieldImpl::HomeAddressCountry: |
157 | return Addressee::homeAddressCountryLabel(); | 154 | return Addressee::homeAddressCountryLabel(); |
158 | case FieldImpl::HomeAddressLabel: | 155 | case FieldImpl::HomeAddressLabel: |
159 | return Addressee::homeAddressLabelLabel(); | 156 | return Addressee::homeAddressLabelLabel(); |
160 | case FieldImpl::BusinessAddressStreet: | 157 | case FieldImpl::BusinessAddressStreet: |
161 | return Addressee::businessAddressStreetLabel(); | 158 | return Addressee::businessAddressStreetLabel(); |
162 | case FieldImpl::BusinessAddressLocality: | 159 | case FieldImpl::BusinessAddressLocality: |
163 | return Addressee::businessAddressLocalityLabel(); | 160 | return Addressee::businessAddressLocalityLabel(); |
164 | case FieldImpl::BusinessAddressRegion: | 161 | case FieldImpl::BusinessAddressRegion: |
165 | return Addressee::businessAddressRegionLabel(); | 162 | return Addressee::businessAddressRegionLabel(); |
166 | case FieldImpl::BusinessAddressPostalCode: | 163 | case FieldImpl::BusinessAddressPostalCode: |
167 | return Addressee::businessAddressPostalCodeLabel(); | 164 | return Addressee::businessAddressPostalCodeLabel(); |
168 | case FieldImpl::BusinessAddressCountry: | 165 | case FieldImpl::BusinessAddressCountry: |
169 | return Addressee::businessAddressCountryLabel(); | 166 | return Addressee::businessAddressCountryLabel(); |
170 | case FieldImpl::BusinessAddressLabel: | 167 | case FieldImpl::BusinessAddressLabel: |
171 | return Addressee::businessAddressLabelLabel(); | 168 | return Addressee::businessAddressLabelLabel(); |
172 | case FieldImpl::HomePhone: | 169 | case FieldImpl::HomePhone: |
173 | return Addressee::homePhoneLabel(); | 170 | return Addressee::homePhoneLabel(); |
174 | case FieldImpl::BusinessPhone: | 171 | case FieldImpl::BusinessPhone: |
175 | return Addressee::businessPhoneLabel(); | 172 | return Addressee::businessPhoneLabel(); |
176 | case FieldImpl::MobilePhone: | 173 | case FieldImpl::MobilePhone: |
177 | return Addressee::mobilePhoneLabel(); | 174 | return Addressee::mobilePhoneLabel(); |
178 | case FieldImpl::MobileHomePhone: | 175 | case FieldImpl::MobileHomePhone: |
179 | return Addressee::mobileHomePhoneLabel(); | 176 | return Addressee::mobileHomePhoneLabel(); |
180 | case FieldImpl::MobileWorkPhone: | 177 | case FieldImpl::MobileWorkPhone: |
181 | return Addressee::mobileWorkPhoneLabel(); | 178 | return Addressee::mobileWorkPhoneLabel(); |
182 | case FieldImpl::HomeFax: | 179 | case FieldImpl::HomeFax: |
183 | return Addressee::homeFaxLabel(); | 180 | return Addressee::homeFaxLabel(); |
184 | case FieldImpl::BusinessFax: | 181 | case FieldImpl::BusinessFax: |
185 | return Addressee::businessFaxLabel(); | 182 | return Addressee::businessFaxLabel(); |
186 | case FieldImpl::CarPhone: | 183 | case FieldImpl::CarPhone: |
187 | return Addressee::carPhoneLabel(); | 184 | return Addressee::carPhoneLabel(); |
188 | case FieldImpl::Isdn: | 185 | case FieldImpl::Isdn: |
189 | return Addressee::isdnLabel(); | 186 | return Addressee::isdnLabel(); |
190 | case FieldImpl::Pager: | 187 | case FieldImpl::Pager: |
191 | return Addressee::pagerLabel(); | 188 | return Addressee::pagerLabel(); |
192 | case FieldImpl::Email: | 189 | case FieldImpl::Email: |
193 | return Addressee::emailLabel(); | 190 | return Addressee::emailLabel(); |
194 | case FieldImpl::Mailer: | 191 | case FieldImpl::Mailer: |
195 | return Addressee::mailerLabel(); | 192 | return Addressee::mailerLabel(); |
196 | case FieldImpl::Title: | 193 | case FieldImpl::Title: |
197 | return Addressee::titleLabel(); | 194 | return Addressee::titleLabel(); |
198 | case FieldImpl::Role: | 195 | case FieldImpl::Role: |
199 | return Addressee::roleLabel(); | 196 | return Addressee::roleLabel(); |
200 | case FieldImpl::Organization: | 197 | case FieldImpl::Organization: |
201 | return Addressee::organizationLabel(); | 198 | return Addressee::organizationLabel(); |
202 | case FieldImpl::Note: | 199 | case FieldImpl::Note: |
203 | return Addressee::noteLabel(); | 200 | return Addressee::noteLabel(); |
204 | case FieldImpl::Url: | 201 | case FieldImpl::Url: |
205 | return Addressee::urlLabel(); | 202 | return Addressee::urlLabel(); |
206 | case FieldImpl::Resource: | 203 | case FieldImpl::Resource: |
207 | return Addressee::resourceLabel(); | 204 | return Addressee::resourceLabel(); |
208 | case FieldImpl::Category: | 205 | case FieldImpl::Category: |
209 | return Addressee::categoryLabel(); | 206 | return Addressee::categoryLabel(); |
210 | case FieldImpl::Sip: | 207 | case FieldImpl::Sip: |
211 | return Addressee::sipLabel(); | 208 | return Addressee::sipLabel(); |
212 | case FieldImpl::CustomField: | 209 | case FieldImpl::CustomField: |
213 | return mImpl->label(); | 210 | return mImpl->label(); |
214 | default: | 211 | default: |
215 | return i18n("Unknown Field"); | 212 | return i18n("Unknown Field"); |
216 | } | 213 | } |
217 | } | 214 | } |
218 | 215 | ||
219 | int Field::category() | 216 | int Field::category() |
220 | { | 217 | { |
221 | return mImpl->category(); | 218 | return mImpl->category(); |
222 | } | 219 | } |
223 | 220 | ||
224 | QString Field::categoryLabel( int category ) | 221 | QString Field::categoryLabel( int category ) |
225 | { | 222 | { |
226 | switch ( category ) { | 223 | switch ( category ) { |
227 | case All: | 224 | case All: |
228 | return i18n("All"); | 225 | return i18n("All"); |
229 | case Frequent: | 226 | case Frequent: |
230 | return i18n("Frequent"); | 227 | return i18n("Frequent"); |
231 | case Address: | 228 | case Address: |
232 | return i18n("Address"); | 229 | return i18n("Address"); |
233 | case Email: | 230 | case Email: |
234 | return i18n("Email"); | 231 | return i18n("Email"); |
235 | case Personal: | 232 | case Personal: |
236 | return i18n("Personal"); | 233 | return i18n("Personal"); |
237 | case Organization: | 234 | case Organization: |
238 | return i18n("Organization"); | 235 | return i18n("Organization"); |
239 | case CustomCategory: | 236 | case CustomCategory: |
240 | return i18n("Custom"); | 237 | return i18n("Custom"); |
241 | default: | 238 | default: |
242 | return i18n("Undefined"); | 239 | return i18n("Undefined"); |
243 | } | 240 | } |
244 | } | 241 | } |
245 | 242 | ||
246 | QString Field::value( const KABC::Addressee &a ) | 243 | QString Field::value( const KABC::Addressee &a ) |
247 | { | 244 | { |
248 | switch ( mImpl->fieldId() ) { | 245 | switch ( mImpl->fieldId() ) { |
249 | case FieldImpl::FormattedName: | 246 | case FieldImpl::FormattedName: |
250 | return a.formattedName(); | 247 | return a.formattedName(); |
251 | case FieldImpl::DefaultFormattedName: | ||
252 | return a.defaultFormattedName(); | ||
253 | case FieldImpl::FamilyName: | 248 | case FieldImpl::FamilyName: |
254 | return a.familyName(); | 249 | return a.familyName(); |
255 | case FieldImpl::GivenName: | 250 | case FieldImpl::GivenName: |
256 | return a.givenName(); | 251 | return a.givenName(); |
257 | case FieldImpl::AdditionalName: | 252 | case FieldImpl::AdditionalName: |
258 | return a.additionalName(); | 253 | return a.additionalName(); |
259 | case FieldImpl::Prefix: | 254 | case FieldImpl::Prefix: |
260 | return a.prefix(); | 255 | return a.prefix(); |
261 | case FieldImpl::Suffix: | 256 | case FieldImpl::Suffix: |
262 | return a.suffix(); | 257 | return a.suffix(); |
263 | case FieldImpl::NickName: | 258 | case FieldImpl::NickName: |
264 | return a.nickName(); | 259 | return a.nickName(); |
265 | case FieldImpl::Mailer: | 260 | case FieldImpl::Mailer: |
266 | return a.mailer(); | 261 | return a.mailer(); |
267 | case FieldImpl::Title: | 262 | case FieldImpl::Title: |
268 | return a.title(); | 263 | return a.title(); |
269 | case FieldImpl::Role: | 264 | case FieldImpl::Role: |
270 | return a.role(); | 265 | return a.role(); |
271 | case FieldImpl::Organization: | 266 | case FieldImpl::Organization: |
272 | return a.organization(); | 267 | return a.organization(); |
273 | case FieldImpl::Note: | 268 | case FieldImpl::Note: |
274 | return a.note(); | 269 | return a.note(); |
275 | case FieldImpl::Email: | 270 | case FieldImpl::Email: |
276 | return a.preferredEmail(); | 271 | return a.preferredEmail(); |
277 | case FieldImpl::Birthday: | 272 | case FieldImpl::Birthday: |
278 | if ( a.birthday().isValid() ) { | 273 | if ( a.birthday().isValid() ) { |
279 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); | 274 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); |
280 | // But Qt::IsoDate was not specified. | 275 | // But Qt::IsoDate was not specified. |
281 | // QString _oldFormat = KGlobal::locale()->dateFormat(); | 276 | // QString _oldFormat = KGlobal::locale()->dateFormat(); |
282 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate | 277 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate |
283 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); | 278 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); |
284 | // KGlobal::locale()->setDateFormat(_oldFormat); | 279 | // KGlobal::locale()->setDateFormat(_oldFormat); |
285 | return dt; | 280 | return dt; |
286 | } | 281 | } |
287 | else | 282 | else |
288 | return QString::null; | 283 | return QString::null; |
289 | case FieldImpl::Url: | 284 | case FieldImpl::Url: |
290 | return a.url().prettyURL(); | 285 | return a.url().prettyURL(); |
291 | //US | 286 | //US |
292 | case FieldImpl::Resource: | 287 | case FieldImpl::Resource: |
293 | return a.resource()->resourceName(); | 288 | return a.resource()->resourceName(); |
294 | case FieldImpl::Category: | 289 | case FieldImpl::Category: |
295 | return a.categories().join(","); | 290 | return a.categories().join(","); |
296 | case FieldImpl::HomePhone: | 291 | case FieldImpl::HomePhone: |
297 | return a.phoneNumber( PhoneNumber::Home ).number(); | 292 | return a.phoneNumber( PhoneNumber::Home ).number(); |
298 | case FieldImpl::BusinessPhone: | 293 | case FieldImpl::BusinessPhone: |
299 | return a.phoneNumber( PhoneNumber::Work ).number(); | 294 | return a.phoneNumber( PhoneNumber::Work ).number(); |
300 | case FieldImpl::MobilePhone: | 295 | case FieldImpl::MobilePhone: |
301 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 296 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
302 | case FieldImpl::MobileWorkPhone: | 297 | case FieldImpl::MobileWorkPhone: |
303 | return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number(); | 298 | return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number(); |
304 | case FieldImpl::MobileHomePhone: | 299 | case FieldImpl::MobileHomePhone: |
305 | return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number(); | 300 | return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number(); |
306 | case FieldImpl::HomeFax: | 301 | case FieldImpl::HomeFax: |
307 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 302 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
308 | case FieldImpl::BusinessFax: | 303 | case FieldImpl::BusinessFax: |
309 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); | 304 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); |
310 | case FieldImpl::CarPhone: | 305 | case FieldImpl::CarPhone: |
311 | return a.phoneNumber( PhoneNumber::Car ).number(); | 306 | return a.phoneNumber( PhoneNumber::Car ).number(); |
312 | case FieldImpl::Isdn: | 307 | case FieldImpl::Isdn: |
313 | return a.phoneNumber( PhoneNumber::Isdn ).number(); | 308 | return a.phoneNumber( PhoneNumber::Isdn ).number(); |
314 | case FieldImpl::Pager: | 309 | case FieldImpl::Pager: |
315 | return a.phoneNumber( PhoneNumber::Pager ).number(); | 310 | return a.phoneNumber( PhoneNumber::Pager ).number(); |
316 | case FieldImpl::Sip: | 311 | case FieldImpl::Sip: |
317 | return a.phoneNumber( PhoneNumber::Sip ).number(); | 312 | return a.phoneNumber( PhoneNumber::Sip ).number(); |
318 | case FieldImpl::HomeAddressStreet: | 313 | case FieldImpl::HomeAddressStreet: |
319 | return a.address( Address::Home ).street(); | 314 | return a.address( Address::Home ).street(); |
320 | case FieldImpl::HomeAddressLocality: | 315 | case FieldImpl::HomeAddressLocality: |
321 | return a.address( Address::Home ).locality(); | 316 | return a.address( Address::Home ).locality(); |
322 | case FieldImpl::HomeAddressRegion: | 317 | case FieldImpl::HomeAddressRegion: |
323 | return a.address( Address::Home ).region(); | 318 | return a.address( Address::Home ).region(); |
324 | case FieldImpl::HomeAddressPostalCode: | 319 | case FieldImpl::HomeAddressPostalCode: |
325 | return a.address( Address::Home ).postalCode(); | 320 | return a.address( Address::Home ).postalCode(); |
326 | case FieldImpl::HomeAddressCountry: | 321 | case FieldImpl::HomeAddressCountry: |
327 | return a.address( Address::Home ).country(); | 322 | return a.address( Address::Home ).country(); |
328 | case FieldImpl::BusinessAddressStreet: | 323 | case FieldImpl::BusinessAddressStreet: |
329 | return a.address( Address::Work ).street(); | 324 | return a.address( Address::Work ).street(); |
330 | case FieldImpl::BusinessAddressLocality: | 325 | case FieldImpl::BusinessAddressLocality: |
331 | return a.address( Address::Work ).locality(); | 326 | return a.address( Address::Work ).locality(); |
332 | case FieldImpl::BusinessAddressRegion: | 327 | case FieldImpl::BusinessAddressRegion: |
333 | return a.address( Address::Work ).region(); | 328 | return a.address( Address::Work ).region(); |
334 | case FieldImpl::BusinessAddressPostalCode: | 329 | case FieldImpl::BusinessAddressPostalCode: |
335 | return a.address( Address::Work ).postalCode(); | 330 | return a.address( Address::Work ).postalCode(); |
336 | case FieldImpl::BusinessAddressCountry: | 331 | case FieldImpl::BusinessAddressCountry: |
337 | return a.address( Address::Work ).country(); | 332 | return a.address( Address::Work ).country(); |
338 | case FieldImpl::CustomField: | 333 | case FieldImpl::CustomField: |
339 | return a.custom( mImpl->app(), mImpl->key() ); | 334 | return a.custom( mImpl->app(), mImpl->key() ); |
340 | default: | 335 | default: |
341 | return QString::null; | 336 | return QString::null; |
342 | } | 337 | } |
343 | } | 338 | } |
344 | 339 | ||
345 | bool Field::setValue( KABC::Addressee &a, const QString &value ) | 340 | bool Field::setValue( KABC::Addressee &a, const QString &value ) |
346 | { | 341 | { |
347 | switch ( mImpl->fieldId() ) { | 342 | switch ( mImpl->fieldId() ) { |
348 | case FieldImpl::FormattedName: | 343 | case FieldImpl::FormattedName: |
349 | a.setFormattedName( value ); | 344 | a.setFormattedName( value ); |
350 | return true; | 345 | return true; |
351 | case FieldImpl::FamilyName: | 346 | case FieldImpl::FamilyName: |
352 | a.setFamilyName( value ); | 347 | a.setFamilyName( value ); |
353 | return true; | 348 | return true; |
354 | case FieldImpl::GivenName: | 349 | case FieldImpl::GivenName: |
355 | a.setGivenName( value ); | 350 | a.setGivenName( value ); |
356 | return true; | 351 | return true; |
357 | case FieldImpl::AdditionalName: | 352 | case FieldImpl::AdditionalName: |
358 | a.setAdditionalName( value ); | 353 | a.setAdditionalName( value ); |
359 | return true; | 354 | return true; |
360 | case FieldImpl::Prefix: | 355 | case FieldImpl::Prefix: |
361 | a.setPrefix( value ); | 356 | a.setPrefix( value ); |
362 | return true; | 357 | return true; |
363 | case FieldImpl::Suffix: | 358 | case FieldImpl::Suffix: |
364 | a.setSuffix( value ); | 359 | a.setSuffix( value ); |
365 | return true; | 360 | return true; |
366 | case FieldImpl::NickName: | 361 | case FieldImpl::NickName: |
367 | a.setNickName( value ); | 362 | a.setNickName( value ); |
368 | return true; | 363 | return true; |
369 | case FieldImpl::Mailer: | 364 | case FieldImpl::Mailer: |
370 | a.setMailer( value ); | 365 | a.setMailer( value ); |
371 | return true; | 366 | return true; |
372 | case FieldImpl::Title: | 367 | case FieldImpl::Title: |
373 | a.setTitle( value ); | 368 | a.setTitle( value ); |
374 | return true; | 369 | return true; |
375 | case FieldImpl::Role: | 370 | case FieldImpl::Role: |
376 | a.setRole( value ); | 371 | a.setRole( value ); |
377 | return true; | 372 | return true; |
378 | case FieldImpl::Organization: | 373 | case FieldImpl::Organization: |
379 | a.setOrganization( value ); | 374 | a.setOrganization( value ); |
380 | return true; | 375 | return true; |
381 | case FieldImpl::Note: | 376 | case FieldImpl::Note: |
382 | a.setNote( value ); | 377 | a.setNote( value ); |
383 | return true; | 378 | return true; |
384 | case FieldImpl::Birthday: | 379 | case FieldImpl::Birthday: |
385 | //US | 380 | //US |
386 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 381 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
387 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 382 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
388 | { | 383 | { |
389 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 384 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
390 | a.setBirthday(dt); | 385 | a.setBirthday(dt); |
391 | } | 386 | } |
392 | return true; | 387 | return true; |
393 | case FieldImpl::CustomField: | 388 | case FieldImpl::CustomField: |
394 | a.insertCustom( mImpl->app(), mImpl->key(), value ); | 389 | a.insertCustom( mImpl->app(), mImpl->key(), value ); |
395 | //US never copy the resourcename back to the adressee. | 390 | //US never copy the resourcename back to the adressee. |
396 | case FieldImpl::Resource: | 391 | case FieldImpl::Resource: |
397 | default: | 392 | default: |
398 | return false; | 393 | return false; |
399 | } | 394 | } |
400 | } | 395 | } |
401 | 396 | ||
402 | bool Field::isCustom() | 397 | bool Field::isCustom() |
403 | { | 398 | { |
404 | return mImpl->fieldId() == FieldImpl::CustomField; | 399 | return mImpl->fieldId() == FieldImpl::CustomField; |
405 | } | 400 | } |
406 | 401 | ||
407 | Field::List Field::allFields() | 402 | Field::List Field::allFields() |
408 | { | 403 | { |
409 | if ( mAllFields.isEmpty() ) { | 404 | if ( mAllFields.isEmpty() ) { |
410 | createField( FieldImpl::FormattedName, Frequent ); | 405 | createField( FieldImpl::FormattedName, Frequent ); |
411 | createField( FieldImpl::DefaultFormattedName, Frequent ); | ||
412 | createField( FieldImpl::FamilyName, Frequent ); | 406 | createField( FieldImpl::FamilyName, Frequent ); |
413 | createField( FieldImpl::GivenName, Frequent ); | 407 | createField( FieldImpl::GivenName, Frequent ); |
414 | createField( FieldImpl::AdditionalName ); | 408 | createField( FieldImpl::AdditionalName ); |
415 | createField( FieldImpl::Prefix ); | 409 | createField( FieldImpl::Prefix ); |
416 | createField( FieldImpl::Suffix ); | 410 | createField( FieldImpl::Suffix ); |
417 | createField( FieldImpl::NickName, Personal ); | 411 | createField( FieldImpl::NickName, Personal ); |
418 | createField( FieldImpl::Birthday, Personal ); | 412 | createField( FieldImpl::Birthday, Personal ); |
419 | createField( FieldImpl::Category ); | 413 | createField( FieldImpl::Category ); |
420 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 414 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
421 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 415 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
422 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 416 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
423 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 417 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
424 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 418 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
425 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 419 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
426 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 420 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
427 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 421 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); |
428 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); | 422 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); |
429 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); | 423 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); |
430 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); | 424 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); |
431 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); | 425 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); |
432 | createField( FieldImpl::HomePhone, Personal|Frequent ); | 426 | createField( FieldImpl::HomePhone, Personal|Frequent ); |
433 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); | 427 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); |
434 | createField( FieldImpl::MobilePhone, Frequent ); | 428 | createField( FieldImpl::MobilePhone, Frequent ); |
435 | createField( FieldImpl::MobileHomePhone, Frequent ); | 429 | createField( FieldImpl::MobileHomePhone, Frequent ); |
436 | createField( FieldImpl::MobileWorkPhone, Frequent ); | 430 | createField( FieldImpl::MobileWorkPhone, Frequent ); |
437 | createField( FieldImpl::HomeFax ); | 431 | createField( FieldImpl::HomeFax ); |
438 | createField( FieldImpl::BusinessFax ); | 432 | createField( FieldImpl::BusinessFax ); |
439 | createField( FieldImpl::CarPhone ); | 433 | createField( FieldImpl::CarPhone ); |
440 | createField( FieldImpl::Isdn ); | 434 | createField( FieldImpl::Isdn ); |
441 | createField( FieldImpl::Pager ); | 435 | createField( FieldImpl::Pager ); |
442 | createField( FieldImpl::Email, Email|Frequent ); | 436 | createField( FieldImpl::Email, Email|Frequent ); |
443 | createField( FieldImpl::Mailer, Email ); | 437 | createField( FieldImpl::Mailer, Email ); |
444 | createField( FieldImpl::Title, Organization ); | 438 | createField( FieldImpl::Title, Organization ); |
445 | createField( FieldImpl::Role, Organization ); | 439 | createField( FieldImpl::Role, Organization ); |
446 | createField( FieldImpl::Organization, Organization ); | 440 | createField( FieldImpl::Organization, Organization ); |
447 | createField( FieldImpl::Note ); | 441 | createField( FieldImpl::Note ); |
448 | createField( FieldImpl::Url ); | 442 | createField( FieldImpl::Url ); |
449 | createField( FieldImpl::Resource ); | 443 | createField( FieldImpl::Resource ); |
450 | createField( FieldImpl::Sip ); | 444 | createField( FieldImpl::Sip ); |
451 | } | 445 | } |
452 | 446 | ||
453 | return mAllFields; | 447 | return mAllFields; |
454 | } | 448 | } |
455 | 449 | ||
456 | Field::List Field::defaultFields() | 450 | Field::List Field::defaultFields() |
457 | { | 451 | { |
458 | if ( mDefaultFields.isEmpty() ) { | 452 | if ( mDefaultFields.isEmpty() ) { |
459 | createDefaultField( FieldImpl::GivenName ); | 453 | createDefaultField( FieldImpl::GivenName ); |
460 | createDefaultField( FieldImpl::FamilyName ); | 454 | createDefaultField( FieldImpl::FamilyName ); |
461 | createDefaultField( FieldImpl::Email ); | 455 | createDefaultField( FieldImpl::Email ); |
462 | } | 456 | } |
463 | 457 | ||
464 | return mDefaultFields; | 458 | return mDefaultFields; |
465 | } | 459 | } |
466 | 460 | ||
467 | void Field::createField( int id, int category ) | 461 | void Field::createField( int id, int category ) |
468 | { | 462 | { |
469 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); | 463 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); |
470 | } | 464 | } |
471 | 465 | ||
472 | void Field::createDefaultField( int id, int category ) | 466 | void Field::createDefaultField( int id, int category ) |
473 | { | 467 | { |
474 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); | 468 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); |
475 | } | 469 | } |
476 | 470 | ||
477 | void Field::deleteFields() | 471 | void Field::deleteFields() |
478 | { | 472 | { |
479 | Field::List::ConstIterator it; | 473 | Field::List::ConstIterator it; |
480 | 474 | ||
481 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { | 475 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { |
482 | delete (*it); | 476 | delete (*it); |
483 | } | 477 | } |
484 | mAllFields.clear(); | 478 | mAllFields.clear(); |
485 | 479 | ||
486 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { | 480 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { |
487 | delete (*it); | 481 | delete (*it); |
488 | } | 482 | } |
489 | mDefaultFields.clear(); | 483 | mDefaultFields.clear(); |
490 | 484 | ||
491 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { | 485 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { |
492 | delete (*it); | 486 | delete (*it); |
493 | } | 487 | } |
494 | mCustomFields.clear(); | 488 | mCustomFields.clear(); |
495 | } | 489 | } |
496 | 490 | ||
497 | void Field::saveFields( const QString &identifier, | 491 | void Field::saveFields( const QString &identifier, |
498 | const Field::List &fields ) | 492 | const Field::List &fields ) |
499 | { | 493 | { |
500 | KConfig *cfg = KGlobal::config(); | 494 | KConfig *cfg = KGlobal::config(); |
501 | KConfigGroupSaver( cfg, "KABCFields" ); | 495 | KConfigGroupSaver( cfg, "KABCFields" ); |
502 | saveFields( cfg, identifier, fields ); | 496 | saveFields( cfg, identifier, fields ); |
503 | } | 497 | } |
504 | 498 | ||
505 | void Field::saveFields( KConfig *cfg, const QString &identifier, | 499 | void Field::saveFields( KConfig *cfg, const QString &identifier, |
506 | const Field::List &fields ) | 500 | const Field::List &fields ) |
507 | { | 501 | { |
508 | QValueList<int> fieldIds; | 502 | QValueList<int> fieldIds; |
509 | 503 | ||
510 | //US | 504 | //US |
511 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); | 505 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); |
512 | 506 | ||
513 | int custom = 0; | 507 | int custom = 0; |
514 | Field::List::ConstIterator it; | 508 | Field::List::ConstIterator it; |
515 | for( it = fields.begin(); it != fields.end(); ++it ) { | 509 | for( it = fields.begin(); it != fields.end(); ++it ) { |
516 | //US | 510 | //US |
517 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); | 511 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); |
518 | 512 | ||
519 | fieldIds.append( (*it)->mImpl->fieldId() ); | 513 | fieldIds.append( (*it)->mImpl->fieldId() ); |
520 | if( (*it)->isCustom() ) { | 514 | if( (*it)->isCustom() ) { |
521 | QStringList customEntry; | 515 | QStringList customEntry; |
522 | customEntry << (*it)->mImpl->label(); | 516 | customEntry << (*it)->mImpl->label(); |
523 | customEntry << (*it)->mImpl->key(); | 517 | customEntry << (*it)->mImpl->key(); |
524 | customEntry << (*it)->mImpl->app(); | 518 | customEntry << (*it)->mImpl->app(); |
525 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + | 519 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + |
526 | QString::number( custom++ ), customEntry ); | 520 | QString::number( custom++ ), customEntry ); |
527 | } | 521 | } |
528 | } | 522 | } |
529 | cfg->writeEntry( identifier, fieldIds ); | 523 | cfg->writeEntry( identifier, fieldIds ); |
530 | } | 524 | } |
531 | 525 | ||
532 | Field::List Field::restoreFields( const QString &identifier ) | 526 | Field::List Field::restoreFields( const QString &identifier ) |
533 | { | 527 | { |
534 | //US | 528 | //US |
535 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); | 529 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); |
536 | 530 | ||
537 | KConfig *cfg = KGlobal::config(); | 531 | KConfig *cfg = KGlobal::config(); |
538 | KConfigGroupSaver( cfg, "KABCFields" ); | 532 | KConfigGroupSaver( cfg, "KABCFields" ); |
539 | cfg->setGroup( "KABCFields" ); | 533 | cfg->setGroup( "KABCFields" ); |
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index b3da428..294ce7d 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -1,187 +1,187 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KOrganizer alarm daemon. | 2 | This file is part of the KOrganizer alarm daemon. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "simplealarmdaemonimpl.h" | 24 | #include "simplealarmdaemonimpl.h" |
25 | 25 | ||
26 | #include "alarmdialog.h" | 26 | #include "alarmdialog.h" |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qhbox.h> | 31 | #include <qhbox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #define protected public | 39 | #define protected public |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #undef protected | 41 | #undef protected |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qtopia/qcopenvelope_qws.h> | 43 | #include <qtopia/qcopenvelope_qws.h> |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) |
52 | : QLabel( parent ) | 52 | : QLabel( parent ) |
53 | { | 53 | { |
54 | mAlarmDialog = new AlarmDialog( 0 ); | 54 | mAlarmDialog = new AlarmDialog( 0 ); |
55 | mPopUp = new QPopupMenu( this ); | 55 | mPopUp = new QPopupMenu( this ); |
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | 56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); |
57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | 57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); |
58 | mPopUp->insertSeparator(); | 58 | mPopUp->insertSeparator(); |
59 | mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); | 59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); |
60 | mPopUp->insertSeparator(); | 60 | mPopUp->insertSeparator(); |
61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | 61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); |
62 | mPopUp->insertSeparator(); | 62 | mPopUp->insertSeparator(); |
63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | 63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); |
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | 64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); |
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | 65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); |
66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); | 66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); |
67 | mPopUp->insertSeparator(); | 67 | mPopUp->insertSeparator(); |
68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | 68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); |
69 | mTimerPopUp = new QPopupMenu( this ); | 69 | mTimerPopUp = new QPopupMenu( this ); |
70 | QFont fon = mTimerPopUp->font(); | 70 | QFont fon = mTimerPopUp->font(); |
71 | fon.setPointSize( fon.pointSize() *3/2 ); | 71 | fon.setPointSize( fon.pointSize() *3/2 ); |
72 | mTimerPopUp->setFont( fon ); | 72 | mTimerPopUp->setFont( fon ); |
73 | mBeepPopUp = new QPopupMenu( this ); | 73 | mBeepPopUp = new QPopupMenu( this ); |
74 | mSoundPopUp = new QPopupMenu( this ); | 74 | mSoundPopUp = new QPopupMenu( this ); |
75 | mPausePopUp = new QPopupMenu( this ); | 75 | mPausePopUp = new QPopupMenu( this ); |
76 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 76 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
77 | savePopUp->insertItem( "Save", 0 ); | 77 | savePopUp->insertItem( "Save", 0 ); |
78 | savePopUp->insertItem( "Load", 1 ); | 78 | savePopUp->insertItem( "Load", 1 ); |
79 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 79 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
80 | mSoundPopUp->insertItem( "Wav file", 1 ); | 80 | mSoundPopUp->insertItem( "Wav file", 1 ); |
81 | mPausePopUp->insertItem( " 1 sec", 1 ); | 81 | mPausePopUp->insertItem( " 1 sec", 1 ); |
82 | mPausePopUp->insertItem( " 2 sec", 2 ); | 82 | mPausePopUp->insertItem( " 2 sec", 2 ); |
83 | mPausePopUp->insertItem( " 3 sec", 3 ); | 83 | mPausePopUp->insertItem( " 3 sec", 3 ); |
84 | mPausePopUp->insertItem( " 5 sec", 5 ); | 84 | mPausePopUp->insertItem( " 5 sec", 5 ); |
85 | mPausePopUp->insertItem( "10 sec", 10 ); | 85 | mPausePopUp->insertItem( "10 sec", 10 ); |
86 | mPausePopUp->insertItem( "30 sec", 30 ); | 86 | mPausePopUp->insertItem( "30 sec", 30 ); |
87 | mPausePopUp->insertItem( " 1 min", 60 ); | 87 | mPausePopUp->insertItem( " 1 min", 60 ); |
88 | mPausePopUp->insertItem( " 5 min", 300 ); | 88 | mPausePopUp->insertItem( " 5 min", 300 ); |
89 | mPausePopUp->insertItem( "10 min", 600 ); | 89 | mPausePopUp->insertItem( "10 min", 600 ); |
90 | mSuspendPopUp = new QPopupMenu( this ); | 90 | mSuspendPopUp = new QPopupMenu( this ); |
91 | mSuspendPopUp->insertItem( "Off", 0 ); | 91 | mSuspendPopUp->insertItem( "Off", 0 ); |
92 | mSuspendPopUp->insertItem( " 1x", 1 ); | 92 | mSuspendPopUp->insertItem( " 1x", 1 ); |
93 | mSuspendPopUp->insertItem( " 2x", 2 ); | 93 | mSuspendPopUp->insertItem( " 2x", 2 ); |
94 | mSuspendPopUp->insertItem( " 3x", 3 ); | 94 | mSuspendPopUp->insertItem( " 3x", 3 ); |
95 | mSuspendPopUp->insertItem( " 5x", 5 ); | 95 | mSuspendPopUp->insertItem( " 5x", 5 ); |
96 | mSuspendPopUp->insertItem( "10x", 10 ); | 96 | mSuspendPopUp->insertItem( "10x", 10 ); |
97 | mSuspendPopUp->insertItem( "20x", 20 ); | 97 | mSuspendPopUp->insertItem( "20x", 20 ); |
98 | mSuspendPopUp->insertItem( "30x", 30 ); | 98 | mSuspendPopUp->insertItem( "30x", 30 ); |
99 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 99 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
100 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 100 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
101 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 101 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
102 | mBeepPopUp->insertItem( "Config",savePopUp ); | 102 | mBeepPopUp->insertItem( "Config",savePopUp ); |
103 | mBeepPopUp->insertItem( "300", 300 ); | 103 | mBeepPopUp->insertItem( "300", 300 ); |
104 | mBeepPopUp->insertItem( "180", 180 ); | 104 | mBeepPopUp->insertItem( "180", 180 ); |
105 | mBeepPopUp->insertItem( "60", 60 ); | 105 | mBeepPopUp->insertItem( "60", 60 ); |
106 | mBeepPopUp->insertItem( "30", 30 ); | 106 | mBeepPopUp->insertItem( "30", 30 ); |
107 | mBeepPopUp->insertItem( "10", 10 ); | 107 | mBeepPopUp->insertItem( "10", 10 ); |
108 | mBeepPopUp->insertItem( "3", 3 ); | 108 | mBeepPopUp->insertItem( "3", 3 ); |
109 | mBeepPopUp->insertItem( "1", 1 ); | 109 | mBeepPopUp->insertItem( "1", 1 ); |
110 | mBeepPopUp->insertItem( "Off", 0 ); | 110 | mBeepPopUp->insertItem( "Off", 0 ); |
111 | mBeepPopUp->setCheckable( true ); | 111 | mBeepPopUp->setCheckable( true ); |
112 | mPopUp->insertSeparator(); | 112 | mPopUp->insertSeparator(); |
113 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | 113 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); |
114 | mPopUp->insertSeparator(); | 114 | mPopUp->insertSeparator(); |
115 | mPopUp->insertItem( "Timer", mTimerPopUp ); | 115 | mPopUp->insertItem( "Timer", mTimerPopUp ); |
116 | mPopUp->insertSeparator(); | 116 | mPopUp->insertSeparator(); |
117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
118 | 118 | ||
119 | mPopUp->resize( mPopUp->sizeHint() ); | 119 | mPopUp->resize( mPopUp->sizeHint() ); |
120 | mPlayBeeps = 60; | 120 | mPlayBeeps = 60; |
121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
129 | mTimerTime = 0; | 129 | mTimerTime = 0; |
130 | mCustomText = "Custom Text"; | 130 | mCustomText = "Custom Text"; |
131 | mCustomMinutes = 7; | 131 | mCustomMinutes = 7; |
132 | mTimerPopupConf = 1; | 132 | mTimerPopupConf = 1; |
133 | fillTimerPopUp(); | 133 | fillTimerPopUp(); |
134 | mPausePlay = 0; | 134 | mPausePlay = 0; |
135 | confPause( 1 ); | 135 | confPause( 1 ); |
136 | mSuspend = 0; | 136 | mSuspend = 0; |
137 | confSuspend( 0 ); | 137 | confSuspend( 0 ); |
138 | if ( QApplication::desktop()->width() < 480 ) { | 138 | if ( QApplication::desktop()->width() < 480 ) { |
139 | wavAlarm = false; | 139 | wavAlarm = false; |
140 | mSoundPopUp->setItemChecked ( 0, true ); | 140 | mSoundPopUp->setItemChecked ( 0, true ); |
141 | } | 141 | } |
142 | else { | 142 | else { |
143 | wavAlarm = true; | 143 | wavAlarm = true; |
144 | mSoundPopUp->setItemChecked ( 1, true ); | 144 | mSoundPopUp->setItemChecked ( 1, true ); |
145 | } | 145 | } |
146 | saveSlot( 1 ); | 146 | saveSlot( 1 ); |
147 | } | 147 | } |
148 | 148 | ||
149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
150 | { | 150 | { |
151 | //delete mPopUp; | 151 | //delete mPopUp; |
152 | delete mAlarmDialog; | 152 | delete mAlarmDialog; |
153 | } | 153 | } |
154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
155 | { | 155 | { |
156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
157 | //qDebug("save %d ", load ); | 157 | //qDebug("save %d ", load ); |
158 | QFile file( fileName ); | 158 | QFile file( fileName ); |
159 | if ( load ) { | 159 | if ( load ) { |
160 | if( !QFile::exists( fileName) ) | 160 | if( !QFile::exists( fileName) ) |
161 | return; | 161 | return; |
162 | if (!file.open( IO_ReadOnly ) ) { | 162 | if (!file.open( IO_ReadOnly ) ) { |
163 | return ; | 163 | return ; |
164 | } | 164 | } |
165 | QString line; | 165 | QString line; |
166 | bool ok; | 166 | bool ok; |
167 | int val; | 167 | int val; |
168 | int len; | 168 | int len; |
169 | while ( file.readLine( line, 1024 ) > 0 ) { | 169 | while ( file.readLine( line, 1024 ) > 0 ) { |
170 | //qDebug("read %s ", line.latin1()); | 170 | //qDebug("read %s ", line.latin1()); |
171 | len = line.length(); | 171 | len = line.length(); |
172 | if ( line.left(4 ) == "PPAU" ) { | 172 | if ( line.left(4 ) == "PPAU" ) { |
173 | val = line.mid( 4,len-5).toInt( &ok ); | 173 | val = line.mid( 4,len-5).toInt( &ok ); |
174 | if ( ok ) { | 174 | if ( ok ) { |
175 | confPause( val ); | 175 | confPause( val ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | if ( line.left(4 ) == "SUCO" ) { | 178 | if ( line.left(4 ) == "SUCO" ) { |
179 | val = line.mid( 4,len-5).toInt( &ok ); | 179 | val = line.mid( 4,len-5).toInt( &ok ); |
180 | if ( ok ) | 180 | if ( ok ) |
181 | confSuspend ( val ); | 181 | confSuspend ( val ); |
182 | } | 182 | } |
183 | if ( line.left(4 ) == "WAAL" ) { | 183 | if ( line.left(4 ) == "WAAL" ) { |
184 | val = line.mid( 4,len-5).toInt( &ok ); | 184 | val = line.mid( 4,len-5).toInt( &ok ); |
185 | if ( ok ) | 185 | if ( ok ) |
186 | confSound( val ); | 186 | confSound( val ); |
187 | 187 | ||
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 23afe7a..e545ca8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -318,397 +318,405 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
318 | if ( mAllDay ) | 318 | if ( mAllDay ) |
319 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
320 | else | 320 | else |
321 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
322 | } | 322 | } |
323 | int x, yy, w, h; | 323 | int x, yy, w, h; |
324 | float nfh = 7.0; | 324 | float nfh = 7.0; |
325 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
326 | if ( mAllDay ) | 326 | if ( mAllDay ) |
327 | yy = y(); | 327 | yy = y(); |
328 | else | 328 | else |
329 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
330 | xPaintCoord= x; | 330 | xPaintCoord= x; |
331 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
332 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
333 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
335 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
336 | paint = &pa; | 336 | paint = &pa; |
337 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
338 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
339 | if ( horLayout ) | 339 | if ( horLayout ) |
340 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
341 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
342 | if ( ! small ) | 342 | if ( ! small ) |
343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
344 | else { | 344 | else { |
345 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
346 | f.setBold( false ); | 346 | f.setBold( false ); |
347 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
349 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
350 | nfh = 6; | 350 | nfh = 6; |
351 | f.setPointSize( nfh ); | 351 | f.setPointSize( nfh ); |
352 | paint->setFont(f); | 352 | paint->setFont(f); |
353 | } | 353 | } |
354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
357 | if ( mIncidence->type() == "Todo" ) { | 357 | if ( mIncidence->type() == "Todo" ) { |
358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
360 | int yyy = yy+3; | 360 | int yyy = yy+3; |
361 | if ( tempTodo->isCompleted() ) | 361 | if ( tempTodo->isCompleted() ) |
362 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 362 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
363 | else { | 363 | else { |
364 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 364 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
365 | 365 | ||
366 | } | 366 | } |
367 | } | 367 | } |
368 | bool addIcon = false; | 368 | bool addIcon = false; |
369 | if ( ! small || w > 3 * h || h > 3* w ) | 369 | if ( ! small || w > 3 * h || h > 3* w ) |
370 | addIcon = updateIcons( paint, horLayout ); | 370 | addIcon = updateIcons( paint, horLayout ); |
371 | 371 | ||
372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
374 | if ( ! small ) { | 374 | if ( ! small ) { |
375 | x += 3; yy += 3;w -= 6; h-= 5; | 375 | x += 3; yy += 3;w -= 6; h-= 5; |
376 | } else { | 376 | } else { |
377 | x += 2; yy += 1;w -= 4; h-= 4; | 377 | x += 2; yy += 1;w -= 4; h-= 4; |
378 | if ( nfh < 6.01 ) { | 378 | if ( nfh < 6.01 ) { |
379 | yy -= 2; | 379 | yy -= 2; |
380 | h += 4; | 380 | h += 4; |
381 | } | 381 | } |
382 | else | 382 | else |
383 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
384 | ++yy; | 384 | ++yy; |
385 | } | 385 | } |
386 | int align; | 386 | int align; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
389 | #else | 389 | #else |
390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
391 | #endif | 391 | #endif |
392 | if ( addIcon ) { | 392 | if ( addIcon ) { |
393 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
394 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
395 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | else { | 397 | else { |
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | 424 | ||
425 | 425 | ||
426 | small = ( height() < 20 ); | 426 | small = ( height() < 20 ); |
427 | 427 | ||
428 | if ( ! small ) { | 428 | if ( ! small ) { |
429 | QFontMetrics fm ( paint->font() ); | 429 | QFontMetrics fm ( paint->font() ); |
430 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 430 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
431 | } | 431 | } |
432 | 432 | ||
433 | } | 433 | } |
434 | pa.end(); | 434 | pa.end(); |
435 | 435 | ||
436 | } | 436 | } |
437 | void KOAgendaItem::resizePixmap( int w , int h ) | 437 | void KOAgendaItem::resizePixmap( int w , int h ) |
438 | { | 438 | { |
439 | paintPix()->resize( w, h ); | 439 | paintPix()->resize( w, h ); |
440 | paintPixSel()->resize( w, h ); | 440 | paintPixSel()->resize( w, h ); |
441 | 441 | ||
442 | } | 442 | } |
443 | QPixmap * KOAgendaItem::paintPix() | 443 | QPixmap * KOAgendaItem::paintPix() |
444 | { | 444 | { |
445 | static QPixmap* mPaintPix = 0; | 445 | static QPixmap* mPaintPix = 0; |
446 | if ( ! mPaintPix ) | 446 | if ( ! mPaintPix ) { |
447 | mPaintPix = new QPixmap(1,1); | 447 | int w = QApplication::desktop()->width(); |
448 | int h = QApplication::desktop()->height(); | ||
449 | mPaintPix = new QPixmap(w,h); | ||
450 | } | ||
448 | return mPaintPix ; | 451 | return mPaintPix ; |
449 | } | 452 | } |
450 | QPixmap * KOAgendaItem::paintPixAllday() | 453 | QPixmap * KOAgendaItem::paintPixAllday() |
451 | { | 454 | { |
452 | static QPixmap* mPaintPixA = 0; | 455 | static QPixmap* mPaintPixA = 0; |
453 | if ( ! mPaintPixA ) | 456 | if ( ! mPaintPixA ) { |
454 | mPaintPixA = new QPixmap(1,1); | 457 | int w = QApplication::desktop()->width(); |
458 | int h = QApplication::desktop()->height()/3; | ||
459 | mPaintPixA = new QPixmap(w,h); | ||
460 | } | ||
455 | return mPaintPixA ; | 461 | return mPaintPixA ; |
456 | } | 462 | } |
457 | QPixmap * KOAgendaItem::paintPixSel() | 463 | QPixmap * KOAgendaItem::paintPixSel() |
458 | { | 464 | { |
459 | static QPixmap* mPaintPixSel = 0; | 465 | static QPixmap* mPaintPixSel = 0; |
460 | if ( ! mPaintPixSel ) | 466 | if ( ! mPaintPixSel ) { |
461 | mPaintPixSel = new QPixmap(1,1); | 467 | int w = QApplication::desktop()->width(); |
468 | int h = QApplication::desktop()->height(); | ||
469 | mPaintPixSel = new QPixmap(w,h); | ||
470 | } | ||
462 | return mPaintPixSel ; | 471 | return mPaintPixSel ; |
463 | } | 472 | } |
464 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 473 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
465 | { | 474 | { |
466 | 475 | ||
467 | if ( globalFlagBlockAgendaItemPaint ) | 476 | if ( globalFlagBlockAgendaItemPaint ) |
468 | return; | 477 | return; |
469 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 478 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
470 | return; | 479 | return; |
471 | int yy; | 480 | int yy; |
472 | if ( mAllDay ) | 481 | if ( mAllDay ) |
473 | yy = y(); | 482 | yy = y(); |
474 | else | 483 | else |
475 | yy = mCellYTop * ( height() / cellHeight() ); | 484 | yy = mCellYTop * ( height() / cellHeight() ); |
476 | int xx = x(); | 485 | int xx = x(); |
477 | 486 | ||
478 | if ( xPaintCoord != xx || yPaintCoord != yy || | 487 | if ( xPaintCoord != xx || yPaintCoord != yy || |
479 | wPaintCoord != width() || hPaintCoord != height()) { | 488 | wPaintCoord != width() || hPaintCoord != height()) { |
480 | xPaintCoord= xx; | 489 | xPaintCoord= xx; |
481 | yPaintCoord = yy; | 490 | yPaintCoord = yy; |
482 | wPaintCoord = width(); | 491 | wPaintCoord = width(); |
483 | hPaintCoord = height(); | 492 | hPaintCoord = height(); |
484 | globalFlagBlockAgendaItemUpdate = 0; | 493 | globalFlagBlockAgendaItemUpdate = 0; |
485 | paintMe( mSelected ); | 494 | paintMe( mSelected ); |
486 | //qDebug("calling paintMe "); | 495 | //qDebug("calling paintMe "); |
487 | globalFlagBlockAgendaItemUpdate = 1; | 496 | globalFlagBlockAgendaItemUpdate = 1; |
488 | } | 497 | } |
489 | int rx, ry, rw, rh; | 498 | int rx, ry, rw, rh; |
490 | rx = e->rect().x(); | 499 | rx = e->rect().x(); |
491 | ry = e->rect().y(); | 500 | ry = e->rect().y(); |
492 | rw = e->rect().width(); | 501 | rw = e->rect().width(); |
493 | rh = e->rect().height(); | 502 | rh = e->rect().height(); |
494 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 503 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
495 | 504 | ||
496 | QPixmap* paintFrom ; | 505 | QPixmap* paintFrom ; |
497 | if ( mSelected ) { | 506 | if ( mSelected ) { |
498 | paintFrom = paintPixSel(); | 507 | paintFrom = paintPixSel(); |
499 | } else { | 508 | } else { |
500 | if ( mAllDay ) | 509 | if ( mAllDay ) |
501 | paintFrom = paintPixAllday(); | 510 | paintFrom = paintPixAllday(); |
502 | else | 511 | else |
503 | paintFrom = paintPix(); | 512 | paintFrom = paintPix(); |
504 | } | 513 | } |
505 | xx += rx; | 514 | xx += rx; |
506 | 515 | ||
507 | if ( xx < 0 ) { | 516 | if ( xx < 0 ) { |
508 | rw = rw + xx; | 517 | rw = rw + xx; |
509 | rx -= xx; | 518 | rx -= xx; |
510 | xx = 0; | 519 | xx = 0; |
511 | if ( rw <= 1 ) { | 520 | if ( rw <= 1 ) { |
512 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 521 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
513 | return; | 522 | return; |
514 | } | 523 | } |
515 | } | 524 | } |
516 | if ( paintFrom->width() < xx+rw ) { | 525 | if ( paintFrom->width() < xx+rw ) { |
517 | rw = paintFrom->width() - xx; | 526 | rw = paintFrom->width() - xx; |
518 | if ( rw <= 1 ) { | 527 | if ( rw <= 1 ) { |
519 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 528 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
520 | return; | 529 | return; |
521 | } | 530 | } |
522 | } | 531 | } |
523 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 532 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
524 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 533 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
525 | } | 534 | } |
526 | void KOAgendaItem::computeText() | 535 | void KOAgendaItem::computeText() |
527 | { | 536 | { |
528 | |||
529 | mDisplayedText = mIncidence->summary(); | 537 | mDisplayedText = mIncidence->summary(); |
530 | if ( (mIncidence->type() == "Todo") ) { | 538 | if ( (mIncidence->type() == "Todo") ) { |
531 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 539 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
532 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 540 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
533 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 541 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
534 | else if ( !(mIncidence->doesFloat())) | 542 | else if ( !(mIncidence->doesFloat())) |
535 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 543 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
536 | } | 544 | } |
537 | } else { | 545 | } else { |
538 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 546 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
539 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 547 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
540 | 548 | ||
541 | if ( mAllDay ) { | 549 | if ( mAllDay ) { |
542 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 550 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
543 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 551 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
544 | } | 552 | } |
545 | } | 553 | } |
546 | 554 | ||
547 | } | 555 | } |
548 | 556 | ||
549 | if ( !mIncidence->location().isEmpty() ) { | 557 | if ( !mIncidence->location().isEmpty() ) { |
550 | if ( mAllDay ) | 558 | if ( mAllDay ) |
551 | mDisplayedText += " ("; | 559 | mDisplayedText += " ("; |
552 | else | 560 | else |
553 | mDisplayedText += "\n("; | 561 | mDisplayedText += "\n("; |
554 | mDisplayedText += mIncidence->location() +")"; | 562 | mDisplayedText += mIncidence->location() +")"; |
555 | } | 563 | } |
556 | 564 | #ifdef DESKTOP_VERSION | |
557 | QString tipText = mIncidence->summary(); | 565 | QString tipText = mIncidence->summary(); |
558 | if ( !mIncidence->doesFloat() ) { | 566 | if ( !mIncidence->doesFloat() ) { |
559 | if ( mIncidence->type() == "Event" ) { | 567 | if ( mIncidence->type() == "Event" ) { |
560 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 568 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
561 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 569 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
562 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 570 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
563 | } | 571 | } |
564 | else { | 572 | else { |
565 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 573 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
566 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 574 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
567 | } | 575 | } |
568 | } | 576 | } |
569 | else if ( mIncidence->type() == "Todo" ) { | 577 | else if ( mIncidence->type() == "Todo" ) { |
570 | if (mIncidence->hasStartDate()) | 578 | if (mIncidence->hasStartDate()) |
571 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 579 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
572 | if (((Todo*)mIncidence)->hasDueDate()) | 580 | if (((Todo*)mIncidence)->hasDueDate()) |
573 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 581 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
574 | } | 582 | } |
575 | } else if ( mIncidence->type() == "Todo" ) { | 583 | } else if ( mIncidence->type() == "Todo" ) { |
576 | if (mIncidence->hasStartDate()) | 584 | if (mIncidence->hasStartDate()) |
577 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 585 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
578 | if (((Todo*)mIncidence)->hasDueDate()) | 586 | if (((Todo*)mIncidence)->hasDueDate()) |
579 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 587 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
580 | } | 588 | } |
581 | 589 | ||
582 | if (!mIncidence->location().isEmpty()) { | 590 | if (!mIncidence->location().isEmpty()) { |
583 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 591 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
584 | } | 592 | } |
585 | QToolTip::add(this,tipText,toolTipGroup(),""); | 593 | QToolTip::add(this,tipText,toolTipGroup(),""); |
586 | 594 | #endif | |
587 | } | 595 | } |
588 | void KOAgendaItem::updateItem() | 596 | void KOAgendaItem::updateItem() |
589 | { | 597 | { |
590 | computeText(); | 598 | computeText(); |
591 | 599 | ||
592 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 600 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
593 | paintMe( mSelected ); | 601 | paintMe( mSelected ); |
594 | repaint( false); | 602 | repaint( false); |
595 | } | 603 | } |
596 | 604 | ||
597 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 605 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
598 | { | 606 | { |
599 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 607 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
600 | paintMe( mSelected ); | 608 | paintMe( mSelected ); |
601 | repaint( false ); | 609 | repaint( false ); |
602 | } | 610 | } |
603 | 611 | ||
604 | /* | 612 | /* |
605 | Return height of item in units of agenda cells | 613 | Return height of item in units of agenda cells |
606 | */ | 614 | */ |
607 | int KOAgendaItem::cellHeight() | 615 | int KOAgendaItem::cellHeight() |
608 | { | 616 | { |
609 | int ret = mCellYBottom - mCellYTop + 1; | 617 | int ret = mCellYBottom - mCellYTop + 1; |
610 | if ( ret <= 0 ) { | 618 | if ( ret <= 0 ) { |
611 | ret = 1; | 619 | ret = 1; |
612 | mCellYBottom = 0; | 620 | mCellYBottom = 0; |
613 | mCellYTop = 0; | 621 | mCellYTop = 0; |
614 | } | 622 | } |
615 | return ret; | 623 | return ret; |
616 | } | 624 | } |
617 | 625 | ||
618 | /* | 626 | /* |
619 | Return height of item in units of agenda cells | 627 | Return height of item in units of agenda cells |
620 | */ | 628 | */ |
621 | int KOAgendaItem::cellWidth() | 629 | int KOAgendaItem::cellWidth() |
622 | { | 630 | { |
623 | return mCellXWidth - mCellX + 1; | 631 | return mCellXWidth - mCellX + 1; |
624 | } | 632 | } |
625 | 633 | ||
626 | void KOAgendaItem::setItemDate(QDate qd) | 634 | void KOAgendaItem::setItemDate(QDate qd) |
627 | { | 635 | { |
628 | mDate = qd; | 636 | mDate = qd; |
629 | } | 637 | } |
630 | 638 | ||
631 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 639 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
632 | { | 640 | { |
633 | mCellX = X; | 641 | mCellX = X; |
634 | mCellYTop = YTop; | 642 | mCellYTop = YTop; |
635 | mCellYBottom = YBottom; | 643 | mCellYBottom = YBottom; |
636 | } | 644 | } |
637 | 645 | ||
638 | void KOAgendaItem::setCellXWidth(int xwidth) | 646 | void KOAgendaItem::setCellXWidth(int xwidth) |
639 | { | 647 | { |
640 | mCellXWidth = xwidth; | 648 | mCellXWidth = xwidth; |
641 | } | 649 | } |
642 | 650 | ||
643 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 651 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
644 | { | 652 | { |
645 | mCellX = XLeft; | 653 | mCellX = XLeft; |
646 | mCellXWidth = XRight; | 654 | mCellXWidth = XRight; |
647 | } | 655 | } |
648 | 656 | ||
649 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 657 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
650 | { | 658 | { |
651 | mCellYTop = YTop; | 659 | mCellYTop = YTop; |
652 | mCellYBottom = YBottom; | 660 | mCellYBottom = YBottom; |
653 | } | 661 | } |
654 | 662 | ||
655 | void KOAgendaItem::setSubCell(int subCell) | 663 | void KOAgendaItem::setSubCell(int subCell) |
656 | { | 664 | { |
657 | mSubCell = subCell; | 665 | mSubCell = subCell; |
658 | } | 666 | } |
659 | 667 | ||
660 | void KOAgendaItem::setSubCells(int subCells) | 668 | void KOAgendaItem::setSubCells(int subCells) |
661 | { | 669 | { |
662 | mSubCells = subCells; | 670 | mSubCells = subCells; |
663 | } | 671 | } |
664 | 672 | ||
665 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 673 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
666 | KOAgendaItem *last) | 674 | KOAgendaItem *last) |
667 | { | 675 | { |
668 | mFirstMultiItem = first; | 676 | mFirstMultiItem = first; |
669 | mNextMultiItem = next; | 677 | mNextMultiItem = next; |
670 | mLastMultiItem = last; | 678 | mLastMultiItem = last; |
671 | } | 679 | } |
672 | 680 | ||
673 | void KOAgendaItem::startMove() | 681 | void KOAgendaItem::startMove() |
674 | { | 682 | { |
675 | mStartCellX = mCellX; | 683 | mStartCellX = mCellX; |
676 | mStartCellXWidth = mCellXWidth; | 684 | mStartCellXWidth = mCellXWidth; |
677 | mStartCellYTop = mCellYTop; | 685 | mStartCellYTop = mCellYTop; |
678 | mStartCellYBottom = mCellYBottom; | 686 | mStartCellYBottom = mCellYBottom; |
679 | } | 687 | } |
680 | 688 | ||
681 | void KOAgendaItem::resetMove() | 689 | void KOAgendaItem::resetMove() |
682 | { | 690 | { |
683 | mCellX = mStartCellX; | 691 | mCellX = mStartCellX; |
684 | mCellXWidth = mStartCellXWidth; | 692 | mCellXWidth = mStartCellXWidth; |
685 | mCellYTop = mStartCellYTop; | 693 | mCellYTop = mStartCellYTop; |
686 | mCellYBottom = mStartCellYBottom; | 694 | mCellYBottom = mStartCellYBottom; |
687 | } | 695 | } |
688 | 696 | ||
689 | void KOAgendaItem::moveRelative(int dx, int dy) | 697 | void KOAgendaItem::moveRelative(int dx, int dy) |
690 | { | 698 | { |
691 | int newX = cellX() + dx; | 699 | int newX = cellX() + dx; |
692 | int newXWidth = cellXWidth() + dx; | 700 | int newXWidth = cellXWidth() + dx; |
693 | int newYTop = cellYTop() + dy; | 701 | int newYTop = cellYTop() + dy; |
694 | int newYBottom = cellYBottom() + dy; | 702 | int newYBottom = cellYBottom() + dy; |
695 | setCellXY(newX,newYTop,newYBottom); | 703 | setCellXY(newX,newYTop,newYBottom); |
696 | setCellXWidth(newXWidth); | 704 | setCellXWidth(newXWidth); |
697 | } | 705 | } |
698 | 706 | ||
699 | void KOAgendaItem::expandTop(int dy) | 707 | void KOAgendaItem::expandTop(int dy) |
700 | { | 708 | { |
701 | int newYTop = cellYTop() + dy; | 709 | int newYTop = cellYTop() + dy; |
702 | int newYBottom = cellYBottom(); | 710 | int newYBottom = cellYBottom(); |
703 | if (newYTop > newYBottom) newYTop = newYBottom; | 711 | if (newYTop > newYBottom) newYTop = newYBottom; |
704 | setCellY(newYTop, newYBottom); | 712 | setCellY(newYTop, newYBottom); |
705 | } | 713 | } |
706 | 714 | ||
707 | void KOAgendaItem::expandBottom(int dy) | 715 | void KOAgendaItem::expandBottom(int dy) |
708 | { | 716 | { |
709 | int newYTop = cellYTop(); | 717 | int newYTop = cellYTop(); |
710 | int newYBottom = cellYBottom() + dy; | 718 | int newYBottom = cellYBottom() + dy; |
711 | if (newYBottom < newYTop) newYBottom = newYTop; | 719 | if (newYBottom < newYTop) newYBottom = newYTop; |
712 | setCellY(newYTop, newYBottom); | 720 | setCellY(newYTop, newYBottom); |
713 | } | 721 | } |
714 | 722 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4dfb9df..65d6acf 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -516,432 +516,445 @@ void MonthViewCell::setDate( const QDate &date ) | |||
516 | QDate MonthViewCell::date() const | 516 | QDate MonthViewCell::date() const |
517 | { | 517 | { |
518 | return mDate; | 518 | return mDate; |
519 | } | 519 | } |
520 | 520 | ||
521 | void MonthViewCell::setPrimary( bool primary ) | 521 | void MonthViewCell::setPrimary( bool primary ) |
522 | { | 522 | { |
523 | mPrimary = primary; | 523 | mPrimary = primary; |
524 | //setMyPalette(); | 524 | //setMyPalette(); |
525 | } | 525 | } |
526 | void MonthViewCell::setMyPalette() | 526 | void MonthViewCell::setMyPalette() |
527 | { | 527 | { |
528 | 528 | ||
529 | if ( mHoliday) { | 529 | if ( mHoliday) { |
530 | if ( currentPalette == 1 ) return; | 530 | if ( currentPalette == 1 ) return; |
531 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 531 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
532 | setPalette( mHolidayPalette ); | 532 | setPalette( mHolidayPalette ); |
533 | //mLabel->setPalette( mHolidayPalette ); | 533 | //mLabel->setPalette( mHolidayPalette ); |
534 | currentPalette = 1; | 534 | currentPalette = 1; |
535 | 535 | ||
536 | } else { | 536 | } else { |
537 | if ( mPrimary ) { | 537 | if ( mPrimary ) { |
538 | if ( currentPalette == 2 ) return; | 538 | if ( currentPalette == 2 ) return; |
539 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 539 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
540 | //mLabel->setPalette( mPrimaryPalette ); | 540 | //mLabel->setPalette( mPrimaryPalette ); |
541 | setPalette( mPrimaryPalette ); | 541 | setPalette( mPrimaryPalette ); |
542 | currentPalette = 2; | 542 | currentPalette = 2; |
543 | 543 | ||
544 | } else { | 544 | } else { |
545 | if ( currentPalette == 3 ) return; | 545 | if ( currentPalette == 3 ) return; |
546 | setPalette( mNonPrimaryPalette ); | 546 | setPalette( mNonPrimaryPalette ); |
547 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 547 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
548 | //mLabel->setPalette( mNonPrimaryPalette );; | 548 | //mLabel->setPalette( mNonPrimaryPalette );; |
549 | currentPalette = 3; | 549 | currentPalette = 3; |
550 | } | 550 | } |
551 | } | 551 | } |
552 | //QPalette pal = palette(); | 552 | //QPalette pal = palette(); |
553 | 553 | ||
554 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 554 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
555 | } | 555 | } |
556 | QPalette MonthViewCell::getPalette () | 556 | QPalette MonthViewCell::getPalette () |
557 | { | 557 | { |
558 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 558 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
559 | return mStandardPalette; | 559 | return mStandardPalette; |
560 | if ( mHoliday) { | 560 | if ( mHoliday) { |
561 | return mHolidayPalette ; | 561 | return mHolidayPalette ; |
562 | } else { | 562 | } else { |
563 | if ( mPrimary ) { | 563 | if ( mPrimary ) { |
564 | return mPrimaryPalette ; | 564 | return mPrimaryPalette ; |
565 | } | 565 | } |
566 | } | 566 | } |
567 | return mNonPrimaryPalette; | 567 | return mNonPrimaryPalette; |
568 | } | 568 | } |
569 | bool MonthViewCell::isPrimary() const | 569 | bool MonthViewCell::isPrimary() const |
570 | { | 570 | { |
571 | return mPrimary; | 571 | return mPrimary; |
572 | } | 572 | } |
573 | 573 | ||
574 | void MonthViewCell::setHoliday( bool holiday ) | 574 | void MonthViewCell::setHoliday( bool holiday ) |
575 | { | 575 | { |
576 | mHoliday = holiday; | 576 | mHoliday = holiday; |
577 | //setMyPalette(); | 577 | //setMyPalette(); |
578 | } | 578 | } |
579 | 579 | ||
580 | void MonthViewCell::setHoliday( const QString &holiday ) | 580 | void MonthViewCell::setHoliday( const QString &holiday ) |
581 | { | 581 | { |
582 | mHolidayString = holiday; | 582 | mHolidayString = holiday; |
583 | 583 | ||
584 | if ( !holiday.isEmpty() ) { | 584 | if ( !holiday.isEmpty() ) { |
585 | setHoliday( true ); | 585 | setHoliday( true ); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | void MonthViewCell::startUpdateCell() | 589 | void MonthViewCell::startUpdateCell() |
590 | { | 590 | { |
591 | mdayCount = 0; | 591 | mdayCount = 0; |
592 | setFocusPolicy(NoFocus); | 592 | setFocusPolicy(NoFocus); |
593 | if ( !mMonthView->isUpdatePossible() ) | 593 | if ( !mMonthView->isUpdatePossible() ) |
594 | return; | 594 | return; |
595 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 595 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
596 | while ( mitem ) { | 596 | while ( mitem ) { |
597 | mitem->setBlockRepaint( true ); | 597 | mitem->setBlockRepaint( true ); |
598 | mitem = (MonthViewItem *)mitem->next(); | 598 | mitem = (MonthViewItem *)mitem->next(); |
599 | } | 599 | } |
600 | if ( mAvailItemList.count() > 20 ) { | 600 | if ( mAvailItemList.count() > 20 ) { |
601 | mAvailItemList.setAutoDelete( true ); | 601 | mAvailItemList.setAutoDelete( true ); |
602 | mAvailItemList.clear(); | 602 | mAvailItemList.clear(); |
603 | mAvailItemList.setAutoDelete( false ); | 603 | mAvailItemList.setAutoDelete( false ); |
604 | } | 604 | } |
605 | /* | 605 | /* |
606 | if ( !isVisible() ){ | 606 | if ( !isVisible() ){ |
607 | return; | 607 | return; |
608 | } | 608 | } |
609 | */ | 609 | */ |
610 | // qDebug("MonthViewCell::updateCell() "); | 610 | // qDebug("MonthViewCell::updateCell() "); |
611 | setPrimary( mDate.month()%2 ); | 611 | setPrimary( mDate.month()%2 ); |
612 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 612 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
613 | if ( mDate == QDate::currentDate() ) { | 613 | if ( mDate == QDate::currentDate() ) { |
614 | setLineWidth( 3 ); | 614 | setLineWidth( 3 ); |
615 | } else { | 615 | } else { |
616 | setLineWidth( 1 ); | 616 | setLineWidth( 1 ); |
617 | } | 617 | } |
618 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 618 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
619 | //clear(); | 619 | //clear(); |
620 | while ( CurrentAvailItem ) { | 620 | while ( CurrentAvailItem ) { |
621 | MonthViewItem *item = CurrentAvailItem; | 621 | MonthViewItem *item = CurrentAvailItem; |
622 | CurrentAvailItem = (MonthViewItem *)item->next(); | 622 | CurrentAvailItem = (MonthViewItem *)item->next(); |
623 | mAvailItemList.append( item ); | 623 | mAvailItemList.append( item ); |
624 | takeItem ( item ); | 624 | takeItem ( item ); |
625 | } | 625 | } |
626 | 626 | ||
627 | #ifdef DESKTOP_VERSION | 627 | #ifdef DESKTOP_VERSION |
628 | QToolTip::remove(this); | 628 | QToolTip::remove(this); |
629 | #endif | 629 | #endif |
630 | mToolTip.clear(); | 630 | mToolTip.clear(); |
631 | //qApp->processEvents(); | 631 | //qApp->processEvents(); |
632 | #if 0 | 632 | #if 0 |
633 | if ( !mHolidayString.isEmpty() ) { | 633 | if ( !mHolidayString.isEmpty() ) { |
634 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 634 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
635 | item->setPalette( mHolidayPalette ); | 635 | item->setPalette( mHolidayPalette ); |
636 | insertItem( item ); | 636 | insertItem( item ); |
637 | mToolTip.append ( mHolidayString ); | 637 | mToolTip.append ( mHolidayString ); |
638 | } | 638 | } |
639 | #endif | 639 | #endif |
640 | } | 640 | } |
641 | 641 | ||
642 | int MonthViewCell::insertEvent(Event *event) | 642 | int MonthViewCell::insertEvent(Event *event) |
643 | { | 643 | { |
644 | bool useToolTips = true; | ||
645 | #ifndef DEKSTOP_VERSION | ||
646 | useToolTips = false; | ||
647 | #endif | ||
644 | QString mToolTipText; | 648 | QString mToolTipText; |
645 | setFocusPolicy(WheelFocus); | 649 | setFocusPolicy(WheelFocus); |
646 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 650 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
647 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 651 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
648 | return mdayCount; | 652 | return mdayCount; |
649 | else | 653 | else |
650 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 654 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
651 | return mdayCount; | 655 | return mdayCount; |
652 | } | 656 | } |
653 | 657 | ||
654 | if ( event->isHoliday()) { | 658 | if ( event->isHoliday()) { |
655 | setHoliday( true ); | 659 | setHoliday( true ); |
656 | if ( mDate.dayOfWeek() == 7 ) | 660 | if ( mDate.dayOfWeek() == 7 ) |
657 | setLineWidth( 3 ); | 661 | setLineWidth( 3 ); |
658 | } | 662 | } |
659 | QString text; | 663 | QString text; |
660 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 664 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
661 | if (event->isMultiDay()) { | 665 | if (event->isMultiDay()) { |
662 | QString prefix = "<->";multiday = 2; | 666 | QString prefix = "<->";multiday = 2; |
663 | QString time; | 667 | QString time; |
664 | if ( event->doesRecur() ) { | 668 | if ( event->doesRecur() ) { |
665 | if ( event->recursOn( mDate) ) { | 669 | if ( event->recursOn( mDate) ) { |
666 | prefix ="->" ;multiday = 1; | 670 | prefix ="->" ;multiday = 1; |
667 | } | 671 | } |
668 | else { | 672 | else { |
669 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 673 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
670 | if ( event->recursOn( mDate.addDays( -days)) ) { | 674 | if ( event->recursOn( mDate.addDays( -days)) ) { |
671 | prefix ="<-" ;multiday = 3; | 675 | prefix ="<-" ;multiday = 3; |
672 | } | 676 | } |
673 | } | 677 | } |
674 | 678 | ||
675 | } else { | 679 | } else { |
676 | if (mDate == event->dtStart().date()) { | 680 | if (mDate == event->dtStart().date()) { |
677 | prefix ="->" ;multiday = 1; | 681 | prefix ="->" ;multiday = 1; |
678 | } else if (mDate == event->dtEnd().date()) { | 682 | } else if (mDate == event->dtEnd().date()) { |
679 | prefix ="<-" ;multiday = 3; | 683 | prefix ="<-" ;multiday = 3; |
680 | } | 684 | } |
681 | } | 685 | } |
682 | if ( !event->doesFloat() ) { | 686 | if ( !event->doesFloat() ) { |
683 | if ( mDate == event->dtStart().date () ) | 687 | if ( mDate == event->dtStart().date () ) |
684 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 688 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
685 | else if ( mDate == event->dtEnd().date () ) | 689 | else if ( mDate == event->dtEnd().date () ) |
686 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 690 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
687 | 691 | ||
688 | } | 692 | } |
689 | text = time + event->summary(); | 693 | text = time + event->summary(); |
690 | mToolTipText += prefix + text; | 694 | if ( useToolTips ) |
695 | mToolTipText += prefix + text; | ||
691 | } else { | 696 | } else { |
692 | if (event->doesFloat()) { | 697 | if (event->doesFloat()) { |
693 | text = event->summary(); | 698 | text = event->summary(); |
694 | mToolTipText += text; | 699 | if ( useToolTips ) |
700 | mToolTipText += text; | ||
695 | } | 701 | } |
696 | else { | 702 | else { |
697 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 703 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
698 | text += " " + event->summary(); | 704 | text += " " + event->summary(); |
699 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 705 | if ( useToolTips ) |
706 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | ||
700 | } | 707 | } |
701 | } | 708 | } |
709 | if ( useToolTips && ! event->location().isEmpty() ) { | ||
710 | mToolTipText += " (" + event->location() +")"; | ||
711 | } | ||
702 | MonthViewItem *item ; | 712 | MonthViewItem *item ; |
703 | 713 | ||
704 | if ( mAvailItemList.count() ) { | 714 | if ( mAvailItemList.count() ) { |
705 | item = mAvailItemList.first(); | 715 | item = mAvailItemList.first(); |
706 | mAvailItemList.remove( item ); | 716 | mAvailItemList.remove( item ); |
707 | item->recycle( event, mDate, text ); | 717 | item->recycle( event, mDate, text ); |
708 | } else { | 718 | } else { |
709 | item = new MonthViewItem( event, mDate, text ); | 719 | item = new MonthViewItem( event, mDate, text ); |
710 | } | 720 | } |
711 | 721 | ||
712 | QPalette pal; | 722 | QPalette pal; |
713 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 723 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
714 | QStringList categories = event->categories(); | 724 | QStringList categories = event->categories(); |
715 | QString cat = categories.first(); | 725 | QString cat = categories.first(); |
716 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 726 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
717 | pal = getPalette(); | 727 | pal = getPalette(); |
718 | if (cat.isEmpty()) { | 728 | if (cat.isEmpty()) { |
719 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 729 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
720 | } else { | 730 | } else { |
721 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 731 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
722 | } | 732 | } |
723 | 733 | ||
724 | } else { | 734 | } else { |
725 | if (cat.isEmpty()) { | 735 | if (cat.isEmpty()) { |
726 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 736 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
727 | } else { | 737 | } else { |
728 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 738 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
729 | } | 739 | } |
730 | } | 740 | } |
731 | 741 | ||
732 | } else { | 742 | } else { |
733 | pal = mStandardPalette ; | 743 | pal = mStandardPalette ; |
734 | } | 744 | } |
735 | item->setPalette( pal ); | 745 | item->setPalette( pal ); |
736 | item->setRecur( event->recurrence()->doesRecur() ); | 746 | item->setRecur( event->recurrence()->doesRecur() ); |
737 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 747 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
738 | item->setMoreInfo( event->description().length() > 0 ); | 748 | item->setMoreInfo( event->description().length() > 0 ); |
739 | #ifdef DESKTOP_VERSION | 749 | #ifdef DESKTOP_VERSION |
740 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 750 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
741 | KOPrefs::instance()->email()); | 751 | KOPrefs::instance()->email()); |
742 | if ( me != 0 ) { | 752 | if ( me != 0 ) { |
743 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 753 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
744 | item->setReply(true && multiday < 2); | 754 | item->setReply(true && multiday < 2); |
745 | else | 755 | else |
746 | item->setReply(false); | 756 | item->setReply(false); |
747 | } else | 757 | } else |
748 | item->setReply(false); | 758 | item->setReply(false); |
749 | #endif | 759 | #endif |
750 | item->setMultiDay( multiday ); | 760 | item->setMultiDay( multiday ); |
751 | if ( multiday ) { | 761 | if ( multiday ) { |
752 | insertItem( item ,mdayCount); | 762 | insertItem( item ,mdayCount); |
753 | ++mdayCount; | 763 | ++mdayCount; |
754 | } else { | 764 | } else { |
755 | uint i; | 765 | uint i; |
756 | int pos = mdayCount; | 766 | int pos = mdayCount; |
757 | for ( i = mdayCount; i < count();++i ) { | 767 | for ( i = mdayCount; i < count();++i ) { |
758 | QListBoxItem* it = this->item ( i ); | 768 | QListBoxItem* it = this->item ( i ); |
759 | if ( text < it->text() ) { | 769 | if ( text < it->text() ) { |
760 | pos = i; | 770 | pos = i; |
761 | break; | 771 | break; |
762 | } | 772 | } |
763 | ++pos; | 773 | ++pos; |
764 | } | 774 | } |
765 | insertItem( item ,pos); | 775 | insertItem( item ,pos); |
766 | } | 776 | } |
767 | mToolTip.append( mToolTipText ); | 777 | if ( useToolTips ) |
778 | mToolTip.append( mToolTipText ); | ||
768 | return mdayCount; | 779 | return mdayCount; |
769 | } | 780 | } |
770 | void MonthViewCell::insertTodo(Todo *todo) | 781 | void MonthViewCell::insertTodo(Todo *todo) |
771 | { | 782 | { |
772 | setFocusPolicy(WheelFocus); | 783 | setFocusPolicy(WheelFocus); |
773 | QString text; | 784 | QString text; |
774 | if (todo->hasDueDate()) { | 785 | if (todo->hasDueDate()) { |
775 | if (!todo->doesFloat()) { | 786 | if (!todo->doesFloat()) { |
776 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 787 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
777 | text += " "; | 788 | text += " "; |
778 | } | 789 | } |
779 | } | 790 | } |
780 | text += todo->summary(); | 791 | text += todo->summary(); |
781 | MonthViewItem *item ; | 792 | MonthViewItem *item ; |
782 | if ( mAvailItemList.count() ) { | 793 | if ( mAvailItemList.count() ) { |
783 | item = mAvailItemList.first(); | 794 | item = mAvailItemList.first(); |
784 | mAvailItemList.remove( item ); | 795 | mAvailItemList.remove( item ); |
785 | item->recycle( todo, mDate, text ); | 796 | item->recycle( todo, mDate, text ); |
786 | } else { | 797 | } else { |
787 | item = new MonthViewItem( todo, mDate, text ); | 798 | item = new MonthViewItem( todo, mDate, text ); |
788 | } | 799 | } |
789 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 800 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
790 | //item->setPalette( mStandardPalette ); | 801 | //item->setPalette( mStandardPalette ); |
791 | QPalette pal; | 802 | QPalette pal; |
792 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 803 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
793 | QStringList categories = todo->categories(); | 804 | QStringList categories = todo->categories(); |
794 | QString cat = categories.first(); | 805 | QString cat = categories.first(); |
795 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 806 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
796 | pal = getPalette(); | 807 | pal = getPalette(); |
797 | if (cat.isEmpty()) { | 808 | if (cat.isEmpty()) { |
798 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 809 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
799 | } else { | 810 | } else { |
800 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 811 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
801 | } | 812 | } |
802 | 813 | ||
803 | } else { | 814 | } else { |
804 | if (cat.isEmpty()) { | 815 | if (cat.isEmpty()) { |
805 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 816 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
806 | } else { | 817 | } else { |
807 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 818 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
808 | } | 819 | } |
809 | } | 820 | } |
810 | 821 | ||
811 | } else { | 822 | } else { |
812 | pal = mStandardPalette ; | 823 | pal = mStandardPalette ; |
813 | } | 824 | } |
814 | item->setPalette( pal ); | 825 | item->setPalette( pal ); |
815 | item->setRecur( todo->recurrence()->doesRecur() ); | 826 | item->setRecur( todo->recurrence()->doesRecur() ); |
816 | item->setAlarm( todo->isAlarmEnabled() ); | 827 | item->setAlarm( todo->isAlarmEnabled() ); |
817 | item->setMoreInfo( todo->description().length() > 0 ); | 828 | item->setMoreInfo( todo->description().length() > 0 ); |
818 | insertItem( item , count()); | 829 | insertItem( item , count()); |
830 | #ifdef DESKTOP_VERSION | ||
819 | mToolTip.append( text ); | 831 | mToolTip.append( text ); |
832 | #endif | ||
820 | } | 833 | } |
821 | void MonthViewCell::repaintfinishUpdateCell() | 834 | void MonthViewCell::repaintfinishUpdateCell() |
822 | { | 835 | { |
823 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 836 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
824 | while ( mitem ) { | 837 | while ( mitem ) { |
825 | mitem->setBlockRepaint( false ); | 838 | mitem->setBlockRepaint( false ); |
826 | updateItem ( mitem ); | 839 | updateItem ( mitem ); |
827 | mitem = (MonthViewItem *)mitem->next(); | 840 | mitem = (MonthViewItem *)mitem->next(); |
828 | } | 841 | } |
829 | } | 842 | } |
830 | void MonthViewCell::finishUpdateCell() | 843 | void MonthViewCell::finishUpdateCell() |
831 | { | 844 | { |
832 | 845 | ||
833 | 846 | ||
834 | 847 | ||
835 | #ifdef DESKTOP_VERSION | 848 | #ifdef DESKTOP_VERSION |
836 | if (mToolTip.count() > 0 ) { | 849 | if (mToolTip.count() > 0 ) { |
837 | mToolTip.sort(); | 850 | mToolTip.sort(); |
838 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 851 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
839 | } | 852 | } |
840 | #endif | 853 | #endif |
841 | //sort(); | 854 | //sort(); |
842 | //setMyPalette(); | 855 | //setMyPalette(); |
843 | setMyPalette(); | 856 | setMyPalette(); |
844 | 857 | ||
845 | resizeEvent( 0 ); | 858 | resizeEvent( 0 ); |
846 | 859 | ||
847 | } | 860 | } |
848 | void MonthViewCell::updateCell() | 861 | void MonthViewCell::updateCell() |
849 | { | 862 | { |
850 | //qDebug("MonthViewCell::updateCell() "); | 863 | //qDebug("MonthViewCell::updateCell() "); |
851 | if ( !mMonthView->isUpdatePossible() ) | 864 | if ( !mMonthView->isUpdatePossible() ) |
852 | return; | 865 | return; |
853 | startUpdateCell(); | 866 | startUpdateCell(); |
854 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 867 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
855 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 868 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
856 | Event *event; | 869 | Event *event; |
857 | for( event = events.first(); event; event = events.next() ) { // for event | 870 | for( event = events.first(); event; event = events.next() ) { // for event |
858 | insertEvent(event); | 871 | insertEvent(event); |
859 | } | 872 | } |
860 | // insert due todos | 873 | // insert due todos |
861 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 874 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
862 | Todo *todo; | 875 | Todo *todo; |
863 | for(todo = todos.first(); todo; todo = todos.next()) { | 876 | for(todo = todos.first(); todo; todo = todos.next()) { |
864 | insertTodo( todo ); | 877 | insertTodo( todo ); |
865 | } | 878 | } |
866 | finishUpdateCell(); | 879 | finishUpdateCell(); |
867 | // if ( isVisible()) | 880 | // if ( isVisible()) |
868 | //qApp->processEvents(); | 881 | //qApp->processEvents(); |
869 | } | 882 | } |
870 | 883 | ||
871 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 884 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
872 | { | 885 | { |
873 | 886 | ||
874 | if ( bigFont ) { | 887 | if ( bigFont ) { |
875 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 888 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
876 | int ps = fo.pointSize() + 2; | 889 | int ps = fo.pointSize() + 2; |
877 | if ( ps < 18 ) | 890 | if ( ps < 18 ) |
878 | ps += 2; | 891 | ps += 2; |
879 | fo.setPointSize( ps ); | 892 | fo.setPointSize( ps ); |
880 | setFont( fo ); | 893 | setFont( fo ); |
881 | } else | 894 | } else |
882 | setFont( KOPrefs::instance()->mMonthViewFont ); | 895 | setFont( KOPrefs::instance()->mMonthViewFont ); |
883 | 896 | ||
884 | QFontMetrics fm( font() ); | 897 | QFontMetrics fm( font() ); |
885 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 898 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
886 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 899 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
887 | mHolidayPalette = mStandardPalette; | 900 | mHolidayPalette = mStandardPalette; |
888 | mPrimaryPalette = mStandardPalette; | 901 | mPrimaryPalette = mStandardPalette; |
889 | mNonPrimaryPalette = mStandardPalette; | 902 | mNonPrimaryPalette = mStandardPalette; |
890 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 903 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
891 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 904 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
892 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 905 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
893 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 906 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
894 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 907 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
895 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 908 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
896 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 909 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
897 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 910 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
898 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 911 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
899 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 912 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
900 | } | 913 | } |
901 | //updateCell(); | 914 | //updateCell(); |
902 | } | 915 | } |
903 | 916 | ||
904 | void MonthViewCell::enableScrollBars( bool enabled ) | 917 | void MonthViewCell::enableScrollBars( bool enabled ) |
905 | { | 918 | { |
906 | 919 | ||
907 | return; | 920 | return; |
908 | if ( enabled ) { | 921 | if ( enabled ) { |
909 | QListBoxItem *fi = firstItem (); | 922 | QListBoxItem *fi = firstItem (); |
910 | if (fi ) { | 923 | if (fi ) { |
911 | int ihei = fi->height( this ); | 924 | int ihei = fi->height( this ); |
912 | int hei = numRows () * ihei; | 925 | int hei = numRows () * ihei; |
913 | if ( hei < height() - horizontalScrollBar()->height () ) { | 926 | if ( hei < height() - horizontalScrollBar()->height () ) { |
914 | setVScrollBarMode(QScrollView::AlwaysOff); | 927 | setVScrollBarMode(QScrollView::AlwaysOff); |
915 | } | 928 | } |
916 | else | 929 | else |
917 | setVScrollBarMode(QScrollView::Auto); | 930 | setVScrollBarMode(QScrollView::Auto); |
918 | if ( ihei *3 > height() ) { | 931 | if ( ihei *3 > height() ) { |
919 | setHScrollBarMode(QScrollView::AlwaysOff); | 932 | setHScrollBarMode(QScrollView::AlwaysOff); |
920 | } | 933 | } |
921 | else { | 934 | else { |
922 | setHScrollBarMode(QScrollView::Auto); | 935 | setHScrollBarMode(QScrollView::Auto); |
923 | } | 936 | } |
924 | } else { | 937 | } else { |
925 | setVScrollBarMode(QScrollView::Auto); | 938 | setVScrollBarMode(QScrollView::Auto); |
926 | setHScrollBarMode(QScrollView::Auto); | 939 | setHScrollBarMode(QScrollView::Auto); |
927 | } | 940 | } |
928 | } else { | 941 | } else { |
929 | setVScrollBarMode(QScrollView::AlwaysOff); | 942 | setVScrollBarMode(QScrollView::AlwaysOff); |
930 | setHScrollBarMode(QScrollView::AlwaysOff); | 943 | setHScrollBarMode(QScrollView::AlwaysOff); |
931 | } | 944 | } |
932 | } | 945 | } |
933 | 946 | ||
934 | Incidence *MonthViewCell::selectedIncidence() | 947 | Incidence *MonthViewCell::selectedIncidence() |
935 | { | 948 | { |
936 | int index = currentItem(); | 949 | int index = currentItem(); |
937 | if ( index < 0 ) return 0; | 950 | if ( index < 0 ) return 0; |
938 | 951 | ||
939 | MonthViewItem *mitem = | 952 | MonthViewItem *mitem = |
940 | static_cast<MonthViewItem *>( item( index ) ); | 953 | static_cast<MonthViewItem *>( item( index ) ); |
941 | 954 | ||
942 | if ( !mitem ) return 0; | 955 | if ( !mitem ) return 0; |
943 | 956 | ||
944 | return mitem->incidence(); | 957 | return mitem->incidence(); |
945 | } | 958 | } |
946 | 959 | ||
947 | QDate MonthViewCell::selectedIncidenceDate() | 960 | QDate MonthViewCell::selectedIncidenceDate() |