-rw-r--r-- | korganizer/calendarview.cpp | 5 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 5150455..f859b90 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -794,209 +794,212 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
794 | return 2; | 794 | return 2; |
795 | return 1; | 795 | return 1; |
796 | break; | 796 | break; |
797 | case SYNC_PREF_REMOTE: | 797 | case SYNC_PREF_REMOTE: |
798 | if ( lastSync > remote->lastModified() ) | 798 | if ( lastSync > remote->lastModified() ) |
799 | return 1; | 799 | return 1; |
800 | if ( lastSync > local->lastModified() ) | 800 | if ( lastSync > local->lastModified() ) |
801 | return 2; | 801 | return 2; |
802 | return 2; | 802 | return 2; |
803 | break; | 803 | break; |
804 | case SYNC_PREF_NEWEST: | 804 | case SYNC_PREF_NEWEST: |
805 | if ( local->lastModified() > remote->lastModified() ) | 805 | if ( local->lastModified() > remote->lastModified() ) |
806 | return 1; | 806 | return 1; |
807 | else | 807 | else |
808 | return 2; | 808 | return 2; |
809 | break; | 809 | break; |
810 | case SYNC_PREF_ASK: | 810 | case SYNC_PREF_ASK: |
811 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 811 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
812 | if ( lastSync > remote->lastModified() ) | 812 | if ( lastSync > remote->lastModified() ) |
813 | return 1; | 813 | return 1; |
814 | if ( lastSync > local->lastModified() ) | 814 | if ( lastSync > local->lastModified() ) |
815 | return 2; | 815 | return 2; |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | localIsNew = local->lastModified() > remote->lastModified(); | 817 | localIsNew = local->lastModified() > remote->lastModified(); |
818 | if ( localIsNew ) | 818 | if ( localIsNew ) |
819 | getEventViewerDialog()->setColorMode( 1 ); | 819 | getEventViewerDialog()->setColorMode( 1 ); |
820 | else | 820 | else |
821 | getEventViewerDialog()->setColorMode( 2 ); | 821 | getEventViewerDialog()->setColorMode( 2 ); |
822 | getEventViewerDialog()->setIncidence(local); | 822 | getEventViewerDialog()->setIncidence(local); |
823 | if ( localIsNew ) | 823 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 2 ); | 824 | getEventViewerDialog()->setColorMode( 2 ); |
825 | else | 825 | else |
826 | getEventViewerDialog()->setColorMode( 1 ); | 826 | getEventViewerDialog()->setColorMode( 1 ); |
827 | getEventViewerDialog()->addIncidence(remote); | 827 | getEventViewerDialog()->addIncidence(remote); |
828 | getEventViewerDialog()->setColorMode( 0 ); | 828 | getEventViewerDialog()->setColorMode( 0 ); |
829 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 829 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
830 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 830 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
831 | getEventViewerDialog()->showMe(); | 831 | getEventViewerDialog()->showMe(); |
832 | result = getEventViewerDialog()->executeS( localIsNew ); | 832 | result = getEventViewerDialog()->executeS( localIsNew ); |
833 | return result; | 833 | return result; |
834 | 834 | ||
835 | break; | 835 | break; |
836 | case SYNC_PREF_FORCE_LOCAL: | 836 | case SYNC_PREF_FORCE_LOCAL: |
837 | return 1; | 837 | return 1; |
838 | break; | 838 | break; |
839 | case SYNC_PREF_FORCE_REMOTE: | 839 | case SYNC_PREF_FORCE_REMOTE: |
840 | return 2; | 840 | return 2; |
841 | break; | 841 | break; |
842 | 842 | ||
843 | default: | 843 | default: |
844 | // SYNC_PREF_TAKE_BOTH not implemented | 844 | // SYNC_PREF_TAKE_BOTH not implemented |
845 | break; | 845 | break; |
846 | } | 846 | } |
847 | return 0; | 847 | return 0; |
848 | } | 848 | } |
849 | Event* CalendarView::getLastSyncEvent() | 849 | Event* CalendarView::getLastSyncEvent() |
850 | { | 850 | { |
851 | Event* lse; | 851 | Event* lse; |
852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
853 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 853 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
854 | if (!lse) { | 854 | if (!lse) { |
855 | lse = new Event(); | 855 | lse = new Event(); |
856 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 856 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
857 | QString sum = ""; | 857 | QString sum = ""; |
858 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 858 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
859 | sum = "E: "; | 859 | sum = "E: "; |
860 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 860 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
861 | lse->setDtStart( mLastCalendarSync ); | 861 | lse->setDtStart( mLastCalendarSync ); |
862 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 862 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
863 | lse->setCategories( i18n("SyncEvent") ); | 863 | lse->setCategories( i18n("SyncEvent") ); |
864 | lse->setReadOnly( true ); | 864 | lse->setReadOnly( true ); |
865 | mCalendar->addEvent( lse ); | 865 | mCalendar->addEvent( lse ); |
866 | } | 866 | } |
867 | 867 | ||
868 | return lse; | 868 | return lse; |
869 | 869 | ||
870 | } | 870 | } |
871 | // probaly useless | 871 | // probaly useless |
872 | void CalendarView::setupExternSyncProfiles() | 872 | void CalendarView::setupExternSyncProfiles() |
873 | { | 873 | { |
874 | Event* lse; | 874 | Event* lse; |
875 | mExternLastSyncEvent.clear(); | 875 | mExternLastSyncEvent.clear(); |
876 | int i; | 876 | int i; |
877 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 877 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
878 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 878 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
879 | if ( lse ) | 879 | if ( lse ) |
880 | mExternLastSyncEvent.append( lse ); | 880 | mExternLastSyncEvent.append( lse ); |
881 | else | 881 | else |
882 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 882 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
883 | } | 883 | } |
884 | 884 | ||
885 | } | 885 | } |
886 | // we check, if the to delete event has a id for a profile | 886 | // we check, if the to delete event has a id for a profile |
887 | // if yes, we set this id in the profile to delete | 887 | // if yes, we set this id in the profile to delete |
888 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 888 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
889 | { | 889 | { |
890 | if ( ! lastSync.count() == 0 ) | 890 | if ( lastSync.count() == 0 ) { |
891 | //qDebug(" lastSync.count() == 0"); | ||
891 | return; | 892 | return; |
893 | } | ||
892 | if ( toDelete->type() == "Journal" ) | 894 | if ( toDelete->type() == "Journal" ) |
893 | return; | 895 | return; |
894 | 896 | ||
895 | Event* eve = lastSync.first(); | 897 | Event* eve = lastSync.first(); |
896 | 898 | ||
897 | while ( eve ) { | 899 | while ( eve ) { |
898 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 900 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
899 | if ( !id.isEmpty() ) { | 901 | if ( !id.isEmpty() ) { |
900 | QString des = eve->description(); | 902 | QString des = eve->description(); |
901 | QString pref = "e"; | 903 | QString pref = "e"; |
902 | if ( toDelete->type() == "Todo" ) | 904 | if ( toDelete->type() == "Todo" ) |
903 | pref = "t"; | 905 | pref = "t"; |
904 | des += pref+ id + ","; | 906 | des += pref+ id + ","; |
905 | eve->setReadOnly( false ); | 907 | eve->setReadOnly( false ); |
906 | eve->setDescription( des ); | 908 | eve->setDescription( des ); |
909 | //qDebug("setdes %s ", des.latin1()); | ||
907 | eve->setReadOnly( true ); | 910 | eve->setReadOnly( true ); |
908 | } | 911 | } |
909 | eve = lastSync.next(); | 912 | eve = lastSync.next(); |
910 | } | 913 | } |
911 | 914 | ||
912 | } | 915 | } |
913 | void CalendarView::checkExternalId( Incidence * inc ) | 916 | void CalendarView::checkExternalId( Incidence * inc ) |
914 | { | 917 | { |
915 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 918 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
916 | checkExternSyncEvent( lastSync, inc ); | 919 | checkExternSyncEvent( lastSync, inc ); |
917 | 920 | ||
918 | } | 921 | } |
919 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 922 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
920 | { | 923 | { |
921 | bool syncOK = true; | 924 | bool syncOK = true; |
922 | int addedEvent = 0; | 925 | int addedEvent = 0; |
923 | int addedEventR = 0; | 926 | int addedEventR = 0; |
924 | int deletedEventR = 0; | 927 | int deletedEventR = 0; |
925 | int deletedEventL = 0; | 928 | int deletedEventL = 0; |
926 | int changedLocal = 0; | 929 | int changedLocal = 0; |
927 | int changedRemote = 0; | 930 | int changedRemote = 0; |
928 | //QPtrList<Event> el = local->rawEvents(); | 931 | //QPtrList<Event> el = local->rawEvents(); |
929 | Event* eventR; | 932 | Event* eventR; |
930 | QString uid; | 933 | QString uid; |
931 | int take; | 934 | int take; |
932 | Event* eventL; | 935 | Event* eventL; |
933 | Event* eventRSync; | 936 | Event* eventRSync; |
934 | Event* eventLSync; | 937 | Event* eventLSync; |
935 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 938 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
936 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 939 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
937 | bool fullDateRange = false; | 940 | bool fullDateRange = false; |
938 | mLastCalendarSync = QDateTime::currentDateTime(); | 941 | mLastCalendarSync = QDateTime::currentDateTime(); |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 942 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 943 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
941 | if ( eventR ) { | 944 | if ( eventR ) { |
942 | eventRSync = (Event*) eventR->clone(); | 945 | eventRSync = (Event*) eventR->clone(); |
943 | remote->deleteEvent(eventR ); | 946 | remote->deleteEvent(eventR ); |
944 | 947 | ||
945 | } else { | 948 | } else { |
946 | fullDateRange = true; | 949 | fullDateRange = true; |
947 | eventRSync = new Event(); | 950 | eventRSync = new Event(); |
948 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
949 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
950 | eventRSync->setDtStart( mLastCalendarSync ); | 953 | eventRSync->setDtStart( mLastCalendarSync ); |
951 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
952 | eventRSync->setCategories( i18n("SyncEvent") ); | 955 | eventRSync->setCategories( i18n("SyncEvent") ); |
953 | } | 956 | } |
954 | eventLSync = getLastSyncEvent(); | 957 | eventLSync = getLastSyncEvent(); |
955 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 958 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
956 | fullDateRange = true; | 959 | fullDateRange = true; |
957 | 960 | ||
958 | if ( ! fullDateRange ) { | 961 | if ( ! fullDateRange ) { |
959 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
960 | 963 | ||
961 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
962 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
963 | fullDateRange = true; | 966 | fullDateRange = true; |
964 | } | 967 | } |
965 | } | 968 | } |
966 | if ( fullDateRange ) | 969 | if ( fullDateRange ) |
967 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
968 | else | 971 | else |
969 | mLastCalendarSync = eventLSync->dtStart(); | 972 | mLastCalendarSync = eventLSync->dtStart(); |
970 | // for resyncing if own file has changed | 973 | // for resyncing if own file has changed |
971 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
972 | mLastCalendarSync = loadedFileVersion; | 975 | mLastCalendarSync = loadedFileVersion; |
973 | qDebug("setting mLastCalendarSync "); | 976 | qDebug("setting mLastCalendarSync "); |
974 | } | 977 | } |
975 | //qDebug("*************************** "); | 978 | //qDebug("*************************** "); |
976 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
977 | QPtrList<Incidence> er = remote->rawIncidences(); | 980 | QPtrList<Incidence> er = remote->rawIncidences(); |
978 | Incidence* inR = er.first(); | 981 | Incidence* inR = er.first(); |
979 | Incidence* inL; | 982 | Incidence* inL; |
980 | QProgressBar bar( er.count(),0 ); | 983 | QProgressBar bar( er.count(),0 ); |
981 | bar.setCaption (i18n("Syncing - close to abort!") ); | 984 | bar.setCaption (i18n("Syncing - close to abort!") ); |
982 | 985 | ||
983 | int w = 300; | 986 | int w = 300; |
984 | if ( QApplication::desktop()->width() < 320 ) | 987 | if ( QApplication::desktop()->width() < 320 ) |
985 | w = 220; | 988 | w = 220; |
986 | int h = bar.sizeHint().height() ; | 989 | int h = bar.sizeHint().height() ; |
987 | int dw = QApplication::desktop()->width(); | 990 | int dw = QApplication::desktop()->width(); |
988 | int dh = QApplication::desktop()->height(); | 991 | int dh = QApplication::desktop()->height(); |
989 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
990 | bar.show(); | 993 | bar.show(); |
991 | int modulo = (er.count()/10)+1; | 994 | int modulo = (er.count()/10)+1; |
992 | int incCounter = 0; | 995 | int incCounter = 0; |
993 | while ( inR ) { | 996 | while ( inR ) { |
994 | if ( ! bar.isVisible() ) | 997 | if ( ! bar.isVisible() ) |
995 | return false; | 998 | return false; |
996 | if ( incCounter % modulo == 0 ) | 999 | if ( incCounter % modulo == 0 ) |
997 | bar.setProgress( incCounter ); | 1000 | bar.setProgress( incCounter ); |
998 | ++incCounter; | 1001 | ++incCounter; |
999 | uid = inR->uid(); | 1002 | uid = inR->uid(); |
1000 | bool skipIncidence = false; | 1003 | bool skipIncidence = false; |
1001 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1004 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1002 | skipIncidence = true; | 1005 | skipIncidence = true; |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index ebfe164..4e54fdf 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -265,193 +265,193 @@ class SharpParser : public QObject | |||
265 | oldCategories = c; | 265 | oldCategories = c; |
266 | } | 266 | } |
267 | 267 | ||
268 | QDateTime fromString ( QString s, bool useTz = true ) { | 268 | QDateTime fromString ( QString s, bool useTz = true ) { |
269 | QDateTime dt; | 269 | QDateTime dt; |
270 | int y,m,t,h,min,sec; | 270 | int y,m,t,h,min,sec; |
271 | y = s.mid(0,4).toInt(); | 271 | y = s.mid(0,4).toInt(); |
272 | m = s.mid(4,2).toInt(); | 272 | m = s.mid(4,2).toInt(); |
273 | t = s.mid(6,2).toInt(); | 273 | t = s.mid(6,2).toInt(); |
274 | h = s.mid(9,2).toInt(); | 274 | h = s.mid(9,2).toInt(); |
275 | min = s.mid(11,2).toInt(); | 275 | min = s.mid(11,2).toInt(); |
276 | sec = s.mid(13,2).toInt(); | 276 | sec = s.mid(13,2).toInt(); |
277 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 277 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
278 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 278 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
279 | if ( useTz ) | 279 | if ( useTz ) |
280 | dt = dt.addSecs ( offset*60); | 280 | dt = dt.addSecs ( offset*60); |
281 | return dt; | 281 | return dt; |
282 | 282 | ||
283 | } | 283 | } |
284 | protected: | 284 | protected: |
285 | QDateTime toDateTime( const QString &value ) | 285 | QDateTime toDateTime( const QString &value ) |
286 | { | 286 | { |
287 | QDateTime dt; | 287 | QDateTime dt; |
288 | dt.setTime_t( value.toUInt() ); | 288 | dt.setTime_t( value.toUInt() ); |
289 | 289 | ||
290 | return dt; | 290 | return dt; |
291 | } | 291 | } |
292 | 292 | ||
293 | QStringList lookupCategories( const QString &categoryList ) | 293 | QStringList lookupCategories( const QString &categoryList ) |
294 | { | 294 | { |
295 | QStringList categoryIds = QStringList::split( ";", categoryList ); | 295 | QStringList categoryIds = QStringList::split( ";", categoryList ); |
296 | QStringList categories; | 296 | QStringList categories; |
297 | QStringList::ConstIterator it; | 297 | QStringList::ConstIterator it; |
298 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | 298 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { |
299 | QString cate = category( *it ); | 299 | QString cate = category( *it ); |
300 | if ( oldCategories ) { | 300 | if ( oldCategories ) { |
301 | if ( ! oldCategories->contains( cate ) ) | 301 | if ( ! oldCategories->contains( cate ) ) |
302 | oldCategories->append( cate ); | 302 | oldCategories->append( cate ); |
303 | } | 303 | } |
304 | categories.append(cate ); | 304 | categories.append(cate ); |
305 | } | 305 | } |
306 | return categories; | 306 | return categories; |
307 | } | 307 | } |
308 | 308 | ||
309 | private: | 309 | private: |
310 | Calendar *mCalendar; | 310 | Calendar *mCalendar; |
311 | QStringList * oldCategories; | 311 | QStringList * oldCategories; |
312 | static QString category( const QString &id ) | 312 | static QString category( const QString &id ) |
313 | { | 313 | { |
314 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | 314 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); |
315 | if ( it == mCategoriesMap.end() ) return id; | 315 | if ( it == mCategoriesMap.end() ) return id; |
316 | else return *it; | 316 | else return *it; |
317 | } | 317 | } |
318 | 318 | ||
319 | static void setCategory( const QString &id, const QString &name ) | 319 | static void setCategory( const QString &id, const QString &name ) |
320 | { | 320 | { |
321 | mCategoriesMap.insert( id, name ); | 321 | mCategoriesMap.insert( id, name ); |
322 | } | 322 | } |
323 | 323 | ||
324 | static QMap<QString,QString> mCategoriesMap; | 324 | static QMap<QString,QString> mCategoriesMap; |
325 | }; | 325 | }; |
326 | 326 | ||
327 | QMap<QString,QString> SharpParser::mCategoriesMap; | 327 | QMap<QString,QString> SharpParser::mCategoriesMap; |
328 | 328 | ||
329 | SharpFormat::SharpFormat() | 329 | SharpFormat::SharpFormat() |
330 | { | 330 | { |
331 | mCategories = 0; | 331 | mCategories = 0; |
332 | } | 332 | } |
333 | 333 | ||
334 | SharpFormat::~SharpFormat() | 334 | SharpFormat::~SharpFormat() |
335 | { | 335 | { |
336 | } | 336 | } |
337 | ulong SharpFormat::getCsum( const QStringList & attList) | 337 | ulong SharpFormat::getCsum( const QStringList & attList) |
338 | { | 338 | { |
339 | int max = attList.count() -1; | 339 | int max = attList.count() -1; |
340 | ulong cSum = 0; | 340 | ulong cSum = 0; |
341 | int j,k,i; | 341 | int j,k,i; |
342 | int add; | 342 | int add; |
343 | for ( i = 1; i < max ; ++i ) { | 343 | for ( i = 1; i < max ; ++i ) { |
344 | QString s = attList[i]; | 344 | QString s = attList[i]; |
345 | if ( ! s.isEmpty() ){ | 345 | if ( ! s.isEmpty() ){ |
346 | j = s.length(); | 346 | j = s.length(); |
347 | for ( k = 0; k < j; ++k ) { | 347 | for ( k = 0; k < j; ++k ) { |
348 | int mul = k +1; | 348 | int mul = k +1; |
349 | add = s[k].unicode (); | 349 | add = s[k].unicode (); |
350 | if ( k < 16 ) | 350 | if ( k < 16 ) |
351 | mul = mul * mul; | 351 | mul = mul * mul; |
352 | add = add * mul *i*i*i; | 352 | add = add * mul *i*i*i; |
353 | cSum += add; | 353 | cSum += add; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } | 356 | } |
357 | return cSum; | 357 | return cSum; |
358 | 358 | ||
359 | } | 359 | } |
360 | #include <stdlib.h> | 360 | #include <stdlib.h> |
361 | #define DEBUGMODE true | 361 | #define DEBUGMODE false |
362 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 362 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
363 | { | 363 | { |
364 | 364 | ||
365 | 365 | ||
366 | bool debug = DEBUGMODE; | 366 | bool debug = DEBUGMODE; |
367 | //debug = true; | 367 | //debug = true; |
368 | QString text; | 368 | QString text; |
369 | QString codec = "utf8"; | 369 | QString codec = "utf8"; |
370 | QLabel status ( i18n("Reading events ..."), 0 ); | 370 | QLabel status ( i18n("Reading events ..."), 0 ); |
371 | 371 | ||
372 | int w = status.sizeHint().width()+20 ; | 372 | int w = status.sizeHint().width()+20 ; |
373 | if ( w < 200 ) w = 200; | 373 | if ( w < 200 ) w = 200; |
374 | int h = status.sizeHint().height()+20 ; | 374 | int h = status.sizeHint().height()+20 ; |
375 | int dw = QApplication::desktop()->width(); | 375 | int dw = QApplication::desktop()->width(); |
376 | int dh = QApplication::desktop()->height(); | 376 | int dh = QApplication::desktop()->height(); |
377 | status.setCaption(i18n("Reading DTM Data") ); | 377 | status.setCaption(i18n("Reading DTM Data") ); |
378 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 378 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
379 | status.show(); | 379 | status.show(); |
380 | status.raise(); | 380 | status.raise(); |
381 | qApp->processEvents(); | 381 | qApp->processEvents(); |
382 | QString fileName; | 382 | QString fileName; |
383 | if ( ! debug ) { | 383 | if ( ! debug ) { |
384 | fileName = "/tmp/kopitempout"; | 384 | fileName = "/tmp/kopitempout"; |
385 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 385 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
386 | system ( command.latin1() ); | 386 | system ( command.latin1() ); |
387 | } else { | 387 | } else { |
388 | fileName = "/tmp/events.txt"; | 388 | fileName = "/tmp/events.txt"; |
389 | 389 | ||
390 | } | 390 | } |
391 | QFile file( fileName ); | 391 | QFile file( fileName ); |
392 | if (!file.open( IO_ReadOnly ) ) { | 392 | if (!file.open( IO_ReadOnly ) ) { |
393 | return false; | 393 | return false; |
394 | 394 | ||
395 | } | 395 | } |
396 | QTextStream ts( &file ); | 396 | QTextStream ts( &file ); |
397 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 397 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
398 | text = ts.read(); | 398 | text = ts.read(); |
399 | file.close(); | 399 | file.close(); |
400 | status.setText( i18n("Processing events ...") ); | 400 | status.setText( i18n("Processing events ...") ); |
401 | status.raise(); | 401 | status.raise(); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | fromString2Cal( calendar, existngCal, text, "Event" ); | 403 | fromString2Cal( calendar, existngCal, text, "Event" ); |
404 | status.setText( i18n("Reading todos ...") ); | 404 | status.setText( i18n("Reading todos ...") ); |
405 | qApp->processEvents(); | 405 | qApp->processEvents(); |
406 | if ( ! debug ) { | 406 | if ( ! debug ) { |
407 | fileName = "/tmp/kopitempout"; | 407 | fileName = "/tmp/kopitempout"; |
408 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 408 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
409 | system ( command.latin1() ); | 409 | system ( command.latin1() ); |
410 | } else { | 410 | } else { |
411 | fileName = "/tmp/todo.txt"; | 411 | fileName = "/tmp/todo.txt"; |
412 | } | 412 | } |
413 | file.setName( fileName ); | 413 | file.setName( fileName ); |
414 | if (!file.open( IO_ReadOnly ) ) { | 414 | if (!file.open( IO_ReadOnly ) ) { |
415 | return false; | 415 | return false; |
416 | 416 | ||
417 | } | 417 | } |
418 | ts.setDevice( &file ); | 418 | ts.setDevice( &file ); |
419 | text = ts.read(); | 419 | text = ts.read(); |
420 | file.close(); | 420 | file.close(); |
421 | 421 | ||
422 | status.setText( i18n("Processing todos ...") ); | 422 | status.setText( i18n("Processing todos ...") ); |
423 | status.raise(); | 423 | status.raise(); |
424 | qApp->processEvents(); | 424 | qApp->processEvents(); |
425 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 425 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
426 | return true; | 426 | return true; |
427 | } | 427 | } |
428 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 428 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
429 | { | 429 | { |
430 | int retval = -1; | 430 | int retval = -1; |
431 | QStringList templist; | 431 | QStringList templist; |
432 | QString tempString; | 432 | QString tempString; |
433 | int start = 0; | 433 | int start = 0; |
434 | int len = answer.length(); | 434 | int len = answer.length(); |
435 | int end = answer.find ("\n",start)+1; | 435 | int end = answer.find ("\n",start)+1; |
436 | bool ok = true; | 436 | bool ok = true; |
437 | start = end; | 437 | start = end; |
438 | int ccc = 0; | 438 | int ccc = 0; |
439 | while ( start > 0 ) { | 439 | while ( start > 0 ) { |
440 | templist.clear(); | 440 | templist.clear(); |
441 | ok = true; | 441 | ok = true; |
442 | int loopCount = 0; | 442 | int loopCount = 0; |
443 | while ( ok ) { | 443 | while ( ok ) { |
444 | ++loopCount; | 444 | ++loopCount; |
445 | if ( loopCount > 25 ) { | 445 | if ( loopCount > 25 ) { |
446 | qDebug("KO: Error in while loop"); | 446 | qDebug("KO: Error in while loop"); |
447 | ok = false; | 447 | ok = false; |
448 | start = 0; | 448 | start = 0; |
449 | break; | 449 | break; |
450 | } | 450 | } |
451 | if ( ok ) | 451 | if ( ok ) |
452 | tempString = getPart( answer, ok, start ); | 452 | tempString = getPart( answer, ok, start ); |
453 | if ( start >= len || start == 0 ) { | 453 | if ( start >= len || start == 0 ) { |
454 | start = 0; | 454 | start = 0; |
455 | ok = false; | 455 | ok = false; |
456 | } | 456 | } |
457 | if ( tempString.right(1) =="\n" ) | 457 | if ( tempString.right(1) =="\n" ) |