author | zecke <zecke> | 2004-11-18 22:20:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 22:20:17 (UTC) |
commit | 770e76de2e039300a1e89f3cb0c4785a8d1c16a7 (patch) (unidiff) | |
tree | 2e0ffedac20db3e5adc0e6ab216f9121fe7e91ca /libopie2 | |
parent | ea24c0654cab6eb62ad4be717c7a2380ad1aa978 (diff) | |
download | opie-770e76de2e039300a1e89f3cb0c4785a8d1c16a7.zip opie-770e76de2e039300a1e89f3cb0c4785a8d1c16a7.tar.gz opie-770e76de2e039300a1e89f3cb0c4785a8d1c16a7.tar.bz2 |
Remove obsoleted OPimEffectiveEvent as it is superseeded
by the generic OPimOccurrence
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 263 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimevent.h | 65 |
2 files changed, 0 insertions, 328 deletions
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp index 1b553d8..cc84426 100644 --- a/libopie2/opiepim/core/opimevent.cpp +++ b/libopie2/opiepim/core/opimevent.cpp | |||
@@ -736,312 +736,49 @@ QArray<int> OPimEvent::children() const | |||
736 | } | 736 | } |
737 | 737 | ||
738 | 738 | ||
739 | void OPimEvent::setChildren( const QArray<int>& arr ) | 739 | void OPimEvent::setChildren( const QArray<int>& arr ) |
740 | { | 740 | { |
741 | changeOrModify(); | 741 | changeOrModify(); |
742 | if ( data->child ) delete data->child; | 742 | if ( data->child ) delete data->child; |
743 | 743 | ||
744 | data->child = new QArray<int>( arr ); | 744 | data->child = new QArray<int>( arr ); |
745 | data->child->detach(); | 745 | data->child->detach(); |
746 | } | 746 | } |
747 | 747 | ||
748 | 748 | ||
749 | void OPimEvent::addChild( int uid ) | 749 | void OPimEvent::addChild( int uid ) |
750 | { | 750 | { |
751 | changeOrModify(); | 751 | changeOrModify(); |
752 | if ( !data->child ) | 752 | if ( !data->child ) |
753 | { | 753 | { |
754 | data->child = new QArray<int>( 1 ); | 754 | data->child = new QArray<int>( 1 ); |
755 | ( *data->child ) [ 0 ] = uid; | 755 | ( *data->child ) [ 0 ] = uid; |
756 | } | 756 | } |
757 | else | 757 | else |
758 | { | 758 | { |
759 | int count = data->child->count(); | 759 | int count = data->child->count(); |
760 | data->child->resize( count + 1 ); | 760 | data->child->resize( count + 1 ); |
761 | ( *data->child ) [ count ] = uid; | 761 | ( *data->child ) [ count ] = uid; |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | void OPimEvent::removeChild( int uid ) | 766 | void OPimEvent::removeChild( int uid ) |
767 | { | 767 | { |
768 | if ( !data->child || !data->child->contains( uid ) ) return ; | 768 | if ( !data->child || !data->child->contains( uid ) ) return ; |
769 | changeOrModify(); | 769 | changeOrModify(); |
770 | QArray<int> newAr( data->child->count() - 1 ); | 770 | QArray<int> newAr( data->child->count() - 1 ); |
771 | int j = 0; | 771 | int j = 0; |
772 | uint count = data->child->count(); | 772 | uint count = data->child->count(); |
773 | for ( uint i = 0; i < count; i++ ) | 773 | for ( uint i = 0; i < count; i++ ) |
774 | { | 774 | { |
775 | if ( ( *data->child ) [ i ] != uid ) | 775 | if ( ( *data->child ) [ i ] != uid ) |
776 | { | 776 | { |
777 | newAr[ j ] = ( *data->child ) [ i ]; | 777 | newAr[ j ] = ( *data->child ) [ i ]; |
778 | j++; | 778 | j++; |
779 | } | 779 | } |
780 | } | 780 | } |
781 | ( *data->child ) = newAr; | 781 | ( *data->child ) = newAr; |
782 | } | 782 | } |
783 | 783 | ||
784 | |||
785 | struct OEffectiveEvent::Data : public QShared | ||
786 | { | ||
787 | Data() : QShared() | ||
788 | {} | ||
789 | OPimEvent event; | ||
790 | QDate date; | ||
791 | QTime start, end; | ||
792 | QDate startDate, endDate; | ||
793 | bool dates : 1; | ||
794 | }; | ||
795 | |||
796 | |||
797 | OEffectiveEvent::OEffectiveEvent() | ||
798 | { | ||
799 | data = new Data; | ||
800 | data->date = QDate::currentDate(); | ||
801 | data->start = data->end = QTime::currentTime(); | ||
802 | data->dates = false; | ||
803 | } | ||
804 | |||
805 | |||
806 | OEffectiveEvent::OEffectiveEvent( const OPimEvent& ev, const QDate& startDate, | ||
807 | Position pos ) | ||
808 | { | ||
809 | data = new Data; | ||
810 | data->event = ev; | ||
811 | data->date = startDate; | ||
812 | if ( pos & Start ) | ||
813 | data->start = ev.startDateTime().time(); | ||
814 | else | ||
815 | data->start = QTime( 0, 0, 0 ); | ||
816 | |||
817 | if ( pos & End ) | ||
818 | data->end = ev.endDateTime().time(); | ||
819 | else | ||
820 | data->end = QTime( 23, 59, 59 ); | ||
821 | |||
822 | data->dates = false; | ||
823 | } | ||
824 | |||
825 | |||
826 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev ) | ||
827 | { | ||
828 | data = ev.data; | ||
829 | data->ref(); | ||
830 | } | ||
831 | |||
832 | |||
833 | OEffectiveEvent::~OEffectiveEvent() | ||
834 | { | ||
835 | if ( data->deref() ) | ||
836 | { | ||
837 | delete data; | ||
838 | data = 0; | ||
839 | } | ||
840 | } | ||
841 | |||
842 | |||
843 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) | ||
844 | { | ||
845 | if ( *this == ev ) return * this; | ||
846 | |||
847 | ev.data->ref(); | ||
848 | deref(); | ||
849 | data = ev.data; | ||
850 | |||
851 | return *this; | ||
852 | } | ||
853 | |||
854 | |||
855 | void OEffectiveEvent::setStartTime( const QTime& ti ) | ||
856 | { | ||
857 | changeOrModify(); | ||
858 | data->start = ti; | ||
859 | } | ||
860 | |||
861 | |||
862 | void OEffectiveEvent::setEndTime( const QTime& en ) | ||
863 | { | ||
864 | changeOrModify(); | ||
865 | data->end = en; | ||
866 | } | ||
867 | |||
868 | |||
869 | void OEffectiveEvent::setEvent( const OPimEvent& ev ) | ||
870 | { | ||
871 | changeOrModify(); | ||
872 | data->event = ev; | ||
873 | } | ||
874 | |||
875 | |||
876 | void OEffectiveEvent::setDate( const QDate& da ) | ||
877 | { | ||
878 | changeOrModify(); | ||
879 | data->date = da; | ||
880 | } | ||
881 | |||
882 | |||
883 | void OEffectiveEvent::setEffectiveDates( const QDate& from, | ||
884 | const QDate& to ) | ||
885 | { | ||
886 | if ( !from.isValid() ) | ||
887 | { | ||
888 | data->dates = false; | ||
889 | return ; | ||
890 | } | ||
891 | |||
892 | data->startDate = from; | ||
893 | data->endDate = to; | ||
894 | } | ||
895 | |||
896 | |||
897 | QString OEffectiveEvent::description() const | ||
898 | { | ||
899 | return data->event.description(); | ||
900 | } | ||
901 | |||
902 | |||
903 | QString OEffectiveEvent::location() const | ||
904 | { | ||
905 | return data->event.location(); | ||
906 | } | ||
907 | |||
908 | |||
909 | QString OEffectiveEvent::note() const | ||
910 | { | ||
911 | return data->event.note(); | ||
912 | } | ||
913 | |||
914 | |||
915 | OPimEvent OEffectiveEvent::event() const | ||
916 | { | ||
917 | return data->event; | ||
918 | } | ||
919 | |||
920 | |||
921 | QTime OEffectiveEvent::startTime() const | ||
922 | { | ||
923 | return data->start; | ||
924 | } | ||
925 | |||
926 | |||
927 | QTime OEffectiveEvent::endTime() const | ||
928 | { | ||
929 | return data->end; | ||
930 | } | ||
931 | |||
932 | |||
933 | QDate OEffectiveEvent::date() const | ||
934 | { | ||
935 | return data->date; | ||
936 | } | ||
937 | |||
938 | |||
939 | int OEffectiveEvent::length() const | ||
940 | { | ||
941 | return ( data->end.hour() * 60 - data->start.hour() * 60 ) | ||
942 | + QABS( data->start.minute() - data->end.minute() ); | ||
943 | } | ||
944 | |||
945 | |||
946 | int OEffectiveEvent::size() const | ||
947 | { | ||
948 | return ( data->end.hour() - data->start.hour() ) * 3600 | ||
949 | + ( data->end.minute() - data->start.minute() * 60 | ||
950 | + data->end.second() - data->start.second() ); | ||
951 | } | ||
952 | |||
953 | |||
954 | QDate OEffectiveEvent::startDate() const | ||
955 | { | ||
956 | if ( data->dates ) | ||
957 | return data->startDate; | ||
958 | else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer | ||
959 | return data->date; | ||
960 | else | ||
961 | return data->event.startDateTime().date(); | ||
962 | } | ||
963 | |||
964 | |||
965 | QDate OEffectiveEvent::endDate() const | ||
966 | { | ||
967 | if ( data->dates ) | ||
968 | return data->endDate; | ||
969 | else if ( data->event.hasRecurrence() ) | ||
970 | return data->date; | ||
971 | else | ||
972 | return data->event.endDateTime().date(); | ||
973 | } | ||
974 | |||
975 | |||
976 | void OEffectiveEvent::deref() | ||
977 | { | ||
978 | if ( data->deref() ) | ||
979 | { | ||
980 | delete data; | ||
981 | data = 0; | ||
982 | } | ||
983 | } | ||
984 | |||
985 | |||
986 | void OEffectiveEvent::changeOrModify() | ||
987 | { | ||
988 | if ( data->count != 1 ) | ||
989 | { | ||
990 | data->deref(); | ||
991 | Data* d2 = new Data; | ||
992 | d2->event = data->event; | ||
993 | d2->date = data->date; | ||
994 | d2->start = data->start; | ||
995 | d2->end = data->end; | ||
996 | d2->startDate = data->startDate; | ||
997 | d2->endDate = data->endDate; | ||
998 | d2->dates = data->dates; | ||
999 | data = d2; | ||
1000 | } | ||
1001 | } | ||
1002 | |||
1003 | |||
1004 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const | ||
1005 | { | ||
1006 | if ( data->date < e.date() ) | ||
1007 | return TRUE; | ||
1008 | if ( data->date == e.date() ) | ||
1009 | return ( startTime() < e.startTime() ); | ||
1010 | else | ||
1011 | return FALSE; | ||
1012 | } | ||
1013 | |||
1014 | |||
1015 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const | ||
1016 | { | ||
1017 | return ( data->date <= e.date() ); | ||
1018 | } | ||
1019 | |||
1020 | |||
1021 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const | ||
1022 | { | ||
1023 | return ( date() == e.date() | ||
1024 | && startTime() == e.startTime() | ||
1025 | && endTime() == e.endTime() | ||
1026 | && event() == e.event() ); | ||
1027 | } | ||
1028 | |||
1029 | |||
1030 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const | ||
1031 | { | ||
1032 | return !( *this == e ); | ||
1033 | } | ||
1034 | |||
1035 | |||
1036 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const | ||
1037 | { | ||
1038 | return !( *this <= e ); | ||
1039 | } | ||
1040 | |||
1041 | |||
1042 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const | ||
1043 | { | ||
1044 | return !( *this < e ); | ||
1045 | } | ||
1046 | |||
1047 | } | 784 | } |
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h index 32f648f..1d12530 100644 --- a/libopie2/opiepim/core/opimevent.h +++ b/libopie2/opiepim/core/opimevent.h | |||
@@ -174,116 +174,51 @@ class OPimEvent : public OPimRecord | |||
174 | QArray<int> children() const; | 174 | QArray<int> children() const; |
175 | void setChildren( const QArray<int>& ); | 175 | void setChildren( const QArray<int>& ); |
176 | void addChild( int uid ); | 176 | void addChild( int uid ); |
177 | void removeChild( int uid ); | 177 | void removeChild( int uid ); |
178 | //@} | 178 | //@} |
179 | 179 | ||
180 | /** return the parent OPimEvent */ | 180 | /** return the parent OPimEvent */ |
181 | int parent() const; | 181 | int parent() const; |
182 | void setParent( int uid ); | 182 | void setParent( int uid ); |
183 | 183 | ||
184 | 184 | ||
185 | /* needed reimp */ | 185 | /* needed reimp */ |
186 | //@{ Reimplementations | 186 | //@{ Reimplementations |
187 | virtual bool match( const QRegExp& ) const; | 187 | virtual bool match( const QRegExp& ) const; |
188 | QString toRichText() const; | 188 | QString toRichText() const; |
189 | QString toShortText() const; | 189 | QString toShortText() const; |
190 | QString type() const; | 190 | QString type() const; |
191 | 191 | ||
192 | QMap<int, QString> toMap() const; | 192 | QMap<int, QString> toMap() const; |
193 | void fromMap( const QMap<int, QString>& map ); | 193 | void fromMap( const QMap<int, QString>& map ); |
194 | QString recordField( int ) const; | 194 | QString recordField( int ) const; |
195 | 195 | ||
196 | bool loadFromStream( QDataStream& ); | 196 | bool loadFromStream( QDataStream& ); |
197 | bool saveToStream( QDataStream& ) const; | 197 | bool saveToStream( QDataStream& ) const; |
198 | //@} | 198 | //@} |
199 | 199 | ||
200 | //@{ | 200 | //@{ |
201 | int rtti() const; | 201 | int rtti() const; |
202 | static OPimEvent* safeCast( const OPimRecord* ); | 202 | static OPimEvent* safeCast( const OPimRecord* ); |
203 | //@} | 203 | //@} |
204 | 204 | ||
205 | /* bool operator==( const OPimEvent& ); | 205 | /* bool operator==( const OPimEvent& ); |
206 | bool operator!=( const OPimEvent& ); | 206 | bool operator!=( const OPimEvent& ); |
207 | bool operator<( const OPimEvent& ); | 207 | bool operator<( const OPimEvent& ); |
208 | bool operator<=( const OPimEvent& ); | 208 | bool operator<=( const OPimEvent& ); |
209 | bool operator>( const OPimEvent& ); | 209 | bool operator>( const OPimEvent& ); |
210 | bool operator>=(const OPimEvent& ); | 210 | bool operator>=(const OPimEvent& ); |
211 | */ | 211 | */ |
212 | 212 | ||
213 | private: | 213 | private: |
214 | inline void changeOrModify(); | 214 | inline void changeOrModify(); |
215 | void deref(); | 215 | void deref(); |
216 | struct Data; | 216 | struct Data; |
217 | Data* data; | 217 | Data* data; |
218 | class Private; | 218 | class Private; |
219 | Private* priv; | 219 | Private* priv; |
220 | 220 | ||
221 | }; | 221 | }; |
222 | |||
223 | /** | ||
224 | * AN Event can span through multiple days. We split up a multiday eve | ||
225 | */ | ||
226 | class OEffectiveEvent | ||
227 | { | ||
228 | |||
229 | public: | ||
230 | typedef QValueList<OEffectiveEvent> ValueList; | ||
231 | enum Position { MidWay, Start, End, StartEnd }; | ||
232 | // If we calculate the effective event of a multi-day event | ||
233 | // we have to figure out whether we are at the first day, | ||
234 | // at the end, or anywhere else ("middle"). This is important | ||
235 | // for the start/end times (00:00/23:59) | ||
236 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | ||
237 | // day event | ||
238 | // Start: start time -> 23:59 | ||
239 | // End: 00:00 -> end time | ||
240 | // Start | End == StartEnd: for single-day events (default) | ||
241 | // here we draw start time -> end time | ||
242 | OEffectiveEvent(); | ||
243 | OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd ); | ||
244 | OEffectiveEvent( const OEffectiveEvent& ); | ||
245 | OEffectiveEvent &operator=( const OEffectiveEvent& ); | ||
246 | ~OEffectiveEvent(); | ||
247 | |||
248 | void setStartTime( const QTime& ); | ||
249 | void setEndTime( const QTime& ); | ||
250 | void setEvent( const OPimEvent& ); | ||
251 | void setDate( const QDate& ); | ||
252 | |||
253 | void setEffectiveDates( const QDate& from, const QDate& to ); | ||
254 | |||
255 | QString description() const; | ||
256 | QString location() const; | ||
257 | QString note() const; | ||
258 | OPimEvent event() const; | ||
259 | QTime startTime() const; | ||
260 | QTime endTime() const; | ||
261 | QDate date() const; | ||
262 | |||
263 | /* return the length in hours */ | ||
264 | int length() const; | ||
265 | int size() const; | ||
266 | |||
267 | QDate startDate() const; | ||
268 | QDate endDate() const; | ||
269 | |||
270 | bool operator<( const OEffectiveEvent &e ) const; | ||
271 | bool operator<=( const OEffectiveEvent &e ) const; | ||
272 | bool operator==( const OEffectiveEvent &e ) const; | ||
273 | bool operator!=( const OEffectiveEvent &e ) const; | ||
274 | bool operator>( const OEffectiveEvent &e ) const; | ||
275 | bool operator>= ( const OEffectiveEvent &e ) const; | ||
276 | |||
277 | private: | ||
278 | void deref(); | ||
279 | inline void changeOrModify(); | ||
280 | class Private; | ||
281 | Private* priv; | ||
282 | struct Data; | ||
283 | Data* data; | ||
284 | |||
285 | }; | ||
286 | |||
287 | } | 222 | } |
288 | 223 | ||
289 | #endif | 224 | #endif |