author | ulf69 <ulf69> | 2004-07-09 08:02:25 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-09 08:02:25 (UTC) |
commit | d91c533ffc42d7bf48fa1326754894b2c30b6831 (patch) (unidiff) | |
tree | ba1eada897522030f17ccdf1afd4d4d96a65464e | |
parent | 82dabc14cc446fb8c0486cd4c32064e3866d2be9 (diff) | |
download | kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.zip kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.gz kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.bz2 |
changed the IntDateFormat from type int to enum, for easier categorization
-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 10 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 39 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 14 |
6 files changed, 33 insertions, 39 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index d8c1aca..5e42640 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp | |||
@@ -1,122 +1,121 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | 30 | ||
31 | #include "addresseeeditorwidget.h" | 31 | #include "addresseeeditorwidget.h" |
32 | #include "kabcore.h" | 32 | #include "kabcore.h" |
33 | 33 | ||
34 | #include "addresseeeditordialog.h" | 34 | #include "addresseeeditordialog.h" |
35 | 35 | ||
36 | AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, | 36 | AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, |
37 | const char *name ) | 37 | const char *name ) |
38 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), | 38 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), |
39 | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, | 39 | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, |
40 | KDialogBase::Ok, parent, name, true ) | 40 | KDialogBase::Ok, parent, name, true ) |
41 | { | 41 | { |
42 | 42 | ||
43 | 43 | ||
44 | QWidget *page = plainPage(); | 44 | QWidget *page = plainPage(); |
45 | 45 | ||
46 | QVBoxLayout *layout = new QVBoxLayout( page ); | 46 | QVBoxLayout *layout = new QVBoxLayout( page ); |
47 | 47 | ||
48 | mEditorWidget = new AddresseeEditorWidget( core, false, page ); | 48 | mEditorWidget = new AddresseeEditorWidget( core, false, page ); |
49 | connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), | 49 | connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), |
50 | SLOT( widgetModified() ) ); | 50 | SLOT( widgetModified() ) ); |
51 | layout->addWidget( mEditorWidget ); | 51 | layout->addWidget( mEditorWidget ); |
52 | 52 | ||
53 | enableButton( KDialogBase::Apply, false ); | 53 | enableButton( KDialogBase::Apply, false ); |
54 | if ( QApplication::desktop()->width() < 480 ) { | 54 | if ( QApplication::desktop()->width() < 480 ) { |
55 | hideButtons(); | 55 | hideButtons(); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | AddresseeEditorDialog::~AddresseeEditorDialog() | 59 | AddresseeEditorDialog::~AddresseeEditorDialog() |
60 | { | 60 | { |
61 | qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()"); | ||
62 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); | 61 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); |
63 | } | 62 | } |
64 | 63 | ||
65 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) | 64 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) |
66 | { | 65 | { |
67 | enableButton( KDialogBase::Apply, false ); | 66 | enableButton( KDialogBase::Apply, false ); |
68 | 67 | ||
69 | mEditorWidget->setAddressee( addr ); | 68 | mEditorWidget->setAddressee( addr ); |
70 | } | 69 | } |
71 | 70 | ||
72 | KABC::Addressee AddresseeEditorDialog::addressee() | 71 | KABC::Addressee AddresseeEditorDialog::addressee() |
73 | { | 72 | { |
74 | return mEditorWidget->addressee(); | 73 | return mEditorWidget->addressee(); |
75 | } | 74 | } |
76 | 75 | ||
77 | bool AddresseeEditorDialog::dirty() | 76 | bool AddresseeEditorDialog::dirty() |
78 | { | 77 | { |
79 | return mEditorWidget->dirty(); | 78 | return mEditorWidget->dirty(); |
80 | } | 79 | } |
81 | 80 | ||
82 | void AddresseeEditorDialog::slotApply() | 81 | void AddresseeEditorDialog::slotApply() |
83 | { | 82 | { |
84 | if ( mEditorWidget->dirty() ) { | 83 | if ( mEditorWidget->dirty() ) { |
85 | mEditorWidget->save(); | 84 | mEditorWidget->save(); |
86 | emit contactModified( mEditorWidget->addressee() ); | 85 | emit contactModified( mEditorWidget->addressee() ); |
87 | } | 86 | } |
88 | 87 | ||
89 | enableButton( KDialogBase::Apply, false ); | 88 | enableButton( KDialogBase::Apply, false ); |
90 | 89 | ||
91 | KDialogBase::slotApply(); | 90 | KDialogBase::slotApply(); |
92 | } | 91 | } |
93 | 92 | ||
94 | void AddresseeEditorDialog:: accept () | 93 | void AddresseeEditorDialog:: accept () |
95 | { | 94 | { |
96 | slotOk(); | 95 | slotOk(); |
97 | 96 | ||
98 | } | 97 | } |
99 | void AddresseeEditorDialog::slotOk() | 98 | void AddresseeEditorDialog::slotOk() |
100 | { | 99 | { |
101 | slotApply(); | 100 | slotApply(); |
102 | 101 | ||
103 | //KDialogBase::slotOk(); | 102 | //KDialogBase::slotOk(); |
104 | emit okClicked(); | 103 | emit okClicked(); |
105 | QDialog::accept(); | 104 | QDialog::accept(); |
106 | } | 105 | } |
107 | 106 | ||
108 | void AddresseeEditorDialog::widgetModified() | 107 | void AddresseeEditorDialog::widgetModified() |
109 | { | 108 | { |
110 | enableButton( KDialogBase::Apply, true ); | 109 | enableButton( KDialogBase::Apply, true ); |
111 | } | 110 | } |
112 | 111 | ||
113 | void AddresseeEditorDialog::slotCancel() | 112 | void AddresseeEditorDialog::slotCancel() |
114 | { | 113 | { |
115 | KDialogBase::slotCancel(); | 114 | KDialogBase::slotCancel(); |
116 | 115 | ||
117 | 116 | ||
118 | } | 117 | } |
119 | 118 | ||
120 | #ifndef KAB_EMBEDDED | 119 | #ifndef KAB_EMBEDDED |
121 | #include "addresseeeditordialog.moc" | 120 | #include "addresseeeditordialog.moc" |
122 | #endif //KAB_EMBEDDED | 121 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 4365ee5..3cfc1f2 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp | |||
@@ -684,601 +684,597 @@ void AddresseeEditorWidget::setupTab2() | |||
684 | #else //KAB_EMBEDDED | 684 | #else //KAB_EMBEDDED |
685 | mNoteEdit = new QMultiLineEdit( tab2 ); | 685 | mNoteEdit = new QMultiLineEdit( tab2 ); |
686 | //US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 686 | //US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
687 | //US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 687 | //US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
688 | qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); | 688 | qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); |
689 | #endif //KAB_EMBEDDED | 689 | #endif //KAB_EMBEDDED |
690 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); | 690 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); |
691 | label->setBuddy( mNoteEdit ); | 691 | label->setBuddy( mNoteEdit ); |
692 | layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); | 692 | layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); |
693 | */ | 693 | */ |
694 | // Build the layout and add to the tab widget | 694 | // Build the layout and add to the tab widget |
695 | layout->activate(); // required | 695 | layout->activate(); // required |
696 | 696 | ||
697 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); | 697 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); |
698 | } | 698 | } |
699 | 699 | ||
700 | void AddresseeEditorWidget::setupTab2_1() | 700 | void AddresseeEditorWidget::setupTab2_1() |
701 | { | 701 | { |
702 | // This is the Details tab | 702 | // This is the Details tab |
703 | QWidget *tab2_2 = new QWidget( mTabWidget ); | 703 | QWidget *tab2_2 = new QWidget( mTabWidget ); |
704 | 704 | ||
705 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); | 705 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); |
706 | layout->setMargin( KDialogBase::marginHintSmall() ); | 706 | layout->setMargin( KDialogBase::marginHintSmall() ); |
707 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 707 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
708 | 708 | ||
709 | QLabel *label; | 709 | QLabel *label; |
710 | KSeparator* bar; | 710 | KSeparator* bar; |
711 | 711 | ||
712 | /*US | 712 | /*US |
713 | /////////////////////// | 713 | /////////////////////// |
714 | // Office info | 714 | // Office info |
715 | 715 | ||
716 | // Department | 716 | // Department |
717 | label = new QLabel( tab2 ); | 717 | label = new QLabel( tab2 ); |
718 | //US loadIcon call is ambiguous. Add one more parameter | 718 | //US loadIcon call is ambiguous. Add one more parameter |
719 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); | 719 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); |
720 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); | 720 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); |
721 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 721 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
722 | 722 | ||
723 | label = new QLabel( i18n( "Department:" ), tab2 ); | 723 | label = new QLabel( i18n( "Department:" ), tab2 ); |
724 | layout->addWidget( label, 0, 1 ); | 724 | layout->addWidget( label, 0, 1 ); |
725 | mDepartmentEdit = new KLineEdit( tab2 ); | 725 | mDepartmentEdit = new KLineEdit( tab2 ); |
726 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), | 726 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), |
727 | SLOT( textChanged( const QString& ) ) ); | 727 | SLOT( textChanged( const QString& ) ) ); |
728 | label->setBuddy( mDepartmentEdit ); | 728 | label->setBuddy( mDepartmentEdit ); |
729 | layout->addWidget( mDepartmentEdit, 0, 2 ); | 729 | layout->addWidget( mDepartmentEdit, 0, 2 ); |
730 | 730 | ||
731 | label = new QLabel( i18n( "Office:" ), tab2 ); | 731 | label = new QLabel( i18n( "Office:" ), tab2 ); |
732 | layout->addWidget( label, 1, 1 ); | 732 | layout->addWidget( label, 1, 1 ); |
733 | mOfficeEdit = new KLineEdit( tab2 ); | 733 | mOfficeEdit = new KLineEdit( tab2 ); |
734 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), | 734 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), |
735 | SLOT( textChanged( const QString& ) ) ); | 735 | SLOT( textChanged( const QString& ) ) ); |
736 | label->setBuddy( mOfficeEdit ); | 736 | label->setBuddy( mOfficeEdit ); |
737 | layout->addWidget( mOfficeEdit, 1, 2 ); | 737 | layout->addWidget( mOfficeEdit, 1, 2 ); |
738 | 738 | ||
739 | label = new QLabel( i18n( "Profession:" ), tab2 ); | 739 | label = new QLabel( i18n( "Profession:" ), tab2 ); |
740 | layout->addWidget( label, 2, 1 ); | 740 | layout->addWidget( label, 2, 1 ); |
741 | mProfessionEdit = new KLineEdit( tab2 ); | 741 | mProfessionEdit = new KLineEdit( tab2 ); |
742 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), | 742 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), |
743 | SLOT( textChanged( const QString& ) ) ); | 743 | SLOT( textChanged( const QString& ) ) ); |
744 | label->setBuddy( mProfessionEdit ); | 744 | label->setBuddy( mProfessionEdit ); |
745 | layout->addWidget( mProfessionEdit, 2, 2 ); | 745 | layout->addWidget( mProfessionEdit, 2, 2 ); |
746 | 746 | ||
747 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); | 747 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); |
748 | layout->addWidget( label, 0, 3 ); | 748 | layout->addWidget( label, 0, 3 ); |
749 | mManagerEdit = new KLineEdit( tab2 ); | 749 | mManagerEdit = new KLineEdit( tab2 ); |
750 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), | 750 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), |
751 | SLOT( textChanged( const QString& ) ) ); | 751 | SLOT( textChanged( const QString& ) ) ); |
752 | label->setBuddy( mManagerEdit ); | 752 | label->setBuddy( mManagerEdit ); |
753 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); | 753 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); |
754 | 754 | ||
755 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); | 755 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); |
756 | layout->addWidget( label, 1, 3 ); | 756 | layout->addWidget( label, 1, 3 ); |
757 | mAssistantEdit = new KLineEdit( tab2 ); | 757 | mAssistantEdit = new KLineEdit( tab2 ); |
758 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), | 758 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), |
759 | SLOT( textChanged( const QString& ) ) ); | 759 | SLOT( textChanged( const QString& ) ) ); |
760 | label->setBuddy( mAssistantEdit ); | 760 | label->setBuddy( mAssistantEdit ); |
761 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); | 761 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); |
762 | 762 | ||
763 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 763 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
764 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); | 764 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); |
765 | 765 | ||
766 | ///////////////////////////////////////////////// | 766 | ///////////////////////////////////////////////// |
767 | // Personal info | 767 | // Personal info |
768 | 768 | ||
769 | label = new QLabel( tab2 ); | 769 | label = new QLabel( tab2 ); |
770 | //US loadIcon call is ambiguous. Add one more parameter | 770 | //US loadIcon call is ambiguous. Add one more parameter |
771 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 771 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
772 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 772 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
773 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); | 773 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); |
774 | 774 | ||
775 | label = new QLabel( i18n( "Nick name:" ), tab2 ); | 775 | label = new QLabel( i18n( "Nick name:" ), tab2 ); |
776 | layout->addWidget( label, 4, 1 ); | 776 | layout->addWidget( label, 4, 1 ); |
777 | mNicknameEdit = new KLineEdit( tab2 ); | 777 | mNicknameEdit = new KLineEdit( tab2 ); |
778 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 778 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
779 | SLOT( textChanged( const QString& ) ) ); | 779 | SLOT( textChanged( const QString& ) ) ); |
780 | label->setBuddy( mNicknameEdit ); | 780 | label->setBuddy( mNicknameEdit ); |
781 | layout->addWidget( mNicknameEdit, 4, 2 ); | 781 | layout->addWidget( mNicknameEdit, 4, 2 ); |
782 | 782 | ||
783 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); | 783 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); |
784 | layout->addWidget( label, 5, 1 ); | 784 | layout->addWidget( label, 5, 1 ); |
785 | mSpouseEdit = new KLineEdit( tab2 ); | 785 | mSpouseEdit = new KLineEdit( tab2 ); |
786 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 786 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
787 | SLOT( textChanged( const QString& ) ) ); | 787 | SLOT( textChanged( const QString& ) ) ); |
788 | label->setBuddy( mSpouseEdit ); | 788 | label->setBuddy( mSpouseEdit ); |
789 | layout->addWidget( mSpouseEdit, 5, 2 ); | 789 | layout->addWidget( mSpouseEdit, 5, 2 ); |
790 | 790 | ||
791 | label = new QLabel( i18n( "Birthday:" ), tab2 ); | 791 | label = new QLabel( i18n( "Birthday:" ), tab2 ); |
792 | layout->addWidget( label, 4, 3 ); | 792 | layout->addWidget( label, 4, 3 ); |
793 | mBirthdayPicker = new KDateEdit( tab2 ); | 793 | mBirthdayPicker = new KDateEdit( tab2 ); |
794 | mBirthdayPicker->setHandleInvalid( true ); | 794 | mBirthdayPicker->setHandleInvalid( true ); |
795 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 795 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
796 | SLOT( dateChanged( QDate ) ) ); | 796 | SLOT( dateChanged( QDate ) ) ); |
797 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), | 797 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), |
798 | SLOT( invalidDate() ) ); | 798 | SLOT( invalidDate() ) ); |
799 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), | 799 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), |
800 | SLOT( emitModified() ) ); | 800 | SLOT( emitModified() ) ); |
801 | label->setBuddy( mBirthdayPicker ); | 801 | label->setBuddy( mBirthdayPicker ); |
802 | layout->addWidget( mBirthdayPicker, 4, 4 ); | 802 | layout->addWidget( mBirthdayPicker, 4, 4 ); |
803 | 803 | ||
804 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); | 804 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); |
805 | layout->addWidget( label, 5, 3 ); | 805 | layout->addWidget( label, 5, 3 ); |
806 | mAnniversaryPicker = new KDateEdit( tab2 ); | 806 | mAnniversaryPicker = new KDateEdit( tab2 ); |
807 | mAnniversaryPicker->setHandleInvalid( true ); | 807 | mAnniversaryPicker->setHandleInvalid( true ); |
808 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 808 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
809 | SLOT( dateChanged( QDate ) ) ); | 809 | SLOT( dateChanged( QDate ) ) ); |
810 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), | 810 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), |
811 | SLOT( invalidDate() ) ); | 811 | SLOT( invalidDate() ) ); |
812 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), | 812 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), |
813 | SLOT( emitModified() ) ); | 813 | SLOT( emitModified() ) ); |
814 | label->setBuddy( mAnniversaryPicker ); | 814 | label->setBuddy( mAnniversaryPicker ); |
815 | layout->addWidget( mAnniversaryPicker, 5, 4 ); | 815 | layout->addWidget( mAnniversaryPicker, 5, 4 ); |
816 | 816 | ||
817 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 817 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
818 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); | 818 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); |
819 | */ | 819 | */ |
820 | ////////////////////////////////////// | 820 | ////////////////////////////////////// |
821 | // Notes | 821 | // Notes |
822 | label = new QLabel( i18n( "Note:" ), tab2_2 ); | 822 | label = new QLabel( i18n( "Note:" ), tab2_2 ); |
823 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); | 823 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); |
824 | //US layout->addWidget( label, 7, 0 ); | 824 | //US layout->addWidget( label, 7, 0 ); |
825 | layout->addWidget( label, 0, 0 ); | 825 | layout->addWidget( label, 0, 0 ); |
826 | #ifndef KAB_EMBEDDED | 826 | #ifndef KAB_EMBEDDED |
827 | mNoteEdit = new QTextEdit( tab2_2 ); | 827 | mNoteEdit = new QTextEdit( tab2_2 ); |
828 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 828 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
829 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 829 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
830 | #else //KAB_EMBEDDED | 830 | #else //KAB_EMBEDDED |
831 | mNoteEdit = new QMultiLineEdit( tab2_2 ); | 831 | mNoteEdit = new QMultiLineEdit( tab2_2 ); |
832 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); | 832 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); |
833 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 833 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
834 | #endif //KAB_EMBEDDED | 834 | #endif //KAB_EMBEDDED |
835 | 835 | ||
836 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); | 836 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); |
837 | label->setBuddy( mNoteEdit ); | 837 | label->setBuddy( mNoteEdit ); |
838 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); | 838 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); |
839 | layout->addWidget( mNoteEdit, 1, 0); | 839 | layout->addWidget( mNoteEdit, 1, 0); |
840 | 840 | ||
841 | // Build the layout and add to the tab widget | 841 | // Build the layout and add to the tab widget |
842 | layout->activate(); // required | 842 | layout->activate(); // required |
843 | 843 | ||
844 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); | 844 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); |
845 | } | 845 | } |
846 | 846 | ||
847 | 847 | ||
848 | 848 | ||
849 | void AddresseeEditorWidget::setupTab3() | 849 | void AddresseeEditorWidget::setupTab3() |
850 | { | 850 | { |
851 | // This is the Misc tab | 851 | // This is the Misc tab |
852 | QWidget *tab3 = new QWidget( mTabWidget ); | 852 | QWidget *tab3 = new QWidget( mTabWidget ); |
853 | 853 | ||
854 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 854 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
855 | layout->setMargin( KDialogBase::marginHintSmall() ); | 855 | layout->setMargin( KDialogBase::marginHintSmall() ); |
856 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 856 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
857 | //US layout->setColStretch( 2, 1 ); | 857 | //US layout->setColStretch( 2, 1 ); |
858 | 858 | ||
859 | ////////////////////////////////////// | 859 | ////////////////////////////////////// |
860 | // Geo | 860 | // Geo |
861 | mGeoWidget = new GeoWidget( tab3 ); | 861 | mGeoWidget = new GeoWidget( tab3 ); |
862 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 862 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
863 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 863 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
864 | layout->addWidget( mGeoWidget, 0, 0 ); | 864 | layout->addWidget( mGeoWidget, 0, 0 ); |
865 | /*US | 865 | /*US |
866 | ////////////////////////////////////// | 866 | ////////////////////////////////////// |
867 | // Sound | 867 | // Sound |
868 | #ifndef KAB_EMBEDDED | 868 | #ifndef KAB_EMBEDDED |
869 | mSoundWidget = new SoundWidget( tab3 ); | 869 | mSoundWidget = new SoundWidget( tab3 ); |
870 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 870 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
871 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 871 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
872 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 872 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
873 | #else //KAB_EMBEDDED | 873 | #else //KAB_EMBEDDED |
874 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 874 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
875 | #endif //KAB_EMBEDDED | 875 | #endif //KAB_EMBEDDED |
876 | 876 | ||
877 | ////////////////////////////////////// | 877 | ////////////////////////////////////// |
878 | // Images | 878 | // Images |
879 | mImageWidget = new ImageWidget( tab3 ); | 879 | mImageWidget = new ImageWidget( tab3 ); |
880 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 880 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
881 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 881 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
882 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); | 882 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); |
883 | */ | 883 | */ |
884 | //US | 884 | //US |
885 | /* | 885 | /* |
886 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); | 886 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); |
887 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); | 887 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); |
888 | */ | 888 | */ |
889 | ////////////////////////////////////// | 889 | ////////////////////////////////////// |
890 | // Keys | 890 | // Keys |
891 | mKeyWidget = new KeyWidget( tab3 ); | 891 | mKeyWidget = new KeyWidget( tab3 ); |
892 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 892 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
893 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 893 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
894 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 894 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
895 | layout->addWidget( mKeyWidget, 1, 0 ); | 895 | layout->addWidget( mKeyWidget, 1, 0 ); |
896 | 896 | ||
897 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); | 897 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); |
898 | } | 898 | } |
899 | 899 | ||
900 | void AddresseeEditorWidget::setupTab3_1() | 900 | void AddresseeEditorWidget::setupTab3_1() |
901 | { | 901 | { |
902 | // This is the Misc tab | 902 | // This is the Misc tab |
903 | QWidget *tab3 = new QWidget( mTabWidget ); | 903 | QWidget *tab3 = new QWidget( mTabWidget ); |
904 | 904 | ||
905 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); | 905 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); |
906 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 906 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
907 | layout->setMargin( KDialogBase::marginHint() ); | 907 | layout->setMargin( KDialogBase::marginHint() ); |
908 | layout->setSpacing( KDialogBase::spacingHint() ); | 908 | layout->setSpacing( KDialogBase::spacingHint() ); |
909 | //US layout->setColStretch( 2, 1 ); | 909 | //US layout->setColStretch( 2, 1 ); |
910 | 910 | ||
911 | /*US | 911 | /*US |
912 | ////////////////////////////////////// | 912 | ////////////////////////////////////// |
913 | // Geo | 913 | // Geo |
914 | mGeoWidget = new GeoWidget( tab3 ); | 914 | mGeoWidget = new GeoWidget( tab3 ); |
915 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 915 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
916 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 916 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
917 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); | 917 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); |
918 | */ | 918 | */ |
919 | ////////////////////////////////////// | 919 | ////////////////////////////////////// |
920 | // Sound | 920 | // Sound |
921 | #ifndef KAB_EMBEDDED | 921 | #ifndef KAB_EMBEDDED |
922 | mSoundWidget = new SoundWidget( tab3 ); | 922 | mSoundWidget = new SoundWidget( tab3 ); |
923 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 923 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
924 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 924 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
925 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 925 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
926 | #else //KAB_EMBEDDED | 926 | #else //KAB_EMBEDDED |
927 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 927 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
928 | #endif //KAB_EMBEDDED | 928 | #endif //KAB_EMBEDDED |
929 | 929 | ||
930 | ////////////////////////////////////// | 930 | ////////////////////////////////////// |
931 | // Images | 931 | // Images |
932 | mImageWidget = new ImageWidget( tab3 ); | 932 | mImageWidget = new ImageWidget( tab3 ); |
933 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 933 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
934 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 934 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
935 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); | 935 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); |
936 | /*US | 936 | /*US |
937 | ////////////////////////////////////// | 937 | ////////////////////////////////////// |
938 | // Keys | 938 | // Keys |
939 | mKeyWidget = new KeyWidget( tab3 ); | 939 | mKeyWidget = new KeyWidget( tab3 ); |
940 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 940 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
941 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 941 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
942 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 942 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
943 | */ | 943 | */ |
944 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); | 944 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); |
945 | } | 945 | } |
946 | 946 | ||
947 | 947 | ||
948 | void AddresseeEditorWidget::load() | 948 | void AddresseeEditorWidget::load() |
949 | { | 949 | { |
950 | kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; | 950 | kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; |
951 | 951 | ||
952 | // Block signals in case anything tries to emit modified | 952 | // Block signals in case anything tries to emit modified |
953 | // CS: This doesn't seem to work. | 953 | // CS: This doesn't seem to work. |
954 | bool block = signalsBlocked(); | 954 | bool block = signalsBlocked(); |
955 | blockSignals( true ); | 955 | blockSignals( true ); |
956 | mBlockSignals = true; // used for internal signal blocking | 956 | mBlockSignals = true; // used for internal signal blocking |
957 | 957 | ||
958 | mNameEdit->setText( mAddressee.assembledName() ); | 958 | mNameEdit->setText( mAddressee.assembledName() ); |
959 | 959 | ||
960 | if ( mAddressee.formattedName().isEmpty() ) { | 960 | if ( mAddressee.formattedName().isEmpty() ) { |
961 | //US KConfig config( "kaddressbookrc" ); | 961 | //US KConfig config( "kaddressbookrc" ); |
962 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 962 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
963 | config.setGroup( "General" ); | 963 | config.setGroup( "General" ); |
964 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); | 964 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); |
965 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 965 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
966 | } else { | 966 | } else { |
967 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) | 967 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) |
968 | mFormattedNameType = NameEditDialog::SimpleName; | 968 | mFormattedNameType = NameEditDialog::SimpleName; |
969 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) | 969 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) |
970 | mFormattedNameType = NameEditDialog::FullName; | 970 | mFormattedNameType = NameEditDialog::FullName; |
971 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) | 971 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) |
972 | mFormattedNameType = NameEditDialog::ReverseName; | 972 | mFormattedNameType = NameEditDialog::ReverseName; |
973 | else | 973 | else |
974 | mFormattedNameType = NameEditDialog::CustomName; | 974 | mFormattedNameType = NameEditDialog::CustomName; |
975 | } | 975 | } |
976 | 976 | ||
977 | mFormattedNameLabel->setText( mAddressee.formattedName() ); | 977 | mFormattedNameLabel->setText( mAddressee.formattedName() ); |
978 | 978 | ||
979 | mRoleEdit->setText( mAddressee.role() ); | 979 | mRoleEdit->setText( mAddressee.role() ); |
980 | mOrgEdit->setText( mAddressee.organization() ); | 980 | mOrgEdit->setText( mAddressee.organization() ); |
981 | 981 | ||
982 | //US mURLEdit->setURL( mAddressee.url().url() ); | 982 | //US mURLEdit->setURL( mAddressee.url().url() ); |
983 | mURLEdit->setText( mAddressee.url().prettyURL() ); | 983 | mURLEdit->setText( mAddressee.url().prettyURL() ); |
984 | //US?? mURLEdit->home( false ); | 984 | //US?? mURLEdit->home( false ); |
985 | 985 | ||
986 | // mNoteEdit->setText( mAddressee.note() ); | 986 | // mNoteEdit->setText( mAddressee.note() ); |
987 | mNoteEdit->setText( mAddressee.note() ); | 987 | mNoteEdit->setText( mAddressee.note() ); |
988 | mEmailWidget->setEmails( mAddressee.emails() ); | 988 | mEmailWidget->setEmails( mAddressee.emails() ); |
989 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); | 989 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); |
990 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); | 990 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); |
991 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); | 991 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); |
992 | 992 | ||
993 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( | 993 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( |
994 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); | 994 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); |
995 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | 995 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), |
996 | "%Y-%m-%d"); // = Qt::ISODate | 996 | "%Y-%m-%d"); // = Qt::ISODate |
997 | mAnniversaryPicker->setDate( dt ); | 997 | mAnniversaryPicker->setDate( dt ); |
998 | 998 | ||
999 | 999 | ||
1000 | mNicknameEdit->setText( mAddressee.nickName() ); | 1000 | mNicknameEdit->setText( mAddressee.nickName() ); |
1001 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); | 1001 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); |
1002 | 1002 | ||
1003 | mGeoWidget->setGeo( mAddressee.geo() ); | 1003 | mGeoWidget->setGeo( mAddressee.geo() ); |
1004 | mImageWidget->setPhoto( mAddressee.photo() ); | 1004 | mImageWidget->setPhoto( mAddressee.photo() ); |
1005 | mImageWidget->setLogo( mAddressee.logo() ); | 1005 | mImageWidget->setLogo( mAddressee.logo() ); |
1006 | mKeyWidget->setKeys( mAddressee.keys() ); | 1006 | mKeyWidget->setKeys( mAddressee.keys() ); |
1007 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); | 1007 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); |
1008 | #ifndef KAB_EMBEDDED | 1008 | #ifndef KAB_EMBEDDED |
1009 | mSoundWidget->setSound( mAddressee.sound() ); | 1009 | mSoundWidget->setSound( mAddressee.sound() ); |
1010 | #else //KAB_EMBEDDED | 1010 | #else //KAB_EMBEDDED |
1011 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); | 1011 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); |
1012 | #endif //KAB_EMBEDDED | 1012 | #endif //KAB_EMBEDDED |
1013 | 1013 | ||
1014 | // Load customs | 1014 | // Load customs |
1015 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); | 1015 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); |
1016 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); | 1016 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); |
1017 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); | 1017 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); |
1018 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); | 1018 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); |
1019 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); | 1019 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); |
1020 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); | 1020 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); |
1021 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); | 1021 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); |
1022 | 1022 | ||
1023 | blockSignals( block ); | 1023 | blockSignals( block ); |
1024 | mBlockSignals = false; | 1024 | mBlockSignals = false; |
1025 | 1025 | ||
1026 | mDirty = false; | 1026 | mDirty = false; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void AddresseeEditorWidget::save() | 1029 | void AddresseeEditorWidget::save() |
1030 | { | 1030 | { |
1031 | if ( !mDirty ) return; | 1031 | if ( !mDirty ) return; |
1032 | 1032 | ||
1033 | mAddressee.setRole( mRoleEdit->text() ); | 1033 | mAddressee.setRole( mRoleEdit->text() ); |
1034 | mAddressee.setOrganization( mOrgEdit->text() ); | 1034 | mAddressee.setOrganization( mOrgEdit->text() ); |
1035 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); | 1035 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); |
1036 | mAddressee.setNote( mNoteEdit->text() ); | 1036 | mAddressee.setNote( mNoteEdit->text() ); |
1037 | if ( mBirthdayPicker->inputIsValid() ) | 1037 | if ( mBirthdayPicker->inputIsValid() ) |
1038 | mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); | 1038 | mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); |
1039 | else | 1039 | else |
1040 | mAddressee.setBirthday( QDateTime() ); | 1040 | mAddressee.setBirthday( QDateTime() ); |
1041 | 1041 | ||
1042 | mAddressee.setNickName( mNicknameEdit->text() ); | 1042 | mAddressee.setNickName( mNicknameEdit->text() ); |
1043 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); | 1043 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); |
1044 | 1044 | ||
1045 | mAddressee.setGeo( mGeoWidget->geo() ); | 1045 | mAddressee.setGeo( mGeoWidget->geo() ); |
1046 | mAddressee.setPhoto( mImageWidget->photo() ); | 1046 | mAddressee.setPhoto( mImageWidget->photo() ); |
1047 | mAddressee.setLogo( mImageWidget->logo() ); | 1047 | mAddressee.setLogo( mImageWidget->logo() ); |
1048 | mAddressee.setKeys( mKeyWidget->keys() ); | 1048 | mAddressee.setKeys( mKeyWidget->keys() ); |
1049 | #ifndef KAB_EMBEDDED | 1049 | #ifndef KAB_EMBEDDED |
1050 | mAddressee.setSound( mSoundWidget->sound() ); | 1050 | mAddressee.setSound( mSoundWidget->sound() ); |
1051 | #else //KAB_EMBEDDED | 1051 | #else //KAB_EMBEDDED |
1052 | //US qDebug("AddresseeEditorWidget::save sound not supported"); | 1052 | //US qDebug("AddresseeEditorWidget::save sound not supported"); |
1053 | #endif //KAB_EMBEDDED | 1053 | #endif //KAB_EMBEDDED |
1054 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); | 1054 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); |
1055 | 1055 | ||
1056 | // save custom fields | 1056 | // save custom fields |
1057 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); | 1057 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); |
1058 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); | 1058 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); |
1059 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); | 1059 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); |
1060 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); | 1060 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); |
1061 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); | 1061 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); |
1062 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); | 1062 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); |
1063 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); | 1063 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); |
1064 | if ( mAnniversaryPicker->inputIsValid() ) { | 1064 | if ( mAnniversaryPicker->inputIsValid() ) { |
1065 | 1065 | ||
1066 | //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", | 1066 | //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", |
1067 | //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); | 1067 | //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); |
1068 | int orgformat = KGlobal::locale()->getIntDateFormat(); | 1068 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); |
1069 | QDate da = mAnniversaryPicker->date(); | ||
1070 | KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate | ||
1071 | QString dt = KGlobal::locale()->formatDate(da, true); | ||
1072 | KGlobal::locale()->setIntDateFormat(orgformat ); | ||
1073 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 1069 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
1074 | } | 1070 | } |
1075 | else | 1071 | else |
1076 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); | 1072 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); |
1077 | 1073 | ||
1078 | // Save the email addresses | 1074 | // Save the email addresses |
1079 | QStringList emails = mAddressee.emails(); | 1075 | QStringList emails = mAddressee.emails(); |
1080 | QStringList::Iterator iter; | 1076 | QStringList::Iterator iter; |
1081 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) | 1077 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) |
1082 | mAddressee.removeEmail( *iter ); | 1078 | mAddressee.removeEmail( *iter ); |
1083 | 1079 | ||
1084 | emails = mEmailWidget->emails(); | 1080 | emails = mEmailWidget->emails(); |
1085 | bool first = true; | 1081 | bool first = true; |
1086 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { | 1082 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { |
1087 | mAddressee.insertEmail( *iter, first ); | 1083 | mAddressee.insertEmail( *iter, first ); |
1088 | first = false; | 1084 | first = false; |
1089 | } | 1085 | } |
1090 | 1086 | ||
1091 | // Save the phone numbers | 1087 | // Save the phone numbers |
1092 | KABC::PhoneNumber::List phoneNumbers; | 1088 | KABC::PhoneNumber::List phoneNumbers; |
1093 | KABC::PhoneNumber::List::Iterator phoneIter; | 1089 | KABC::PhoneNumber::List::Iterator phoneIter; |
1094 | phoneNumbers = mAddressee.phoneNumbers(); | 1090 | phoneNumbers = mAddressee.phoneNumbers(); |
1095 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1091 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1096 | ++phoneIter ) | 1092 | ++phoneIter ) |
1097 | mAddressee.removePhoneNumber( *phoneIter ); | 1093 | mAddressee.removePhoneNumber( *phoneIter ); |
1098 | 1094 | ||
1099 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); | 1095 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); |
1100 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1096 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1101 | ++phoneIter ) | 1097 | ++phoneIter ) |
1102 | mAddressee.insertPhoneNumber( *phoneIter ); | 1098 | mAddressee.insertPhoneNumber( *phoneIter ); |
1103 | 1099 | ||
1104 | // Save the addresses | 1100 | // Save the addresses |
1105 | KABC::Address::List addresses; | 1101 | KABC::Address::List addresses; |
1106 | KABC::Address::List::Iterator addressIter; | 1102 | KABC::Address::List::Iterator addressIter; |
1107 | addresses = mAddressee.addresses(); | 1103 | addresses = mAddressee.addresses(); |
1108 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1104 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1109 | ++addressIter ) | 1105 | ++addressIter ) |
1110 | mAddressee.removeAddress( *addressIter ); | 1106 | mAddressee.removeAddress( *addressIter ); |
1111 | 1107 | ||
1112 | addresses = mAddressEditWidget->addresses(); | 1108 | addresses = mAddressEditWidget->addresses(); |
1113 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1109 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1114 | ++addressIter ) | 1110 | ++addressIter ) |
1115 | mAddressee.insertAddress( *addressIter ); | 1111 | mAddressee.insertAddress( *addressIter ); |
1116 | mDirty = false; | 1112 | mDirty = false; |
1117 | } | 1113 | } |
1118 | 1114 | ||
1119 | bool AddresseeEditorWidget::dirty() | 1115 | bool AddresseeEditorWidget::dirty() |
1120 | { | 1116 | { |
1121 | return mDirty; | 1117 | return mDirty; |
1122 | } | 1118 | } |
1123 | 1119 | ||
1124 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) | 1120 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) |
1125 | { | 1121 | { |
1126 | // use the addressee class to parse the name for us | 1122 | // use the addressee class to parse the name for us |
1127 | mAConfig->setUid( mAddressee.uid() ); | 1123 | mAConfig->setUid( mAddressee.uid() ); |
1128 | if ( mAConfig->automaticNameParsing() ) { | 1124 | if ( mAConfig->automaticNameParsing() ) { |
1129 | if ( !mAddressee.formattedName().isEmpty() ) { | 1125 | if ( !mAddressee.formattedName().isEmpty() ) { |
1130 | QString fn = mAddressee.formattedName(); | 1126 | QString fn = mAddressee.formattedName(); |
1131 | mAddressee.setNameFromString( text ); | 1127 | mAddressee.setNameFromString( text ); |
1132 | mAddressee.setFormattedName( fn ); | 1128 | mAddressee.setFormattedName( fn ); |
1133 | } else { | 1129 | } else { |
1134 | // use extra addressee to avoid a formatted name assignment | 1130 | // use extra addressee to avoid a formatted name assignment |
1135 | Addressee addr; | 1131 | Addressee addr; |
1136 | addr.setNameFromString( text ); | 1132 | addr.setNameFromString( text ); |
1137 | mAddressee.setPrefix( addr.prefix() ); | 1133 | mAddressee.setPrefix( addr.prefix() ); |
1138 | mAddressee.setGivenName( addr.givenName() ); | 1134 | mAddressee.setGivenName( addr.givenName() ); |
1139 | mAddressee.setAdditionalName( addr.additionalName() ); | 1135 | mAddressee.setAdditionalName( addr.additionalName() ); |
1140 | mAddressee.setFamilyName( addr.familyName() ); | 1136 | mAddressee.setFamilyName( addr.familyName() ); |
1141 | mAddressee.setSuffix( addr.suffix() ); | 1137 | mAddressee.setSuffix( addr.suffix() ); |
1142 | } | 1138 | } |
1143 | } | 1139 | } |
1144 | 1140 | ||
1145 | nameBoxChanged(); | 1141 | nameBoxChanged(); |
1146 | 1142 | ||
1147 | emitModified(); | 1143 | emitModified(); |
1148 | } | 1144 | } |
1149 | 1145 | ||
1150 | void AddresseeEditorWidget::nameBoxChanged() | 1146 | void AddresseeEditorWidget::nameBoxChanged() |
1151 | { | 1147 | { |
1152 | KABC::Addressee addr; | 1148 | KABC::Addressee addr; |
1153 | mAConfig->setUid( mAddressee.uid() ); | 1149 | mAConfig->setUid( mAddressee.uid() ); |
1154 | if ( mAConfig->automaticNameParsing() ) { | 1150 | if ( mAConfig->automaticNameParsing() ) { |
1155 | addr.setNameFromString( mNameEdit->text() ); | 1151 | addr.setNameFromString( mNameEdit->text() ); |
1156 | mNameLabel->hide(); | 1152 | mNameLabel->hide(); |
1157 | mNameEdit->show(); | 1153 | mNameEdit->show(); |
1158 | } else { | 1154 | } else { |
1159 | addr = mAddressee; | 1155 | addr = mAddressee; |
1160 | mNameEdit->hide(); | 1156 | mNameEdit->hide(); |
1161 | mNameLabel->setText( mNameEdit->text() ); | 1157 | mNameLabel->setText( mNameEdit->text() ); |
1162 | mNameLabel->show(); | 1158 | mNameLabel->show(); |
1163 | } | 1159 | } |
1164 | 1160 | ||
1165 | if ( mFormattedNameType != NameEditDialog::CustomName ) { | 1161 | if ( mFormattedNameType != NameEditDialog::CustomName ) { |
1166 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1162 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1167 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1163 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1168 | } | 1164 | } |
1169 | } | 1165 | } |
1170 | 1166 | ||
1171 | void AddresseeEditorWidget::nameButtonClicked() | 1167 | void AddresseeEditorWidget::nameButtonClicked() |
1172 | { | 1168 | { |
1173 | // show the name dialog. | 1169 | // show the name dialog. |
1174 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); | 1170 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); |
1175 | 1171 | ||
1176 | if ( dialog.exec() ) { | 1172 | if ( dialog.exec() ) { |
1177 | if ( dialog.changed() ) { | 1173 | if ( dialog.changed() ) { |
1178 | mAddressee.setFamilyName( dialog.familyName() ); | 1174 | mAddressee.setFamilyName( dialog.familyName() ); |
1179 | mAddressee.setGivenName( dialog.givenName() ); | 1175 | mAddressee.setGivenName( dialog.givenName() ); |
1180 | mAddressee.setPrefix( dialog.prefix() ); | 1176 | mAddressee.setPrefix( dialog.prefix() ); |
1181 | mAddressee.setSuffix( dialog.suffix() ); | 1177 | mAddressee.setSuffix( dialog.suffix() ); |
1182 | mAddressee.setAdditionalName( dialog.additionalName() ); | 1178 | mAddressee.setAdditionalName( dialog.additionalName() ); |
1183 | mFormattedNameType = dialog.formattedNameType(); | 1179 | mFormattedNameType = dialog.formattedNameType(); |
1184 | if ( mFormattedNameType == NameEditDialog::CustomName ) { | 1180 | if ( mFormattedNameType == NameEditDialog::CustomName ) { |
1185 | mFormattedNameLabel->setText( dialog.customFormattedName() ); | 1181 | mFormattedNameLabel->setText( dialog.customFormattedName() ); |
1186 | mAddressee.setFormattedName( dialog.customFormattedName() ); | 1182 | mAddressee.setFormattedName( dialog.customFormattedName() ); |
1187 | } | 1183 | } |
1188 | // Update the name edit. | 1184 | // Update the name edit. |
1189 | bool block = mNameEdit->signalsBlocked(); | 1185 | bool block = mNameEdit->signalsBlocked(); |
1190 | mNameEdit->blockSignals( true ); | 1186 | mNameEdit->blockSignals( true ); |
1191 | mNameEdit->setText( mAddressee.assembledName() ); | 1187 | mNameEdit->setText( mAddressee.assembledName() ); |
1192 | mNameEdit->blockSignals( block ); | 1188 | mNameEdit->blockSignals( block ); |
1193 | 1189 | ||
1194 | // Update the combo box. | 1190 | // Update the combo box. |
1195 | nameBoxChanged(); | 1191 | nameBoxChanged(); |
1196 | 1192 | ||
1197 | emitModified(); | 1193 | emitModified(); |
1198 | } | 1194 | } |
1199 | } | 1195 | } |
1200 | } | 1196 | } |
1201 | 1197 | ||
1202 | void AddresseeEditorWidget::categoryButtonClicked() | 1198 | void AddresseeEditorWidget::categoryButtonClicked() |
1203 | { | 1199 | { |
1204 | // Show the category dialog | 1200 | // Show the category dialog |
1205 | if ( mCategoryDialog == 0 ) { | 1201 | if ( mCategoryDialog == 0 ) { |
1206 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); | 1202 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); |
1207 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), | 1203 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), |
1208 | SLOT(categoriesSelected( const QStringList& ) ) ); | 1204 | SLOT(categoriesSelected( const QStringList& ) ) ); |
1209 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); | 1205 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); |
1210 | } | 1206 | } |
1211 | 1207 | ||
1212 | mCategoryDialog->setCategories(); | 1208 | mCategoryDialog->setCategories(); |
1213 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); | 1209 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); |
1214 | mCategoryDialog->show(); | 1210 | mCategoryDialog->show(); |
1215 | mCategoryDialog->raise(); | 1211 | mCategoryDialog->raise(); |
1216 | } | 1212 | } |
1217 | 1213 | ||
1218 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) | 1214 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) |
1219 | { | 1215 | { |
1220 | mCategoryEdit->setText( list.join( "," ) ); | 1216 | mCategoryEdit->setText( list.join( "," ) ); |
1221 | } | 1217 | } |
1222 | 1218 | ||
1223 | void AddresseeEditorWidget::editCategories() | 1219 | void AddresseeEditorWidget::editCategories() |
1224 | { | 1220 | { |
1225 | if ( mCategoryEditDialog == 0 ) { | 1221 | if ( mCategoryEditDialog == 0 ) { |
1226 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); | 1222 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); |
1227 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), | 1223 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), |
1228 | SLOT( categoryButtonClicked() ) ); | 1224 | SLOT( categoryButtonClicked() ) ); |
1229 | } | 1225 | } |
1230 | 1226 | ||
1231 | mCategoryEditDialog->show(); | 1227 | mCategoryEditDialog->show(); |
1232 | mCategoryEditDialog->raise(); | 1228 | mCategoryEditDialog->raise(); |
1233 | } | 1229 | } |
1234 | 1230 | ||
1235 | void AddresseeEditorWidget::emitModified() | 1231 | void AddresseeEditorWidget::emitModified() |
1236 | { | 1232 | { |
1237 | mDirty = true; | 1233 | mDirty = true; |
1238 | 1234 | ||
1239 | KABC::Addressee::List list; | 1235 | KABC::Addressee::List list; |
1240 | 1236 | ||
1241 | if ( mIsExtension && !mBlockSignals ) { | 1237 | if ( mIsExtension && !mBlockSignals ) { |
1242 | save(); | 1238 | save(); |
1243 | list.append( mAddressee ); | 1239 | list.append( mAddressee ); |
1244 | } | 1240 | } |
1245 | 1241 | ||
1246 | emit modified( list ); | 1242 | emit modified( list ); |
1247 | } | 1243 | } |
1248 | 1244 | ||
1249 | void AddresseeEditorWidget::dateChanged( QDate ) | 1245 | void AddresseeEditorWidget::dateChanged( QDate ) |
1250 | { | 1246 | { |
1251 | emitModified(); | 1247 | emitModified(); |
1252 | } | 1248 | } |
1253 | 1249 | ||
1254 | //US invalid dates are handdled by the KDateEdit widget itself | 1250 | //US invalid dates are handdled by the KDateEdit widget itself |
1255 | void AddresseeEditorWidget::invalidDate() | 1251 | void AddresseeEditorWidget::invalidDate() |
1256 | { | 1252 | { |
1257 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); | 1253 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); |
1258 | } | 1254 | } |
1259 | 1255 | ||
1260 | 1256 | ||
1261 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) | 1257 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) |
1262 | { | 1258 | { |
1263 | #ifndef KAB_EMBEDDED | 1259 | #ifndef KAB_EMBEDDED |
1264 | if ( wdg ) | 1260 | if ( wdg ) |
1265 | KAcceleratorManager::manage( wdg ); | 1261 | KAcceleratorManager::manage( wdg ); |
1266 | #else //KAB_EMBEDDED | 1262 | #else //KAB_EMBEDDED |
1267 | //US | 1263 | //US |
1268 | #endif //KAB_EMBEDDED | 1264 | #endif //KAB_EMBEDDED |
1269 | 1265 | ||
1270 | } | 1266 | } |
1271 | 1267 | ||
1272 | QString AddresseeEditorWidget::title() const | 1268 | QString AddresseeEditorWidget::title() const |
1273 | { | 1269 | { |
1274 | return i18n( "Contact Editor" ); | 1270 | return i18n( "Contact Editor" ); |
1275 | } | 1271 | } |
1276 | 1272 | ||
1277 | QString AddresseeEditorWidget::identifier() const | 1273 | QString AddresseeEditorWidget::identifier() const |
1278 | { | 1274 | { |
1279 | return i18n( "contact_editor" ); | 1275 | return i18n( "contact_editor" ); |
1280 | } | 1276 | } |
1281 | 1277 | ||
1282 | #ifndef KAB_EMBEDDED | 1278 | #ifndef KAB_EMBEDDED |
1283 | #include "addresseeeditorwidget.moc" | 1279 | #include "addresseeeditorwidget.moc" |
1284 | #endif //KAB_EMBEDDED | 1280 | #endif //KAB_EMBEDDED |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c3c3d47..58b3d70 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1395,769 +1395,769 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
1395 | return false; | 1395 | return false; |
1396 | } | 1396 | } |
1397 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1397 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1398 | { | 1398 | { |
1399 | loadedFileVersion = dt; | 1399 | loadedFileVersion = dt; |
1400 | } | 1400 | } |
1401 | bool CalendarView::checkFileChanged(QString fn) | 1401 | bool CalendarView::checkFileChanged(QString fn) |
1402 | { | 1402 | { |
1403 | QFileInfo finf ( fn ); | 1403 | QFileInfo finf ( fn ); |
1404 | if ( !finf.exists() ) | 1404 | if ( !finf.exists() ) |
1405 | return true; | 1405 | return true; |
1406 | QDateTime dt = finf.lastModified (); | 1406 | QDateTime dt = finf.lastModified (); |
1407 | if ( dt <= loadedFileVersion ) | 1407 | if ( dt <= loadedFileVersion ) |
1408 | return false; | 1408 | return false; |
1409 | return true; | 1409 | return true; |
1410 | 1410 | ||
1411 | } | 1411 | } |
1412 | bool CalendarView::checkFileVersion(QString fn) | 1412 | bool CalendarView::checkFileVersion(QString fn) |
1413 | { | 1413 | { |
1414 | QFileInfo finf ( fn ); | 1414 | QFileInfo finf ( fn ); |
1415 | if ( !finf.exists() ) | 1415 | if ( !finf.exists() ) |
1416 | return true; | 1416 | return true; |
1417 | QDateTime dt = finf.lastModified (); | 1417 | QDateTime dt = finf.lastModified (); |
1418 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1418 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1419 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1419 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1420 | if ( dt <= loadedFileVersion ) | 1420 | if ( dt <= loadedFileVersion ) |
1421 | return true; | 1421 | return true; |
1422 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1422 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1423 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1423 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1424 | i18n("Sync+save")); | 1424 | i18n("Sync+save")); |
1425 | 1425 | ||
1426 | if ( km == KMessageBox::Cancel ) | 1426 | if ( km == KMessageBox::Cancel ) |
1427 | return false; | 1427 | return false; |
1428 | if ( km == KMessageBox::Yes ) | 1428 | if ( km == KMessageBox::Yes ) |
1429 | return true; | 1429 | return true; |
1430 | 1430 | ||
1431 | setSyncDevice("deleteaftersync" ); | 1431 | setSyncDevice("deleteaftersync" ); |
1432 | KOPrefs::instance()->mAskForPreferences = true; | 1432 | KOPrefs::instance()->mAskForPreferences = true; |
1433 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1433 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1434 | KOPrefs::instance()->mWriteBackFile = false; | 1434 | KOPrefs::instance()->mWriteBackFile = false; |
1435 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1435 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1436 | KOPrefs::instance()->mShowSyncSummary = false; | 1436 | KOPrefs::instance()->mShowSyncSummary = false; |
1437 | syncCalendar( fn, 3 ); | 1437 | syncCalendar( fn, 3 ); |
1438 | Event * e = getLastSyncEvent(); | 1438 | Event * e = getLastSyncEvent(); |
1439 | mCalendar->deleteEvent ( e ); | 1439 | mCalendar->deleteEvent ( e ); |
1440 | updateView(); | 1440 | updateView(); |
1441 | return true; | 1441 | return true; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | bool CalendarView::saveCalendar( QString filename ) | 1444 | bool CalendarView::saveCalendar( QString filename ) |
1445 | { | 1445 | { |
1446 | 1446 | ||
1447 | // Store back all unsaved data into calendar object | 1447 | // Store back all unsaved data into calendar object |
1448 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1448 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1449 | if ( mViewManager->currentView() ) | 1449 | if ( mViewManager->currentView() ) |
1450 | mViewManager->currentView()->flushView(); | 1450 | mViewManager->currentView()->flushView(); |
1451 | 1451 | ||
1452 | //mStorage->setFileName( filename ); | 1452 | //mStorage->setFileName( filename ); |
1453 | 1453 | ||
1454 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1454 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1455 | mStorage->setFileName( filename ); | 1455 | mStorage->setFileName( filename ); |
1456 | bool success; | 1456 | bool success; |
1457 | success = mStorage->save(); | 1457 | success = mStorage->save(); |
1458 | if ( !success ) { | 1458 | if ( !success ) { |
1459 | return false; | 1459 | return false; |
1460 | } | 1460 | } |
1461 | 1461 | ||
1462 | return true; | 1462 | return true; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | void CalendarView::closeCalendar() | 1465 | void CalendarView::closeCalendar() |
1466 | { | 1466 | { |
1467 | 1467 | ||
1468 | // child windows no longer valid | 1468 | // child windows no longer valid |
1469 | emit closingDown(); | 1469 | emit closingDown(); |
1470 | 1470 | ||
1471 | mCalendar->close(); | 1471 | mCalendar->close(); |
1472 | setModified(false); | 1472 | setModified(false); |
1473 | updateView(); | 1473 | updateView(); |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | void CalendarView::archiveCalendar() | 1476 | void CalendarView::archiveCalendar() |
1477 | { | 1477 | { |
1478 | mDialogManager->showArchiveDialog(); | 1478 | mDialogManager->showArchiveDialog(); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | 1481 | ||
1482 | void CalendarView::readSettings() | 1482 | void CalendarView::readSettings() |
1483 | { | 1483 | { |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | // mViewManager->showAgendaView(); | 1486 | // mViewManager->showAgendaView(); |
1487 | QString str; | 1487 | QString str; |
1488 | //qDebug("CalendarView::readSettings() "); | 1488 | //qDebug("CalendarView::readSettings() "); |
1489 | // read settings from the KConfig, supplying reasonable | 1489 | // read settings from the KConfig, supplying reasonable |
1490 | // defaults where none are to be found | 1490 | // defaults where none are to be found |
1491 | KConfig *config = KOGlobals::config(); | 1491 | KConfig *config = KOGlobals::config(); |
1492 | #ifndef KORG_NOSPLITTER | 1492 | #ifndef KORG_NOSPLITTER |
1493 | config->setGroup("KOrganizer Geometry"); | 1493 | config->setGroup("KOrganizer Geometry"); |
1494 | 1494 | ||
1495 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1495 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1496 | if (sizes.count() != 2) { | 1496 | if (sizes.count() != 2) { |
1497 | sizes << mDateNavigator->minimumSizeHint().width(); | 1497 | sizes << mDateNavigator->minimumSizeHint().width(); |
1498 | sizes << 300; | 1498 | sizes << 300; |
1499 | } | 1499 | } |
1500 | mPanner->setSizes(sizes); | 1500 | mPanner->setSizes(sizes); |
1501 | 1501 | ||
1502 | sizes = config->readIntListEntry("Separator2"); | 1502 | sizes = config->readIntListEntry("Separator2"); |
1503 | if ( ( mResourceView && sizes.count() == 4 ) || | 1503 | if ( ( mResourceView && sizes.count() == 4 ) || |
1504 | ( !mResourceView && sizes.count() == 3 ) ) { | 1504 | ( !mResourceView && sizes.count() == 3 ) ) { |
1505 | mLeftSplitter->setSizes(sizes); | 1505 | mLeftSplitter->setSizes(sizes); |
1506 | } | 1506 | } |
1507 | #endif | 1507 | #endif |
1508 | globalFlagBlockAgenda = 1; | 1508 | globalFlagBlockAgenda = 1; |
1509 | mViewManager->showAgendaView(); | 1509 | mViewManager->showAgendaView(); |
1510 | //mViewManager->readSettings( config ); | 1510 | //mViewManager->readSettings( config ); |
1511 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1511 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1512 | readFilterSettings(config); | 1512 | readFilterSettings(config); |
1513 | config->setGroup( "Views" ); | 1513 | config->setGroup( "Views" ); |
1514 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1514 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1515 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1515 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1516 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1516 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1517 | else mNavigator->selectDates( dateCount ); | 1517 | else mNavigator->selectDates( dateCount ); |
1518 | // mViewManager->readSettings( config ); | 1518 | // mViewManager->readSettings( config ); |
1519 | updateConfig(); | 1519 | updateConfig(); |
1520 | globalFlagBlockAgenda = 2; | 1520 | globalFlagBlockAgenda = 2; |
1521 | mViewManager->readSettings( config ); | 1521 | mViewManager->readSettings( config ); |
1522 | #ifdef DESKTOP_VERSION | 1522 | #ifdef DESKTOP_VERSION |
1523 | config->setGroup("WidgetLayout"); | 1523 | config->setGroup("WidgetLayout"); |
1524 | QStringList list; | 1524 | QStringList list; |
1525 | list = config->readListEntry("MainLayout"); | 1525 | list = config->readListEntry("MainLayout"); |
1526 | int x,y,w,h; | 1526 | int x,y,w,h; |
1527 | if ( ! list.isEmpty() ) { | 1527 | if ( ! list.isEmpty() ) { |
1528 | x = list[0].toInt(); | 1528 | x = list[0].toInt(); |
1529 | y = list[1].toInt(); | 1529 | y = list[1].toInt(); |
1530 | w = list[2].toInt(); | 1530 | w = list[2].toInt(); |
1531 | h = list[3].toInt(); | 1531 | h = list[3].toInt(); |
1532 | topLevelWidget()->setGeometry(x,y,w,h); | 1532 | topLevelWidget()->setGeometry(x,y,w,h); |
1533 | 1533 | ||
1534 | } else { | 1534 | } else { |
1535 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1535 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1536 | } | 1536 | } |
1537 | list = config->readListEntry("EditEventLayout"); | 1537 | list = config->readListEntry("EditEventLayout"); |
1538 | if ( ! list.isEmpty() ) { | 1538 | if ( ! list.isEmpty() ) { |
1539 | x = list[0].toInt(); | 1539 | x = list[0].toInt(); |
1540 | y = list[1].toInt(); | 1540 | y = list[1].toInt(); |
1541 | w = list[2].toInt(); | 1541 | w = list[2].toInt(); |
1542 | h = list[3].toInt(); | 1542 | h = list[3].toInt(); |
1543 | mEventEditor->setGeometry(x,y,w,h); | 1543 | mEventEditor->setGeometry(x,y,w,h); |
1544 | 1544 | ||
1545 | } | 1545 | } |
1546 | list = config->readListEntry("EditTodoLayout"); | 1546 | list = config->readListEntry("EditTodoLayout"); |
1547 | if ( ! list.isEmpty() ) { | 1547 | if ( ! list.isEmpty() ) { |
1548 | x = list[0].toInt(); | 1548 | x = list[0].toInt(); |
1549 | y = list[1].toInt(); | 1549 | y = list[1].toInt(); |
1550 | w = list[2].toInt(); | 1550 | w = list[2].toInt(); |
1551 | h = list[3].toInt(); | 1551 | h = list[3].toInt(); |
1552 | mTodoEditor->setGeometry(x,y,w,h); | 1552 | mTodoEditor->setGeometry(x,y,w,h); |
1553 | 1553 | ||
1554 | } | 1554 | } |
1555 | list = config->readListEntry("ViewerLayout"); | 1555 | list = config->readListEntry("ViewerLayout"); |
1556 | if ( ! list.isEmpty() ) { | 1556 | if ( ! list.isEmpty() ) { |
1557 | x = list[0].toInt(); | 1557 | x = list[0].toInt(); |
1558 | y = list[1].toInt(); | 1558 | y = list[1].toInt(); |
1559 | w = list[2].toInt(); | 1559 | w = list[2].toInt(); |
1560 | h = list[3].toInt(); | 1560 | h = list[3].toInt(); |
1561 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1561 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1562 | } | 1562 | } |
1563 | #endif | 1563 | #endif |
1564 | 1564 | ||
1565 | 1565 | ||
1566 | // pending read sync settings; | 1566 | // pending read sync settings; |
1567 | mSyncProfileNames.clear(); | 1567 | mSyncProfileNames.clear(); |
1568 | mSyncProfileNames << "Profile_1"; | 1568 | mSyncProfileNames << "Profile_1"; |
1569 | mSyncProfileNames << "Profile_2"; | 1569 | mSyncProfileNames << "Profile_2"; |
1570 | mSyncProfileNames << "Profile_3"; | 1570 | mSyncProfileNames << "Profile_3"; |
1571 | mSyncProfileNames << "Profile_4"; | 1571 | mSyncProfileNames << "Profile_4"; |
1572 | mSyncProfileNames << "Profile_5"; | 1572 | mSyncProfileNames << "Profile_5"; |
1573 | KSyncProfile* temp = new KSyncProfile (); | 1573 | KSyncProfile* temp = new KSyncProfile (); |
1574 | temp->setName("Profile_1" ); | 1574 | temp->setName("Profile_1" ); |
1575 | mSyncProfiles.append( temp ); | 1575 | mSyncProfiles.append( temp ); |
1576 | temp = new KSyncProfile (); | 1576 | temp = new KSyncProfile (); |
1577 | temp->setName("Profile_2" ); | 1577 | temp->setName("Profile_2" ); |
1578 | mSyncProfiles.append( temp ); | 1578 | mSyncProfiles.append( temp ); |
1579 | temp = new KSyncProfile (); | 1579 | temp = new KSyncProfile (); |
1580 | temp->setName("Profile_3" ); | 1580 | temp->setName("Profile_3" ); |
1581 | mSyncProfiles.append( temp ); | 1581 | mSyncProfiles.append( temp ); |
1582 | temp = new KSyncProfile (); | 1582 | temp = new KSyncProfile (); |
1583 | temp->setName("Profile_4" ); | 1583 | temp->setName("Profile_4" ); |
1584 | mSyncProfiles.append( temp ); | 1584 | mSyncProfiles.append( temp ); |
1585 | temp = new KSyncProfile (); | 1585 | temp = new KSyncProfile (); |
1586 | temp->setName("Profile_5" ); | 1586 | temp->setName("Profile_5" ); |
1587 | mSyncProfiles.append( temp ); | 1587 | mSyncProfiles.append( temp ); |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | 1590 | ||
1591 | void CalendarView::writeSettings() | 1591 | void CalendarView::writeSettings() |
1592 | { | 1592 | { |
1593 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1593 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1594 | 1594 | ||
1595 | KConfig *config = KOGlobals::config(); | 1595 | KConfig *config = KOGlobals::config(); |
1596 | 1596 | ||
1597 | #ifndef KORG_NOSPLITTER | 1597 | #ifndef KORG_NOSPLITTER |
1598 | config->setGroup("KOrganizer Geometry"); | 1598 | config->setGroup("KOrganizer Geometry"); |
1599 | 1599 | ||
1600 | QValueList<int> list = mPanner->sizes(); | 1600 | QValueList<int> list = mPanner->sizes(); |
1601 | config->writeEntry("Separator1",list); | 1601 | config->writeEntry("Separator1",list); |
1602 | 1602 | ||
1603 | list = mLeftSplitter->sizes(); | 1603 | list = mLeftSplitter->sizes(); |
1604 | config->writeEntry("Separator2",list); | 1604 | config->writeEntry("Separator2",list); |
1605 | #endif | 1605 | #endif |
1606 | 1606 | ||
1607 | mViewManager->writeSettings( config ); | 1607 | mViewManager->writeSettings( config ); |
1608 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1608 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1609 | mDialogManager->writeSettings( config ); | 1609 | mDialogManager->writeSettings( config ); |
1610 | //KOPrefs::instance()->usrWriteConfig(); | 1610 | //KOPrefs::instance()->usrWriteConfig(); |
1611 | KOPrefs::instance()->writeConfig(); | 1611 | KOPrefs::instance()->writeConfig(); |
1612 | 1612 | ||
1613 | writeFilterSettings(config); | 1613 | writeFilterSettings(config); |
1614 | 1614 | ||
1615 | config->setGroup( "Views" ); | 1615 | config->setGroup( "Views" ); |
1616 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1616 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1617 | 1617 | ||
1618 | #ifdef DESKTOP_VERSION | 1618 | #ifdef DESKTOP_VERSION |
1619 | config->setGroup("WidgetLayout"); | 1619 | config->setGroup("WidgetLayout"); |
1620 | QStringList list ;//= config->readListEntry("MainLayout"); | 1620 | QStringList list ;//= config->readListEntry("MainLayout"); |
1621 | int x,y,w,h; | 1621 | int x,y,w,h; |
1622 | QWidget* wid; | 1622 | QWidget* wid; |
1623 | wid = topLevelWidget(); | 1623 | wid = topLevelWidget(); |
1624 | x = wid->geometry().x(); | 1624 | x = wid->geometry().x(); |
1625 | y = wid->geometry().y(); | 1625 | y = wid->geometry().y(); |
1626 | w = wid->width(); | 1626 | w = wid->width(); |
1627 | h = wid->height(); | 1627 | h = wid->height(); |
1628 | list.clear(); | 1628 | list.clear(); |
1629 | list << QString::number( x ); | 1629 | list << QString::number( x ); |
1630 | list << QString::number( y ); | 1630 | list << QString::number( y ); |
1631 | list << QString::number( w ); | 1631 | list << QString::number( w ); |
1632 | list << QString::number( h ); | 1632 | list << QString::number( h ); |
1633 | config->writeEntry("MainLayout",list ); | 1633 | config->writeEntry("MainLayout",list ); |
1634 | 1634 | ||
1635 | wid = mEventEditor; | 1635 | wid = mEventEditor; |
1636 | x = wid->geometry().x(); | 1636 | x = wid->geometry().x(); |
1637 | y = wid->geometry().y(); | 1637 | y = wid->geometry().y(); |
1638 | w = wid->width(); | 1638 | w = wid->width(); |
1639 | h = wid->height(); | 1639 | h = wid->height(); |
1640 | list.clear(); | 1640 | list.clear(); |
1641 | list << QString::number( x ); | 1641 | list << QString::number( x ); |
1642 | list << QString::number( y ); | 1642 | list << QString::number( y ); |
1643 | list << QString::number( w ); | 1643 | list << QString::number( w ); |
1644 | list << QString::number( h ); | 1644 | list << QString::number( h ); |
1645 | config->writeEntry("EditEventLayout",list ); | 1645 | config->writeEntry("EditEventLayout",list ); |
1646 | 1646 | ||
1647 | wid = mTodoEditor; | 1647 | wid = mTodoEditor; |
1648 | x = wid->geometry().x(); | 1648 | x = wid->geometry().x(); |
1649 | y = wid->geometry().y(); | 1649 | y = wid->geometry().y(); |
1650 | w = wid->width(); | 1650 | w = wid->width(); |
1651 | h = wid->height(); | 1651 | h = wid->height(); |
1652 | list.clear(); | 1652 | list.clear(); |
1653 | list << QString::number( x ); | 1653 | list << QString::number( x ); |
1654 | list << QString::number( y ); | 1654 | list << QString::number( y ); |
1655 | list << QString::number( w ); | 1655 | list << QString::number( w ); |
1656 | list << QString::number( h ); | 1656 | list << QString::number( h ); |
1657 | config->writeEntry("EditTodoLayout",list ); | 1657 | config->writeEntry("EditTodoLayout",list ); |
1658 | wid = getEventViewerDialog(); | 1658 | wid = getEventViewerDialog(); |
1659 | x = wid->geometry().x(); | 1659 | x = wid->geometry().x(); |
1660 | y = wid->geometry().y(); | 1660 | y = wid->geometry().y(); |
1661 | w = wid->width(); | 1661 | w = wid->width(); |
1662 | h = wid->height(); | 1662 | h = wid->height(); |
1663 | list.clear(); | 1663 | list.clear(); |
1664 | list << QString::number( x ); | 1664 | list << QString::number( x ); |
1665 | list << QString::number( y ); | 1665 | list << QString::number( y ); |
1666 | list << QString::number( w ); | 1666 | list << QString::number( w ); |
1667 | list << QString::number( h ); | 1667 | list << QString::number( h ); |
1668 | config->writeEntry("ViewerLayout",list ); | 1668 | config->writeEntry("ViewerLayout",list ); |
1669 | wid = mDialogManager->getSearchDialog(); | 1669 | wid = mDialogManager->getSearchDialog(); |
1670 | if ( wid ) { | 1670 | if ( wid ) { |
1671 | x = wid->geometry().x(); | 1671 | x = wid->geometry().x(); |
1672 | y = wid->geometry().y(); | 1672 | y = wid->geometry().y(); |
1673 | w = wid->width(); | 1673 | w = wid->width(); |
1674 | h = wid->height(); | 1674 | h = wid->height(); |
1675 | list.clear(); | 1675 | list.clear(); |
1676 | list << QString::number( x ); | 1676 | list << QString::number( x ); |
1677 | list << QString::number( y ); | 1677 | list << QString::number( y ); |
1678 | list << QString::number( w ); | 1678 | list << QString::number( w ); |
1679 | list << QString::number( h ); | 1679 | list << QString::number( h ); |
1680 | config->writeEntry("SearchLayout",list ); | 1680 | config->writeEntry("SearchLayout",list ); |
1681 | } | 1681 | } |
1682 | #endif | 1682 | #endif |
1683 | 1683 | ||
1684 | 1684 | ||
1685 | config->sync(); | 1685 | config->sync(); |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | void CalendarView::readFilterSettings(KConfig *config) | 1688 | void CalendarView::readFilterSettings(KConfig *config) |
1689 | { | 1689 | { |
1690 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1690 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1691 | 1691 | ||
1692 | mFilters.clear(); | 1692 | mFilters.clear(); |
1693 | 1693 | ||
1694 | config->setGroup("General"); | 1694 | config->setGroup("General"); |
1695 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1695 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1696 | 1696 | ||
1697 | QStringList::ConstIterator it = filterList.begin(); | 1697 | QStringList::ConstIterator it = filterList.begin(); |
1698 | QStringList::ConstIterator end = filterList.end(); | 1698 | QStringList::ConstIterator end = filterList.end(); |
1699 | while(it != end) { | 1699 | while(it != end) { |
1700 | // kdDebug() << " filter: " << (*it) << endl; | 1700 | // kdDebug() << " filter: " << (*it) << endl; |
1701 | 1701 | ||
1702 | CalFilter *filter; | 1702 | CalFilter *filter; |
1703 | filter = new CalFilter(*it); | 1703 | filter = new CalFilter(*it); |
1704 | config->setGroup("Filter_" + (*it)); | 1704 | config->setGroup("Filter_" + (*it)); |
1705 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1705 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1706 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1706 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1707 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1707 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1708 | mFilters.append(filter); | 1708 | mFilters.append(filter); |
1709 | 1709 | ||
1710 | ++it; | 1710 | ++it; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | if (mFilters.count() == 0) { | 1713 | if (mFilters.count() == 0) { |
1714 | CalFilter *filter = new CalFilter(i18n("Default")); | 1714 | CalFilter *filter = new CalFilter(i18n("Default")); |
1715 | mFilters.append(filter); | 1715 | mFilters.append(filter); |
1716 | } | 1716 | } |
1717 | mFilterView->updateFilters(); | 1717 | mFilterView->updateFilters(); |
1718 | config->setGroup("FilterView"); | 1718 | config->setGroup("FilterView"); |
1719 | 1719 | ||
1720 | mFilterView->blockSignals(true); | 1720 | mFilterView->blockSignals(true); |
1721 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1721 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1722 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1722 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1723 | mFilterView->blockSignals(false); | 1723 | mFilterView->blockSignals(false); |
1724 | // We do it manually to avoid it being done twice by the above calls | 1724 | // We do it manually to avoid it being done twice by the above calls |
1725 | updateFilter(); | 1725 | updateFilter(); |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | void CalendarView::writeFilterSettings(KConfig *config) | 1728 | void CalendarView::writeFilterSettings(KConfig *config) |
1729 | { | 1729 | { |
1730 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1730 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1731 | 1731 | ||
1732 | QStringList filterList; | 1732 | QStringList filterList; |
1733 | 1733 | ||
1734 | CalFilter *filter = mFilters.first(); | 1734 | CalFilter *filter = mFilters.first(); |
1735 | while(filter) { | 1735 | while(filter) { |
1736 | // kdDebug() << " fn: " << filter->name() << endl; | 1736 | // kdDebug() << " fn: " << filter->name() << endl; |
1737 | filterList << filter->name(); | 1737 | filterList << filter->name(); |
1738 | config->setGroup("Filter_" + filter->name()); | 1738 | config->setGroup("Filter_" + filter->name()); |
1739 | config->writeEntry("Criteria",filter->criteria()); | 1739 | config->writeEntry("Criteria",filter->criteria()); |
1740 | config->writeEntry("CategoryList",filter->categoryList()); | 1740 | config->writeEntry("CategoryList",filter->categoryList()); |
1741 | filter = mFilters.next(); | 1741 | filter = mFilters.next(); |
1742 | } | 1742 | } |
1743 | config->setGroup("General"); | 1743 | config->setGroup("General"); |
1744 | config->writeEntry("CalendarFilters",filterList); | 1744 | config->writeEntry("CalendarFilters",filterList); |
1745 | 1745 | ||
1746 | config->setGroup("FilterView"); | 1746 | config->setGroup("FilterView"); |
1747 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1747 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1748 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1748 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | 1751 | ||
1752 | void CalendarView::goToday() | 1752 | void CalendarView::goToday() |
1753 | { | 1753 | { |
1754 | mNavigator->selectToday(); | 1754 | mNavigator->selectToday(); |
1755 | } | 1755 | } |
1756 | 1756 | ||
1757 | void CalendarView::goNext() | 1757 | void CalendarView::goNext() |
1758 | { | 1758 | { |
1759 | mNavigator->selectNext(); | 1759 | mNavigator->selectNext(); |
1760 | } | 1760 | } |
1761 | 1761 | ||
1762 | void CalendarView::goPrevious() | 1762 | void CalendarView::goPrevious() |
1763 | { | 1763 | { |
1764 | mNavigator->selectPrevious(); | 1764 | mNavigator->selectPrevious(); |
1765 | } | 1765 | } |
1766 | void CalendarView::goNextMonth() | 1766 | void CalendarView::goNextMonth() |
1767 | { | 1767 | { |
1768 | mNavigator->selectNextMonth(); | 1768 | mNavigator->selectNextMonth(); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void CalendarView::goPreviousMonth() | 1771 | void CalendarView::goPreviousMonth() |
1772 | { | 1772 | { |
1773 | mNavigator->selectPreviousMonth(); | 1773 | mNavigator->selectPreviousMonth(); |
1774 | } | 1774 | } |
1775 | void CalendarView::writeLocale() | 1775 | void CalendarView::writeLocale() |
1776 | { | 1776 | { |
1777 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1777 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1778 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1778 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1779 | KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); | 1779 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1780 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1780 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1781 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1781 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1782 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1782 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1783 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1783 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1784 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1784 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1785 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1785 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1786 | KOPrefs::instance()->mDaylightsavingStart, | 1786 | KOPrefs::instance()->mDaylightsavingStart, |
1787 | KOPrefs::instance()->mDaylightsavingEnd ); | 1787 | KOPrefs::instance()->mDaylightsavingEnd ); |
1788 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1788 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1789 | } | 1789 | } |
1790 | void CalendarView::updateConfig() | 1790 | void CalendarView::updateConfig() |
1791 | { | 1791 | { |
1792 | writeLocale(); | 1792 | writeLocale(); |
1793 | if ( KOPrefs::instance()->mUseAppColors ) | 1793 | if ( KOPrefs::instance()->mUseAppColors ) |
1794 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1794 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1795 | emit configChanged(); | 1795 | emit configChanged(); |
1796 | mTodoList->updateConfig(); | 1796 | mTodoList->updateConfig(); |
1797 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1797 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1798 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1798 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1799 | // To make the "fill window" configurations work | 1799 | // To make the "fill window" configurations work |
1800 | //mViewManager->raiseCurrentView(); | 1800 | //mViewManager->raiseCurrentView(); |
1801 | } | 1801 | } |
1802 | 1802 | ||
1803 | 1803 | ||
1804 | void CalendarView::eventChanged(Event *event) | 1804 | void CalendarView::eventChanged(Event *event) |
1805 | { | 1805 | { |
1806 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1806 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1807 | //updateUnmanagedViews(); | 1807 | //updateUnmanagedViews(); |
1808 | } | 1808 | } |
1809 | 1809 | ||
1810 | void CalendarView::eventAdded(Event *event) | 1810 | void CalendarView::eventAdded(Event *event) |
1811 | { | 1811 | { |
1812 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1812 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1813 | } | 1813 | } |
1814 | 1814 | ||
1815 | void CalendarView::eventToBeDeleted(Event *) | 1815 | void CalendarView::eventToBeDeleted(Event *) |
1816 | { | 1816 | { |
1817 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1817 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | void CalendarView::eventDeleted() | 1820 | void CalendarView::eventDeleted() |
1821 | { | 1821 | { |
1822 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1822 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1823 | } | 1823 | } |
1824 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1824 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1825 | { | 1825 | { |
1826 | changeIncidenceDisplay((Incidence *)which, action); | 1826 | changeIncidenceDisplay((Incidence *)which, action); |
1827 | } | 1827 | } |
1828 | void CalendarView::checkZaurusId( int id, bool todo ) | 1828 | void CalendarView::checkZaurusId( int id, bool todo ) |
1829 | { | 1829 | { |
1830 | if ( id >= 0 ) { | 1830 | if ( id >= 0 ) { |
1831 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); | 1831 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); |
1832 | if ( lse ) { | 1832 | if ( lse ) { |
1833 | QString des = lse->description(); | 1833 | QString des = lse->description(); |
1834 | QString pref = "e"; | 1834 | QString pref = "e"; |
1835 | if ( todo ) | 1835 | if ( todo ) |
1836 | pref = "t"; | 1836 | pref = "t"; |
1837 | des += pref+ QString::number ( id ) + ","; | 1837 | des += pref+ QString::number ( id ) + ","; |
1838 | lse->setReadOnly( false ); | 1838 | lse->setReadOnly( false ); |
1839 | lse->setDescription( des ); | 1839 | lse->setDescription( des ); |
1840 | lse->setReadOnly( true ); | 1840 | lse->setReadOnly( true ); |
1841 | } | 1841 | } |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1844 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1845 | { | 1845 | { |
1846 | updateUnmanagedViews(); | 1846 | updateUnmanagedViews(); |
1847 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1847 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1848 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1848 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1849 | mCalendar->checkAlarmForIncidence( 0, true ); | 1849 | mCalendar->checkAlarmForIncidence( 0, true ); |
1850 | if ( mEventViewerDialog ) | 1850 | if ( mEventViewerDialog ) |
1851 | mEventViewerDialog->hide(); | 1851 | mEventViewerDialog->hide(); |
1852 | } | 1852 | } |
1853 | else | 1853 | else |
1854 | mCalendar->checkAlarmForIncidence( which , false ); | 1854 | mCalendar->checkAlarmForIncidence( which , false ); |
1855 | } | 1855 | } |
1856 | 1856 | ||
1857 | // most of the changeEventDisplays() right now just call the view's | 1857 | // most of the changeEventDisplays() right now just call the view's |
1858 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1858 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1859 | void CalendarView::changeEventDisplay(Event *which, int action) | 1859 | void CalendarView::changeEventDisplay(Event *which, int action) |
1860 | { | 1860 | { |
1861 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1861 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1862 | changeIncidenceDisplay((Incidence *)which, action); | 1862 | changeIncidenceDisplay((Incidence *)which, action); |
1863 | mDateNavigator->updateView(); | 1863 | mDateNavigator->updateView(); |
1864 | //mDialogManager->updateSearchDialog(); | 1864 | //mDialogManager->updateSearchDialog(); |
1865 | 1865 | ||
1866 | if (which) { | 1866 | if (which) { |
1867 | // If there is an event view visible update the display | 1867 | // If there is an event view visible update the display |
1868 | mViewManager->currentView()->changeEventDisplay(which,action); | 1868 | mViewManager->currentView()->changeEventDisplay(which,action); |
1869 | // TODO: check, if update needed | 1869 | // TODO: check, if update needed |
1870 | // if (which->getTodoStatus()) { | 1870 | // if (which->getTodoStatus()) { |
1871 | mTodoList->updateView(); | 1871 | mTodoList->updateView(); |
1872 | // } | 1872 | // } |
1873 | } else { | 1873 | } else { |
1874 | mViewManager->currentView()->updateView(); | 1874 | mViewManager->currentView()->updateView(); |
1875 | } | 1875 | } |
1876 | } | 1876 | } |
1877 | 1877 | ||
1878 | 1878 | ||
1879 | void CalendarView::updateTodoViews() | 1879 | void CalendarView::updateTodoViews() |
1880 | { | 1880 | { |
1881 | 1881 | ||
1882 | mTodoList->updateView(); | 1882 | mTodoList->updateView(); |
1883 | mViewManager->currentView()->updateView(); | 1883 | mViewManager->currentView()->updateView(); |
1884 | 1884 | ||
1885 | } | 1885 | } |
1886 | 1886 | ||
1887 | 1887 | ||
1888 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1888 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1889 | { | 1889 | { |
1890 | mTodoList->updateView(); | 1890 | mTodoList->updateView(); |
1891 | mViewManager->updateView(start, end); | 1891 | mViewManager->updateView(start, end); |
1892 | //mDateNavigator->updateView(); | 1892 | //mDateNavigator->updateView(); |
1893 | } | 1893 | } |
1894 | 1894 | ||
1895 | void CalendarView::updateView() | 1895 | void CalendarView::updateView() |
1896 | { | 1896 | { |
1897 | DateList tmpList = mNavigator->selectedDates(); | 1897 | DateList tmpList = mNavigator->selectedDates(); |
1898 | 1898 | ||
1899 | // We assume that the navigator only selects consecutive days. | 1899 | // We assume that the navigator only selects consecutive days. |
1900 | updateView( tmpList.first(), tmpList.last() ); | 1900 | updateView( tmpList.first(), tmpList.last() ); |
1901 | } | 1901 | } |
1902 | 1902 | ||
1903 | void CalendarView::updateUnmanagedViews() | 1903 | void CalendarView::updateUnmanagedViews() |
1904 | { | 1904 | { |
1905 | mDateNavigator->updateDayMatrix(); | 1905 | mDateNavigator->updateDayMatrix(); |
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | int CalendarView::msgItemDelete() | 1908 | int CalendarView::msgItemDelete() |
1909 | { | 1909 | { |
1910 | return KMessageBox::warningContinueCancel(this, | 1910 | return KMessageBox::warningContinueCancel(this, |
1911 | i18n("This item will be\npermanently deleted."), | 1911 | i18n("This item will be\npermanently deleted."), |
1912 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1912 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | 1915 | ||
1916 | void CalendarView::edit_cut() | 1916 | void CalendarView::edit_cut() |
1917 | { | 1917 | { |
1918 | Event *anEvent=0; | 1918 | Event *anEvent=0; |
1919 | 1919 | ||
1920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1921 | 1921 | ||
1922 | if (mViewManager->currentView()->isEventView()) { | 1922 | if (mViewManager->currentView()->isEventView()) { |
1923 | if ( incidence && incidence->type() == "Event" ) { | 1923 | if ( incidence && incidence->type() == "Event" ) { |
1924 | anEvent = static_cast<Event *>(incidence); | 1924 | anEvent = static_cast<Event *>(incidence); |
1925 | } | 1925 | } |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | if (!anEvent) { | 1928 | if (!anEvent) { |
1929 | KNotifyClient::beep(); | 1929 | KNotifyClient::beep(); |
1930 | return; | 1930 | return; |
1931 | } | 1931 | } |
1932 | DndFactory factory( mCalendar ); | 1932 | DndFactory factory( mCalendar ); |
1933 | factory.cutEvent(anEvent); | 1933 | factory.cutEvent(anEvent); |
1934 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1934 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | void CalendarView::edit_copy() | 1937 | void CalendarView::edit_copy() |
1938 | { | 1938 | { |
1939 | Event *anEvent=0; | 1939 | Event *anEvent=0; |
1940 | 1940 | ||
1941 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1941 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1942 | 1942 | ||
1943 | if (mViewManager->currentView()->isEventView()) { | 1943 | if (mViewManager->currentView()->isEventView()) { |
1944 | if ( incidence && incidence->type() == "Event" ) { | 1944 | if ( incidence && incidence->type() == "Event" ) { |
1945 | anEvent = static_cast<Event *>(incidence); | 1945 | anEvent = static_cast<Event *>(incidence); |
1946 | } | 1946 | } |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | if (!anEvent) { | 1949 | if (!anEvent) { |
1950 | KNotifyClient::beep(); | 1950 | KNotifyClient::beep(); |
1951 | return; | 1951 | return; |
1952 | } | 1952 | } |
1953 | DndFactory factory( mCalendar ); | 1953 | DndFactory factory( mCalendar ); |
1954 | factory.copyEvent(anEvent); | 1954 | factory.copyEvent(anEvent); |
1955 | } | 1955 | } |
1956 | 1956 | ||
1957 | void CalendarView::edit_paste() | 1957 | void CalendarView::edit_paste() |
1958 | { | 1958 | { |
1959 | QDate date = mNavigator->selectedDates().first(); | 1959 | QDate date = mNavigator->selectedDates().first(); |
1960 | 1960 | ||
1961 | DndFactory factory( mCalendar ); | 1961 | DndFactory factory( mCalendar ); |
1962 | Event *pastedEvent = factory.pasteEvent( date ); | 1962 | Event *pastedEvent = factory.pasteEvent( date ); |
1963 | 1963 | ||
1964 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 1964 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | void CalendarView::edit_options() | 1967 | void CalendarView::edit_options() |
1968 | { | 1968 | { |
1969 | mDialogManager->showOptionsDialog(); | 1969 | mDialogManager->showOptionsDialog(); |
1970 | //writeSettings(); | 1970 | //writeSettings(); |
1971 | } | 1971 | } |
1972 | void CalendarView::edit_sync_options() | 1972 | void CalendarView::edit_sync_options() |
1973 | { | 1973 | { |
1974 | //mDialogManager->showSyncOptions(); | 1974 | //mDialogManager->showSyncOptions(); |
1975 | //KOPrefs::instance()->mSyncAlgoPrefs | 1975 | //KOPrefs::instance()->mSyncAlgoPrefs |
1976 | QDialog dia( this, "dia", true ); | 1976 | QDialog dia( this, "dia", true ); |
1977 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 1977 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
1978 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 1978 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
1979 | QVBoxLayout lay ( &dia ); | 1979 | QVBoxLayout lay ( &dia ); |
1980 | lay.setSpacing( 2 ); | 1980 | lay.setSpacing( 2 ); |
1981 | lay.setMargin( 3 ); | 1981 | lay.setMargin( 3 ); |
1982 | lay.addWidget(&gr); | 1982 | lay.addWidget(&gr); |
1983 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 1983 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
1984 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 1984 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
1985 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 1985 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
1986 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 1986 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
1987 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 1987 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
1988 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 1988 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
1989 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 1989 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
1990 | QPushButton pb ( "OK", &dia); | 1990 | QPushButton pb ( "OK", &dia); |
1991 | lay.addWidget( &pb ); | 1991 | lay.addWidget( &pb ); |
1992 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1992 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1993 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 1993 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
1994 | case 0: | 1994 | case 0: |
1995 | loc.setChecked( true); | 1995 | loc.setChecked( true); |
1996 | break; | 1996 | break; |
1997 | case 1: | 1997 | case 1: |
1998 | rem.setChecked( true ); | 1998 | rem.setChecked( true ); |
1999 | break; | 1999 | break; |
2000 | case 2: | 2000 | case 2: |
2001 | newest.setChecked( true); | 2001 | newest.setChecked( true); |
2002 | break; | 2002 | break; |
2003 | case 3: | 2003 | case 3: |
2004 | ask.setChecked( true); | 2004 | ask.setChecked( true); |
2005 | break; | 2005 | break; |
2006 | case 4: | 2006 | case 4: |
2007 | f_loc.setChecked( true); | 2007 | f_loc.setChecked( true); |
2008 | break; | 2008 | break; |
2009 | case 5: | 2009 | case 5: |
2010 | f_rem.setChecked( true); | 2010 | f_rem.setChecked( true); |
2011 | break; | 2011 | break; |
2012 | case 6: | 2012 | case 6: |
2013 | // both.setChecked( true); | 2013 | // both.setChecked( true); |
2014 | break; | 2014 | break; |
2015 | default: | 2015 | default: |
2016 | break; | 2016 | break; |
2017 | } | 2017 | } |
2018 | if ( dia.exec() ) { | 2018 | if ( dia.exec() ) { |
2019 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2019 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2020 | } | 2020 | } |
2021 | 2021 | ||
2022 | } | 2022 | } |
2023 | 2023 | ||
2024 | void CalendarView::slotSelectPickerDate( QDate d) | 2024 | void CalendarView::slotSelectPickerDate( QDate d) |
2025 | { | 2025 | { |
2026 | mDateFrame->hide(); | 2026 | mDateFrame->hide(); |
2027 | if ( mDatePickerMode == 1 ) { | 2027 | if ( mDatePickerMode == 1 ) { |
2028 | mNavigator->slotDaySelect( d ); | 2028 | mNavigator->slotDaySelect( d ); |
2029 | } else if ( mDatePickerMode == 2 ) { | 2029 | } else if ( mDatePickerMode == 2 ) { |
2030 | if ( mMoveIncidence->type() == "Todo" ) { | 2030 | if ( mMoveIncidence->type() == "Todo" ) { |
2031 | Todo * to = (Todo *) mMoveIncidence; | 2031 | Todo * to = (Todo *) mMoveIncidence; |
2032 | QTime tim; | 2032 | QTime tim; |
2033 | if ( to->hasDueDate() ) | 2033 | if ( to->hasDueDate() ) |
2034 | tim = to->dtDue().time(); | 2034 | tim = to->dtDue().time(); |
2035 | else { | 2035 | else { |
2036 | tim = QTime ( 0,0,0 ); | 2036 | tim = QTime ( 0,0,0 ); |
2037 | to->setFloats( true ); | 2037 | to->setFloats( true ); |
2038 | to->setHasDueDate( true ); | 2038 | to->setHasDueDate( true ); |
2039 | } | 2039 | } |
2040 | QDateTime dt ( d,tim ); | 2040 | QDateTime dt ( d,tim ); |
2041 | to->setDtDue( dt ); | 2041 | to->setDtDue( dt ); |
2042 | todoChanged( to ); | 2042 | todoChanged( to ); |
2043 | } else { | 2043 | } else { |
2044 | QTime tim = mMoveIncidence->dtStart().time(); | 2044 | QTime tim = mMoveIncidence->dtStart().time(); |
2045 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2045 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2046 | QDateTime dt ( d,tim ); | 2046 | QDateTime dt ( d,tim ); |
2047 | mMoveIncidence->setDtStart( dt ); | 2047 | mMoveIncidence->setDtStart( dt ); |
2048 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2048 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2049 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2049 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2050 | } | 2050 | } |
2051 | 2051 | ||
2052 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2052 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2053 | } | 2053 | } |
2054 | } | 2054 | } |
2055 | 2055 | ||
2056 | void CalendarView::removeCategories() | 2056 | void CalendarView::removeCategories() |
2057 | { | 2057 | { |
2058 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2058 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2059 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2059 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2060 | QStringList catIncList; | 2060 | QStringList catIncList; |
2061 | QStringList newCatList; | 2061 | QStringList newCatList; |
2062 | Incidence* inc = incList.first(); | 2062 | Incidence* inc = incList.first(); |
2063 | int i; | 2063 | int i; |
2064 | int count = 0; | 2064 | int count = 0; |
2065 | while ( inc ) { | 2065 | while ( inc ) { |
2066 | newCatList.clear(); | 2066 | newCatList.clear(); |
2067 | catIncList = inc->categories() ; | 2067 | catIncList = inc->categories() ; |
2068 | for( i = 0; i< catIncList.count(); ++i ) { | 2068 | for( i = 0; i< catIncList.count(); ++i ) { |
2069 | if ( catList.contains (catIncList[i])) | 2069 | if ( catList.contains (catIncList[i])) |
2070 | newCatList.append( catIncList[i] ); | 2070 | newCatList.append( catIncList[i] ); |
2071 | } | 2071 | } |
2072 | newCatList.sort(); | 2072 | newCatList.sort(); |
2073 | inc->setCategories( newCatList.join(",") ); | 2073 | inc->setCategories( newCatList.join(",") ); |
2074 | inc = incList.next(); | 2074 | inc = incList.next(); |
2075 | } | 2075 | } |
2076 | } | 2076 | } |
2077 | 2077 | ||
2078 | int CalendarView::addCategories() | 2078 | int CalendarView::addCategories() |
2079 | { | 2079 | { |
2080 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2080 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2081 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2081 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2082 | QStringList catIncList; | 2082 | QStringList catIncList; |
2083 | Incidence* inc = incList.first(); | 2083 | Incidence* inc = incList.first(); |
2084 | int i; | 2084 | int i; |
2085 | int count = 0; | 2085 | int count = 0; |
2086 | while ( inc ) { | 2086 | while ( inc ) { |
2087 | catIncList = inc->categories() ; | 2087 | catIncList = inc->categories() ; |
2088 | for( i = 0; i< catIncList.count(); ++i ) { | 2088 | for( i = 0; i< catIncList.count(); ++i ) { |
2089 | if ( !catList.contains (catIncList[i])) { | 2089 | if ( !catList.contains (catIncList[i])) { |
2090 | catList.append( catIncList[i] ); | 2090 | catList.append( catIncList[i] ); |
2091 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2091 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2092 | ++count; | 2092 | ++count; |
2093 | } | 2093 | } |
2094 | } | 2094 | } |
2095 | inc = incList.next(); | 2095 | inc = incList.next(); |
2096 | } | 2096 | } |
2097 | catList.sort(); | 2097 | catList.sort(); |
2098 | KOPrefs::instance()->mCustomCategories = catList; | 2098 | KOPrefs::instance()->mCustomCategories = catList; |
2099 | return count; | 2099 | return count; |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | void CalendarView::manageCategories() | 2102 | void CalendarView::manageCategories() |
2103 | { | 2103 | { |
2104 | KOCatPrefs* cp = new KOCatPrefs(); | 2104 | KOCatPrefs* cp = new KOCatPrefs(); |
2105 | cp->show(); | 2105 | cp->show(); |
2106 | int w =cp->sizeHint().width() ; | 2106 | int w =cp->sizeHint().width() ; |
2107 | int h = cp->sizeHint().height() ; | 2107 | int h = cp->sizeHint().height() ; |
2108 | int dw = QApplication::desktop()->width(); | 2108 | int dw = QApplication::desktop()->width(); |
2109 | int dh = QApplication::desktop()->height(); | 2109 | int dh = QApplication::desktop()->height(); |
2110 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2110 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2111 | if ( !cp->exec() ) { | 2111 | if ( !cp->exec() ) { |
2112 | delete cp; | 2112 | delete cp; |
2113 | return; | 2113 | return; |
2114 | } | 2114 | } |
2115 | int count = 0; | 2115 | int count = 0; |
2116 | if ( cp->addCat() ) { | 2116 | if ( cp->addCat() ) { |
2117 | count = addCategories(); | 2117 | count = addCategories(); |
2118 | if ( count ) { | 2118 | if ( count ) { |
2119 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2119 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2120 | writeSettings(); | 2120 | writeSettings(); |
2121 | } | 2121 | } |
2122 | } else { | 2122 | } else { |
2123 | removeCategories(); | 2123 | removeCategories(); |
2124 | updateView(); | 2124 | updateView(); |
2125 | } | 2125 | } |
2126 | delete cp; | 2126 | delete cp; |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | void CalendarView::beamIncidence(Incidence * Inc) | 2129 | void CalendarView::beamIncidence(Incidence * Inc) |
2130 | { | 2130 | { |
2131 | QPtrList<Incidence> delSel ; | 2131 | QPtrList<Incidence> delSel ; |
2132 | delSel.append(Inc); | 2132 | delSel.append(Inc); |
2133 | beamIncidenceList( delSel ); | 2133 | beamIncidenceList( delSel ); |
2134 | } | 2134 | } |
2135 | void CalendarView::beamCalendar() | 2135 | void CalendarView::beamCalendar() |
2136 | { | 2136 | { |
2137 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2137 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2138 | //qDebug("beamCalendar() "); | 2138 | //qDebug("beamCalendar() "); |
2139 | beamIncidenceList( delSel ); | 2139 | beamIncidenceList( delSel ); |
2140 | } | 2140 | } |
2141 | void CalendarView::beamFilteredCalendar() | 2141 | void CalendarView::beamFilteredCalendar() |
2142 | { | 2142 | { |
2143 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2143 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2144 | //qDebug("beamFilteredCalendar() "); | 2144 | //qDebug("beamFilteredCalendar() "); |
2145 | beamIncidenceList( delSel ); | 2145 | beamIncidenceList( delSel ); |
2146 | } | 2146 | } |
2147 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2147 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2148 | { | 2148 | { |
2149 | if ( beamDialog->exec () == QDialog::Rejected ) | 2149 | if ( beamDialog->exec () == QDialog::Rejected ) |
2150 | return; | 2150 | return; |
2151 | 2151 | ||
2152 | QString fn = "/tmp/kopibeamfile"; | 2152 | QString fn = "/tmp/kopibeamfile"; |
2153 | QString mes; | 2153 | QString mes; |
2154 | bool createbup = true; | 2154 | bool createbup = true; |
2155 | if ( createbup ) { | 2155 | if ( createbup ) { |
2156 | QString description = "\n"; | 2156 | QString description = "\n"; |
2157 | CalendarLocal* cal = new CalendarLocal(); | 2157 | CalendarLocal* cal = new CalendarLocal(); |
2158 | if ( beamDialog->beamLocal() ) | 2158 | if ( beamDialog->beamLocal() ) |
2159 | cal->setLocalTime(); | 2159 | cal->setLocalTime(); |
2160 | else | 2160 | else |
2161 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2161 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2162 | Incidence *incidence = delSel.first(); | 2162 | Incidence *incidence = delSel.first(); |
2163 | bool addText = false; | 2163 | bool addText = false; |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 0547a2e..b2001ec 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -69,581 +69,575 @@ KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | |||
69 | mView = new WhatsNextTextBrowser(this); | 69 | mView = new WhatsNextTextBrowser(this); |
70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
71 | 71 | ||
72 | mEventViewer = 0; | 72 | mEventViewer = 0; |
73 | 73 | ||
74 | QBoxLayout *topLayout = new QVBoxLayout(this); | 74 | QBoxLayout *topLayout = new QVBoxLayout(this); |
75 | // topLayout->addWidget(mDateLabel); | 75 | // topLayout->addWidget(mDateLabel); |
76 | topLayout->addWidget(mView); | 76 | topLayout->addWidget(mView); |
77 | } | 77 | } |
78 | 78 | ||
79 | KOWhatsNextView::~KOWhatsNextView() | 79 | KOWhatsNextView::~KOWhatsNextView() |
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | int KOWhatsNextView::maxDatesHint() | 83 | int KOWhatsNextView::maxDatesHint() |
84 | { | 84 | { |
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | int KOWhatsNextView::currentDateCount() | 88 | int KOWhatsNextView::currentDateCount() |
89 | { | 89 | { |
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 93 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
94 | { | 94 | { |
95 | QPtrList<Incidence> eventList; | 95 | QPtrList<Incidence> eventList; |
96 | 96 | ||
97 | return eventList; | 97 | return eventList; |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 101 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
102 | const QDate &td) | 102 | const QDate &td) |
103 | { | 103 | { |
104 | #ifndef KORG_NOPRINTER | 104 | #ifndef KORG_NOPRINTER |
105 | calPrinter->preview(CalPrinter::Day, fd, td); | 105 | calPrinter->preview(CalPrinter::Day, fd, td); |
106 | #endif | 106 | #endif |
107 | } | 107 | } |
108 | void KOWhatsNextView::updateConfig() | 108 | void KOWhatsNextView::updateConfig() |
109 | { | 109 | { |
110 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 110 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
111 | updateView(); | 111 | updateView(); |
112 | 112 | ||
113 | } | 113 | } |
114 | void KOWhatsNextView::updateView() | 114 | void KOWhatsNextView::updateView() |
115 | { | 115 | { |
116 | 116 | ||
117 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 117 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
118 | KIconLoader kil("korganizer"); | 118 | KIconLoader kil("korganizer"); |
119 | QString ipath;// = new QString(); | 119 | QString ipath;// = new QString(); |
120 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 120 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
121 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 121 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
122 | mText = "<table width=\"100%\">\n"; | 122 | mText = "<table width=\"100%\">\n"; |
123 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 123 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
124 | #ifdef DESKTOP_VERSION | 124 | #ifdef DESKTOP_VERSION |
125 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 125 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
126 | #else | 126 | #else |
127 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 127 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
128 | #endif | 128 | #endif |
129 | // mText += "<img src=\""; | 129 | // mText += "<img src=\""; |
130 | // mText += ipath; | 130 | // mText += ipath; |
131 | // mText += "\">"; | 131 | // mText += "\">"; |
132 | mEventDate = QDate::currentDate(); | 132 | mEventDate = QDate::currentDate(); |
133 | #ifdef DESKTOP_VERSION | 133 | #ifdef DESKTOP_VERSION |
134 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 134 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
135 | #else | 135 | #else |
136 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 136 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
137 | #endif | 137 | #endif |
138 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 138 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
139 | int iii; | 139 | int iii; |
140 | mTodos.clear(); | 140 | mTodos.clear(); |
141 | QPtrList<Event> events; | 141 | QPtrList<Event> events; |
142 | QPtrList<Todo> todos = calendar()->todos(); | 142 | QPtrList<Todo> todos = calendar()->todos(); |
143 | Todo * todo; | 143 | Todo * todo; |
144 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 144 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
145 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 145 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
146 | bool itemAdded = false; | 146 | bool itemAdded = false; |
147 | for ( iii = 0; iii < daysToShow; ++iii ) { | 147 | for ( iii = 0; iii < daysToShow; ++iii ) { |
148 | QString date; | 148 | QString date; |
149 | itemAdded = false; | 149 | itemAdded = false; |
150 | events = calendar()->events( mEventDate, true ); | 150 | events = calendar()->events( mEventDate, true ); |
151 | 151 | ||
152 | if ( iii == 0 ) { // today !!! | 152 | if ( iii == 0 ) { // today !!! |
153 | todo = todos.first(); | 153 | todo = todos.first(); |
154 | while(todo) { | 154 | while(todo) { |
155 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 155 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
156 | if ( ! itemAdded ) { | 156 | if ( ! itemAdded ) { |
157 | appendDay ( iii, mEventDate ); | 157 | appendDay ( iii, mEventDate ); |
158 | itemAdded = true; | 158 | itemAdded = true; |
159 | 159 | ||
160 | } | 160 | } |
161 | appendEvent(todo); | 161 | appendEvent(todo); |
162 | } | 162 | } |
163 | todo = todos.next(); | 163 | todo = todos.next(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | if (events.count() > 0) { | 168 | if (events.count() > 0) { |
169 | // mText += "<p></p>"; | 169 | // mText += "<p></p>"; |
170 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 170 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
171 | // mText += "<h2>"; | 171 | // mText += "<h2>"; |
172 | //mText += " <img src=\""; | 172 | //mText += " <img src=\""; |
173 | //mText += ipath; | 173 | //mText += ipath; |
174 | //mText += "\">"; | 174 | //mText += "\">"; |
175 | if ( ! itemAdded ) { | 175 | if ( ! itemAdded ) { |
176 | appendDay ( iii, mEventDate ); | 176 | appendDay ( iii, mEventDate ); |
177 | itemAdded = true; | 177 | itemAdded = true; |
178 | 178 | ||
179 | } | 179 | } |
180 | Event *ev = events.first(); | 180 | Event *ev = events.first(); |
181 | while(ev) { | 181 | while(ev) { |
182 | //qDebug("+++++event append %s", ev->summary().latin1()); | 182 | //qDebug("+++++event append %s", ev->summary().latin1()); |
183 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 183 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
184 | appendEvent(ev, false , iii!= 0 ); | 184 | appendEvent(ev, false , iii!= 0 ); |
185 | } | 185 | } |
186 | ev = events.next(); | 186 | ev = events.next(); |
187 | } | 187 | } |
188 | 188 | ||
189 | //mText += "</table>\n"; | 189 | //mText += "</table>\n"; |
190 | } | 190 | } |
191 | 191 | ||
192 | todo = todos.first(); | 192 | todo = todos.first(); |
193 | while(todo) { | 193 | while(todo) { |
194 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 194 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
195 | if ( ! itemAdded ) { | 195 | if ( ! itemAdded ) { |
196 | appendDay ( iii, mEventDate ); | 196 | appendDay ( iii, mEventDate ); |
197 | itemAdded = true; | 197 | itemAdded = true; |
198 | } | 198 | } |
199 | appendEvent(todo); | 199 | appendEvent(todo); |
200 | } | 200 | } |
201 | todo = todos.next(); | 201 | todo = todos.next(); |
202 | } | 202 | } |
203 | if ( !itemAdded && iii == 0 ) { | 203 | if ( !itemAdded && iii == 0 ) { |
204 | // appendDay ( iii, mEventDate ); | 204 | // appendDay ( iii, mEventDate ); |
205 | //mText += "<table>"; | 205 | //mText += "<table>"; |
206 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 206 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
207 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; | 207 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; |
208 | //mText +="</table>"; | 208 | //mText +="</table>"; |
209 | } | 209 | } |
210 | if ( itemAdded ) | 210 | if ( itemAdded ) |
211 | mText += "</table>\n"; | 211 | mText += "</table>\n"; |
212 | mEventDate = mEventDate.addDays( 1 ); | 212 | mEventDate = mEventDate.addDays( 1 ); |
213 | } | 213 | } |
214 | 214 | ||
215 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 215 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
216 | if (todos.count() > 0 && topmostPrios > 0 ) { | 216 | if (todos.count() > 0 && topmostPrios > 0 ) { |
217 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 217 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
218 | // mText += "<h2>"; | 218 | // mText += "<h2>"; |
219 | //<img src=\""; | 219 | //<img src=\""; |
220 | // mText += ipath; | 220 | // mText += ipath; |
221 | // mText += "\">"; | 221 | // mText += "\">"; |
222 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 222 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
223 | 223 | ||
224 | //mText += "<ul>\n"; | 224 | //mText += "<ul>\n"; |
225 | bool gotone = false; | 225 | bool gotone = false; |
226 | int priority = 1; | 226 | int priority = 1; |
227 | int priosFound = 0; | 227 | int priosFound = 0; |
228 | #ifdef DESKTOP_VERSION | 228 | #ifdef DESKTOP_VERSION |
229 | mText +="<p></p>"; | 229 | mText +="<p></p>"; |
230 | #endif | 230 | #endif |
231 | 231 | ||
232 | mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; | 232 | mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; |
233 | mText += "<ul>\n"; | 233 | mText += "<ul>\n"; |
234 | while (!gotone && priority<6) { | 234 | while (!gotone && priority<6) { |
235 | todo = todos.first(); | 235 | todo = todos.first(); |
236 | while(todo) { | 236 | while(todo) { |
237 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 237 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
238 | if ( appendTodo(todo) ) | 238 | if ( appendTodo(todo) ) |
239 | gotone = true; | 239 | gotone = true; |
240 | } | 240 | } |
241 | todo = todos.next(); | 241 | todo = todos.next(); |
242 | } | 242 | } |
243 | if ( gotone ) { | 243 | if ( gotone ) { |
244 | gotone = false; | 244 | gotone = false; |
245 | ++priosFound; | 245 | ++priosFound; |
246 | if ( priosFound == topmostPrios ) | 246 | if ( priosFound == topmostPrios ) |
247 | break; | 247 | break; |
248 | } | 248 | } |
249 | priority++; | 249 | priority++; |
250 | // kdDebug() << "adding the todos..." << endl; | 250 | // kdDebug() << "adding the todos..." << endl; |
251 | } | 251 | } |
252 | mText += "</ul>\n"; | 252 | mText += "</ul>\n"; |
253 | } | 253 | } |
254 | 254 | ||
255 | int replys = 0; | 255 | int replys = 0; |
256 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 256 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
257 | if (events.count() > 0) { | 257 | if (events.count() > 0) { |
258 | Event *ev = events.first(); | 258 | Event *ev = events.first(); |
259 | while(ev) { | 259 | while(ev) { |
260 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 260 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
261 | if (me!=0) { | 261 | if (me!=0) { |
262 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 262 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
263 | if (replys == 0) { | 263 | if (replys == 0) { |
264 | mText += "<p></p>"; | 264 | mText += "<p></p>"; |
265 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 265 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
266 | mText += "<h2>"; | 266 | mText += "<h2>"; |
267 | //<img src=\""; | 267 | //<img src=\""; |
268 | // mText += ipath; | 268 | // mText += ipath; |
269 | // mText += "\">"; | 269 | // mText += "\">"; |
270 | mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 270 | mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
271 | mText += "<table>\n"; | 271 | mText += "<table>\n"; |
272 | } | 272 | } |
273 | replys++; | 273 | replys++; |
274 | appendEvent(ev,true); | 274 | appendEvent(ev,true); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | ev = events.next(); | 277 | ev = events.next(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | todos = calendar()->todos(); | 280 | todos = calendar()->todos(); |
281 | if (todos.count() > 0) { | 281 | if (todos.count() > 0) { |
282 | Todo *to = todos.first(); | 282 | Todo *to = todos.first(); |
283 | while(to) { | 283 | while(to) { |
284 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 284 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
285 | if (me!=0) { | 285 | if (me!=0) { |
286 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 286 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
287 | if (replys == 0) { | 287 | if (replys == 0) { |
288 | mText += "<p></p>"; | 288 | mText += "<p></p>"; |
289 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 289 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
290 | mText += "<h2>"; | 290 | mText += "<h2>"; |
291 | //<img src=\""; | 291 | //<img src=\""; |
292 | // mText += ipath; | 292 | // mText += ipath; |
293 | // mText += "\">"; | 293 | // mText += "\">"; |
294 | mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 294 | mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
295 | mText += "<table>\n"; | 295 | mText += "<table>\n"; |
296 | } | 296 | } |
297 | replys++; | 297 | replys++; |
298 | appendEvent(to); | 298 | appendEvent(to); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | kdDebug () << "check for todo-replys..." << endl; | 301 | kdDebug () << "check for todo-replys..." << endl; |
302 | to = todos.next(); | 302 | to = todos.next(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | if (replys > 0 ) mText += "</table>\n"; | 305 | if (replys > 0 ) mText += "</table>\n"; |
306 | 306 | ||
307 | 307 | ||
308 | mText += "</td></tr>\n</table>\n"; | 308 | mText += "</td></tr>\n</table>\n"; |
309 | 309 | ||
310 | kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl; | 310 | kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl; |
311 | mView->setText(mText); | 311 | mView->setText(mText); |
312 | mView->setFocus(); | 312 | mView->setFocus(); |
313 | 313 | ||
314 | // QPixmap bPix = SmallIcon( "back" ); | 314 | // QPixmap bPix = SmallIcon( "back" ); |
315 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 315 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
316 | // QWidget* test = new QWidget(); | 316 | // QWidget* test = new QWidget(); |
317 | // test->setBackgroundMode(FixedPixmap ); | 317 | // test->setBackgroundMode(FixedPixmap ); |
318 | // test->setBackgroundPixmap ( bPix ); | 318 | // test->setBackgroundPixmap ( bPix ); |
319 | // test->resize( 300, 400 ); | 319 | // test->resize( 300, 400 ); |
320 | // test->show(); | 320 | // test->show(); |
321 | // mView->setBackgroundMode(FixedPixmap ); | 321 | // mView->setBackgroundMode(FixedPixmap ); |
322 | // mView->setBackgroundPixmap ( bPix ); | 322 | // mView->setBackgroundPixmap ( bPix ); |
323 | } | 323 | } |
324 | 324 | ||
325 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 325 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
326 | { | 326 | { |
327 | QString date; | 327 | QString date; |
328 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 328 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
329 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 329 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
330 | if ( i == 0 ) { | 330 | if ( i == 0 ) { |
331 | mText += "<table>\n"; | 331 | mText += "<table>\n"; |
332 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 332 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
333 | } | 333 | } |
334 | else if ( i == 1 ) | 334 | else if ( i == 1 ) |
335 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 335 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
336 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 336 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
337 | //mText += "<h2>" + date + "</h2>\n"; | 337 | //mText += "<h2>" + date + "</h2>\n"; |
338 | mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 338 | mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
339 | mText += "<table>\n"; | 339 | mText += "<table>\n"; |
340 | 340 | ||
341 | 341 | ||
342 | 342 | ||
343 | } else { | 343 | } else { |
344 | if ( i == 0 ) { | 344 | if ( i == 0 ) { |
345 | mText += "<table>\n"; | 345 | mText += "<table>\n"; |
346 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 346 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
347 | } | 347 | } |
348 | 348 | ||
349 | #ifdef DESKTOP_VERSION | 349 | #ifdef DESKTOP_VERSION |
350 | else if ( i == 1 ) { | 350 | else if ( i == 1 ) { |
351 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 351 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
352 | } | 352 | } |
353 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 353 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
354 | #else | 354 | #else |
355 | else if ( i == 1 ) { | 355 | else if ( i == 1 ) { |
356 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 356 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
357 | } | 357 | } |
358 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 358 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
359 | 359 | ||
360 | #endif | 360 | #endif |
361 | //mText += "<h2>" + date + "</h2>\n"; | 361 | //mText += "<h2>" + date + "</h2>\n"; |
362 | mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 362 | mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
363 | mText += "<table>\n"; | 363 | mText += "<table>\n"; |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 368 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
369 | { | 369 | { |
370 | updateView(); | 370 | updateView(); |
371 | } | 371 | } |
372 | 372 | ||
373 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 373 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
374 | { | 374 | { |
375 | } | 375 | } |
376 | 376 | ||
377 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 377 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
378 | { | 378 | { |
379 | switch(action) { | 379 | switch(action) { |
380 | case KOGlobals::EVENTADDED: | 380 | case KOGlobals::EVENTADDED: |
381 | updateView(); | 381 | updateView(); |
382 | break; | 382 | break; |
383 | case KOGlobals::EVENTEDITED: | 383 | case KOGlobals::EVENTEDITED: |
384 | updateView(); | 384 | updateView(); |
385 | break; | 385 | break; |
386 | case KOGlobals::EVENTDELETED: | 386 | case KOGlobals::EVENTDELETED: |
387 | updateView(); | 387 | updateView(); |
388 | break; | 388 | break; |
389 | default: | 389 | default: |
390 | updateView(); | 390 | updateView(); |
391 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 391 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) | 395 | void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) |
396 | { | 396 | { |
397 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") ) | 397 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") ) |
398 | return; | 398 | return; |
399 | QDateTime cdt = QDateTime::currentDateTime(); | 399 | QDateTime cdt = QDateTime::currentDateTime(); |
400 | mText += "<tr><td><b>"; | 400 | mText += "<tr><td><b>"; |
401 | if (ev->type()=="Event") { | 401 | if (ev->type()=="Event") { |
402 | 402 | ||
403 | if (!ev->doesFloat()) { | 403 | if (!ev->doesFloat()) { |
404 | Event *event = static_cast<Event *>(ev); | 404 | Event *event = static_cast<Event *>(ev); |
405 | QDateTime st,end; | 405 | QDateTime st,end; |
406 | if ( event->recurrence()->doesRecur() ) { | 406 | if ( event->recurrence()->doesRecur() ) { |
407 | QDate recDate= mEventDate; | 407 | QDate recDate= mEventDate; |
408 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 408 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
409 | while ( ! event->recursOn( recDate ) ) { | 409 | while ( ! event->recursOn( recDate ) ) { |
410 | recDate = recDate.addDays( -1 ); | 410 | recDate = recDate.addDays( -1 ); |
411 | 411 | ||
412 | } | 412 | } |
413 | st = QDateTime ( recDate, event->dtStart().time() ); | 413 | st = QDateTime ( recDate, event->dtStart().time() ); |
414 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 414 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
415 | } | 415 | } |
416 | else { | 416 | else { |
417 | st = event->dtStart(); | 417 | st = event->dtStart(); |
418 | end = event->dtEnd(); | 418 | end = event->dtEnd(); |
419 | } | 419 | } |
420 | 420 | ||
421 | if (reply) mText += "on " + event->dtStartDateStr() + ": "; | 421 | if (reply) mText += "on " + event->dtStartDateStr() + ": "; |
422 | QString dateText; | 422 | QString dateText; |
423 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 423 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
424 | if ( st.date() < mEventDate ) | 424 | if ( st.date() < mEventDate ) |
425 | dateText = "++:++-"; | 425 | dateText = "++:++-"; |
426 | else | 426 | else |
427 | dateText = event->dtStartTimeStr() + "-"; | 427 | dateText = event->dtStartTimeStr() + "-"; |
428 | if ( end.date() > mEventDate ) | 428 | if ( end.date() > mEventDate ) |
429 | dateText += "++:++"; | 429 | dateText += "++:++"; |
430 | else | 430 | else |
431 | dateText += event->dtEndTimeStr(); | 431 | dateText += event->dtEndTimeStr(); |
432 | if ( notRed ) | 432 | if ( notRed ) |
433 | mText += dateText; | 433 | mText += dateText; |
434 | else { | 434 | else { |
435 | if ( end < cdt ) | 435 | if ( end < cdt ) |
436 | mText += "<font color=\"#F00000\">" + dateText + "</font>"; | 436 | mText += "<font color=\"#F00000\">" + dateText + "</font>"; |
437 | else if ( st < cdt ) | 437 | else if ( st < cdt ) |
438 | mText += "<font color=\"#008000\">" + dateText + "</font>"; | 438 | mText += "<font color=\"#008000\">" + dateText + "</font>"; |
439 | else | 439 | else |
440 | mText += dateText; | 440 | mText += dateText; |
441 | } | 441 | } |
442 | 442 | ||
443 | } else { | 443 | } else { |
444 | mText += i18n("Allday:"); | 444 | mText += i18n("Allday:"); |
445 | 445 | ||
446 | } | 446 | } |
447 | } else { | 447 | } else { |
448 | mTodos.append( ev ); | 448 | mTodos.append( ev ); |
449 | mText += i18n("ToDo:"); | 449 | mText += i18n("ToDo:"); |
450 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 450 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
451 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 451 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
452 | QString dfs = KGlobal::locale()->dateFormatShort(); | 452 | QString dfs = KGlobal::locale()->dateFormatShort(); |
453 | KGlobal::locale()->setIntDateFormat( 3 ); | ||
454 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 453 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
455 | mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>"; | 454 | mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
456 | |||
457 | KGlobal::locale()->setDateFormatShort(dfs); | 455 | KGlobal::locale()->setDateFormatShort(dfs); |
458 | KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); | ||
459 | } else { | 456 | } else { |
460 | if (!ev->doesFloat() ) | 457 | if (!ev->doesFloat() ) |
461 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 458 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
462 | mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 459 | mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
463 | 460 | ||
464 | 461 | ||
465 | } else | 462 | } else |
466 | mText +=((Todo*)ev)->dtDueTimeStr(); | 463 | mText +=((Todo*)ev)->dtDueTimeStr(); |
467 | mTodos.append( ev ); | 464 | mTodos.append( ev ); |
468 | } | 465 | } |
469 | } | 466 | } |
470 | mText += "</b></td><td>"; | 467 | mText += "</b></td><td>"; |
471 | bool needClose = false; | 468 | bool needClose = false; |
472 | if ( ev->cancelled() ) { | 469 | if ( ev->cancelled() ) { |
473 | mText += "<font color=\"#F00000\">[c"; | 470 | mText += "<font color=\"#F00000\">[c"; |
474 | needClose =true; | 471 | needClose =true; |
475 | 472 | ||
476 | } | 473 | } |
477 | if ( ev->isAlarmEnabled() ) { | 474 | if ( ev->isAlarmEnabled() ) { |
478 | if ( !needClose) | 475 | if ( !needClose) |
479 | mText +="["; | 476 | mText +="["; |
480 | mText += "a"; | 477 | mText += "a"; |
481 | needClose =true; | 478 | needClose =true; |
482 | 479 | ||
483 | } | 480 | } |
484 | if ( ev->description().length() > 0 ) { | 481 | if ( ev->description().length() > 0 ) { |
485 | if ( !needClose) | 482 | if ( !needClose) |
486 | mText +="["; | 483 | mText +="["; |
487 | mText += "i"; | 484 | mText += "i"; |
488 | needClose =true; | 485 | needClose =true; |
489 | } | 486 | } |
490 | if ( ev->recurrence()->doesRecur() ) { | 487 | if ( ev->recurrence()->doesRecur() ) { |
491 | if ( !needClose) | 488 | if ( !needClose) |
492 | mText +="["; | 489 | mText +="["; |
493 | mText += "r"; | 490 | mText += "r"; |
494 | needClose =true; | 491 | needClose =true; |
495 | } | 492 | } |
496 | if ( needClose ) { | 493 | if ( needClose ) { |
497 | mText += "] "; | 494 | mText += "] "; |
498 | } | 495 | } |
499 | if ( ev->cancelled() ) | 496 | if ( ev->cancelled() ) |
500 | mText += "</font>"; | 497 | mText += "</font>"; |
501 | mText += "<a "; | 498 | mText += "<a "; |
502 | if (ev->type()=="Event") mText += "href=\"event:"; | 499 | if (ev->type()=="Event") mText += "href=\"event:"; |
503 | if (ev->type()=="Todo") mText += "href=\"todo:"; | 500 | if (ev->type()=="Todo") mText += "href=\"todo:"; |
504 | mText += ev->uid() + "\">"; | 501 | mText += ev->uid() + "\">"; |
505 | if ( ev->summary().length() > 0 ) | 502 | if ( ev->summary().length() > 0 ) |
506 | mText += ev->summary(); | 503 | mText += ev->summary(); |
507 | else | 504 | else |
508 | mText += i18n("-no summary-"); | 505 | mText += i18n("-no summary-"); |
509 | mText += "</a>"; | 506 | mText += "</a>"; |
510 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 507 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
511 | if ( !ev->location().isEmpty() ) | 508 | if ( !ev->location().isEmpty() ) |
512 | mText += " ("+ev->location() +")"; | 509 | mText += " ("+ev->location() +")"; |
513 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 510 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
514 | mText += " ["+ev->relatedTo()->summary() +"]"; | 511 | mText += " ["+ev->relatedTo()->summary() +"]"; |
515 | mText += "</td></tr>\n"; | 512 | mText += "</td></tr>\n"; |
516 | } | 513 | } |
517 | 514 | ||
518 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 515 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
519 | { | 516 | { |
520 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 517 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
521 | 518 | ||
522 | mTodos.append( ev ); | 519 | mTodos.append( ev ); |
523 | if ( !isSub ) | 520 | if ( !isSub ) |
524 | mText += "<p>"; | 521 | mText += "<p>"; |
525 | else | 522 | else |
526 | mText += "<li>"; | 523 | mText += "<li>"; |
527 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 524 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
528 | 525 | ||
529 | 526 | ||
530 | mText += ind; | 527 | mText += ind; |
531 | bool needClose = false; | 528 | bool needClose = false; |
532 | if ( ev->cancelled() ) { | 529 | if ( ev->cancelled() ) { |
533 | mText += "<font color=\"#F00000\">[c"; | 530 | mText += "<font color=\"#F00000\">[c"; |
534 | needClose =true; | 531 | needClose =true; |
535 | 532 | ||
536 | } | 533 | } |
537 | if ( ev->isAlarmEnabled() ) { | 534 | if ( ev->isAlarmEnabled() ) { |
538 | if ( !needClose) | 535 | if ( !needClose) |
539 | mText +="["; | 536 | mText +="["; |
540 | mText += "a"; | 537 | mText += "a"; |
541 | needClose =true; | 538 | needClose =true; |
542 | 539 | ||
543 | } | 540 | } |
544 | 541 | ||
545 | if ( ev->description().length() > 0 ) { | 542 | if ( ev->description().length() > 0 ) { |
546 | if ( !needClose) | 543 | if ( !needClose) |
547 | mText +="["; | 544 | mText +="["; |
548 | mText += "i"; | 545 | mText += "i"; |
549 | needClose =true; | 546 | needClose =true; |
550 | } | 547 | } |
551 | // if ( ev->recurrence()->doesRecur() ) { | 548 | // if ( ev->recurrence()->doesRecur() ) { |
552 | // if ( !needClose) | 549 | // if ( !needClose) |
553 | // mText +="("; | 550 | // mText +="("; |
554 | // mText += "r"; | 551 | // mText += "r"; |
555 | // needClose =true; | 552 | // needClose =true; |
556 | // } | 553 | // } |
557 | if ( needClose ) | 554 | if ( needClose ) |
558 | mText += "] "; | 555 | mText += "] "; |
559 | if ( ev->cancelled() ) | 556 | if ( ev->cancelled() ) |
560 | mText += "</font>"; | 557 | mText += "</font>"; |
561 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 558 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
562 | mText += ev->summary(); | 559 | mText += ev->summary(); |
563 | mText += "</a>"; | 560 | mText += "</a>"; |
564 | if ( ((Todo*)ev)->hasDueDate () ) { | 561 | if ( ((Todo*)ev)->hasDueDate () ) { |
565 | QString year = ""; | 562 | QString year = ""; |
566 | int ye = ((Todo*)ev)->dtDue().date().year(); | 563 | int ye = ((Todo*)ev)->dtDue().date().year(); |
567 | if ( QDateTime::currentDateTime().date().year() != ye ) | 564 | if ( QDateTime::currentDateTime().date().year() != ye ) |
568 | year = QString::number( ye ); | 565 | year = QString::number( ye ); |
569 | QString dfs = KGlobal::locale()->dateFormatShort(); | 566 | QString dfs = KGlobal::locale()->dateFormatShort(); |
570 | KGlobal::locale()->setIntDateFormat( 3 ); | ||
571 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 567 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
572 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>"; | 568 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
573 | |||
574 | KGlobal::locale()->setDateFormatShort(dfs); | 569 | KGlobal::locale()->setDateFormatShort(dfs); |
575 | KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); | ||
576 | } | 570 | } |
577 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 571 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
578 | if ( !ev->location().isEmpty() ) | 572 | if ( !ev->location().isEmpty() ) |
579 | mText += " ("+ev->location() +")"; | 573 | mText += " ("+ev->location() +")"; |
580 | if ( !isSub ) { | 574 | if ( !isSub ) { |
581 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 575 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
582 | mText += " ["+ev->relatedTo()->summary() +"]"; | 576 | mText += " ["+ev->relatedTo()->summary() +"]"; |
583 | mText += "</p>\n"; | 577 | mText += "</p>\n"; |
584 | } | 578 | } |
585 | else { | 579 | else { |
586 | ind += "-"; | 580 | ind += "-"; |
587 | mText += "</li>\n"; | 581 | mText += "</li>\n"; |
588 | } | 582 | } |
589 | QPtrList<Incidence> Relations = ev->relations(); | 583 | QPtrList<Incidence> Relations = ev->relations(); |
590 | Incidence *to; | 584 | Incidence *to; |
591 | for (to=Relations.first();to;to=Relations.next()) { | 585 | for (to=Relations.first();to;to=Relations.next()) { |
592 | if (!((Todo*)to)->isCompleted()) | 586 | if (!((Todo*)to)->isCompleted()) |
593 | appendTodo( to, ind , true ); | 587 | appendTodo( to, ind , true ); |
594 | } | 588 | } |
595 | 589 | ||
596 | return true; | 590 | return true; |
597 | } | 591 | } |
598 | 592 | ||
599 | /* | 593 | /* |
600 | void KOWhatsNextView::createEventViewer() | 594 | void KOWhatsNextView::createEventViewer() |
601 | { | 595 | { |
602 | if (!mEventViewer) { | 596 | if (!mEventViewer) { |
603 | 597 | ||
604 | mEventViewer = new KOEventViewerDialog(this); | 598 | mEventViewer = new KOEventViewerDialog(this); |
605 | } | 599 | } |
606 | } | 600 | } |
607 | */ | 601 | */ |
608 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 602 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
609 | { | 603 | { |
610 | if ( mEventViewer ) | 604 | if ( mEventViewer ) |
611 | delete mEventViewer; | 605 | delete mEventViewer; |
612 | mEventViewer = v; | 606 | mEventViewer = v; |
613 | } | 607 | } |
614 | 608 | ||
615 | // TODO: Create this function in CalendarView and remove it from here | 609 | // TODO: Create this function in CalendarView and remove it from here |
616 | void KOWhatsNextView::showIncidence(const QString &uid) | 610 | void KOWhatsNextView::showIncidence(const QString &uid) |
617 | { | 611 | { |
618 | if ( !mEventViewer ) { | 612 | if ( !mEventViewer ) { |
619 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 613 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
620 | return; | 614 | return; |
621 | } | 615 | } |
622 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 616 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
623 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 617 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
624 | if (uid.startsWith("event:")) { | 618 | if (uid.startsWith("event:")) { |
625 | #ifdef DESKTOP_VERSION | 619 | #ifdef DESKTOP_VERSION |
626 | Event *event = calendar()->event(uid.mid(8)); | 620 | Event *event = calendar()->event(uid.mid(8)); |
627 | #else | 621 | #else |
628 | Event *event = calendar()->event(uid.mid(6)); | 622 | Event *event = calendar()->event(uid.mid(6)); |
629 | #endif | 623 | #endif |
630 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 624 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
631 | if (!event) return; | 625 | if (!event) return; |
632 | //createEventViewer(); | 626 | //createEventViewer(); |
633 | mEventViewer->setEvent(event); | 627 | mEventViewer->setEvent(event); |
634 | } else if (uid.startsWith("todo:")) { | 628 | } else if (uid.startsWith("todo:")) { |
635 | #ifdef DESKTOP_VERSION | 629 | #ifdef DESKTOP_VERSION |
636 | Todo *todo = calendar()->todo(uid.mid(7)); | 630 | Todo *todo = calendar()->todo(uid.mid(7)); |
637 | #else | 631 | #else |
638 | Todo *todo = calendar()->todo(uid.mid(5)); | 632 | Todo *todo = calendar()->todo(uid.mid(5)); |
639 | #endif | 633 | #endif |
640 | if (!todo) return; | 634 | if (!todo) return; |
641 | //createEventViewer(); | 635 | //createEventViewer(); |
642 | mEventViewer->setTodo(todo); | 636 | mEventViewer->setTodo(todo); |
643 | } else { | 637 | } else { |
644 | return; | 638 | return; |
645 | 639 | ||
646 | } | 640 | } |
647 | mEventViewer->showMe(); | 641 | mEventViewer->showMe(); |
648 | mEventViewer->raise(); | 642 | mEventViewer->raise(); |
649 | } | 643 | } |
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d77e251..9d7e60b 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,881 +1,884 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | 3 | ||
4 | #include "kdebug.h" | 4 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 5 | #include "kcalendarsystemgregorian.h" |
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | 8 | ||
9 | 9 | ||
10 | QDict<QString> *mLocaleDict = 0; | 10 | QDict<QString> *mLocaleDict = 0; |
11 | void setLocaleDict( QDict<QString> * dict ) | 11 | void setLocaleDict( QDict<QString> * dict ) |
12 | { | 12 | { |
13 | mLocaleDict = dict; | 13 | mLocaleDict = dict; |
14 | 14 | ||
15 | } | 15 | } |
16 | QString i18n(const char *text) | 16 | QString i18n(const char *text) |
17 | { | 17 | { |
18 | if ( ! mLocaleDict ) | 18 | if ( ! mLocaleDict ) |
19 | return QString( text ); | 19 | return QString( text ); |
20 | else { | 20 | else { |
21 | QString* ret = mLocaleDict->find(QString(text)) ; | 21 | QString* ret = mLocaleDict->find(QString(text)) ; |
22 | if ( ret == 0 ) { | 22 | if ( ret == 0 ) { |
23 | return QString( text ); | 23 | return QString( text ); |
24 | } | 24 | } |
25 | else { | 25 | else { |
26 | if ( (*ret).isEmpty() ) | 26 | if ( (*ret).isEmpty() ) |
27 | return QString( text ); | 27 | return QString( text ); |
28 | else | 28 | else |
29 | return (*ret); | 29 | return (*ret); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | } | 33 | } |
34 | 34 | ||
35 | QString i18n(const char *,const char *text) | 35 | QString i18n(const char *,const char *text) |
36 | { | 36 | { |
37 | return i18n( text ); | 37 | return i18n( text ); |
38 | } | 38 | } |
39 | 39 | ||
40 | QString i18n(const char *text1, const char *textn, int num) | 40 | QString i18n(const char *text1, const char *textn, int num) |
41 | { | 41 | { |
42 | if ( num == 1 ) return i18n( text1 ); | 42 | if ( num == 1 ) return i18n( text1 ); |
43 | else { | 43 | else { |
44 | QString text = i18n( textn ); | 44 | QString text = i18n( textn ); |
45 | int pos = text.find( "%n" ); | 45 | int pos = text.find( "%n" ); |
46 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 46 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
47 | return text; | 47 | return text; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 51 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
52 | { | 52 | { |
53 | for ( uint l = 0; l < s.length(); l++ ) | 53 | for ( uint l = 0; l < s.length(); l++ ) |
54 | buffer[index++] = s.at( l ); | 54 | buffer[index++] = s.at( l ); |
55 | } | 55 | } |
56 | 56 | ||
57 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 57 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
58 | { | 58 | { |
59 | buffer[index++] = number / 10 + '0'; | 59 | buffer[index++] = number / 10 + '0'; |
60 | buffer[index++] = number % 10 + '0'; | 60 | buffer[index++] = number % 10 + '0'; |
61 | } | 61 | } |
62 | 62 | ||
63 | static int readInt(const QString &str, uint &pos) | 63 | static int readInt(const QString &str, uint &pos) |
64 | { | 64 | { |
65 | if (!str.at(pos).isDigit()) return -1; | 65 | if (!str.at(pos).isDigit()) return -1; |
66 | int result = 0; | 66 | int result = 0; |
67 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 67 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
68 | { | 68 | { |
69 | result *= 10; | 69 | result *= 10; |
70 | result += str.at(pos).digitValue(); | 70 | result += str.at(pos).digitValue(); |
71 | } | 71 | } |
72 | 72 | ||
73 | return result; | 73 | return result; |
74 | } | 74 | } |
75 | 75 | ||
76 | KLocale::KLocale() : mCalendarSystem( 0 ) | 76 | KLocale::KLocale() : mCalendarSystem( 0 ) |
77 | { | 77 | { |
78 | 78 | ||
79 | m_decimalSymbol = "."; | 79 | m_decimalSymbol = "."; |
80 | m_positiveSign = ""; | 80 | m_positiveSign = ""; |
81 | m_negativeSign = "-"; | 81 | m_negativeSign = "-"; |
82 | m_thousandsSeparator = ","; | 82 | m_thousandsSeparator = ","; |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | mWeekStartsMonday = true; | 87 | mWeekStartsMonday = true; |
88 | mHourF24Format = true; | 88 | mHourF24Format = true; |
89 | mIntDateFormat = 0; | 89 | mIntDateFormat = Default; |
90 | mLanguage = 0; | 90 | mLanguage = 0; |
91 | mDateFormat = "%a %Y %b %d"; | 91 | mDateFormat = "%a %Y %b %d"; |
92 | mDateFormatShort = "%Y-%m-%d"; | 92 | mDateFormatShort = "%Y-%m-%d"; |
93 | mTimeZoneList << i18n ("-11:00 US/Samoa") | 93 | mTimeZoneList << i18n ("-11:00 US/Samoa") |
94 | << i18n ("-10:00 US/Hawaii") | 94 | << i18n ("-10:00 US/Hawaii") |
95 | << i18n ("-09:00 US/Alaska") | 95 | << i18n ("-09:00 US/Alaska") |
96 | << i18n ("-08:00 US/Pacific") | 96 | << i18n ("-08:00 US/Pacific") |
97 | << i18n ("-07:00 US/Mountain") | 97 | << i18n ("-07:00 US/Mountain") |
98 | << i18n ("-06:00 US/Central") | 98 | << i18n ("-06:00 US/Central") |
99 | << i18n ("-05:00 US/Eastern") | 99 | << i18n ("-05:00 US/Eastern") |
100 | << i18n ("-04:00 Brazil/West") | 100 | << i18n ("-04:00 Brazil/West") |
101 | << i18n ("-03:00 Brazil/East") | 101 | << i18n ("-03:00 Brazil/East") |
102 | << i18n ("-02:00 Brazil/DeNoronha") | 102 | << i18n ("-02:00 Brazil/DeNoronha") |
103 | << i18n ("-01:00 Atlantic/Azores") | 103 | << i18n ("-01:00 Atlantic/Azores") |
104 | << i18n (" 00:00 Europe/London(UTC)") | 104 | << i18n (" 00:00 Europe/London(UTC)") |
105 | << i18n ("+01:00 Europe/Oslo(CET)") | 105 | << i18n ("+01:00 Europe/Oslo(CET)") |
106 | << i18n ("+02:00 Europe/Helsinki") | 106 | << i18n ("+02:00 Europe/Helsinki") |
107 | << i18n ("+03:00 Europe/Moscow") | 107 | << i18n ("+03:00 Europe/Moscow") |
108 | << i18n ("+04:00 Indian/Mauritius") | 108 | << i18n ("+04:00 Indian/Mauritius") |
109 | << i18n ("+05:00 Indian/Maldives") | 109 | << i18n ("+05:00 Indian/Maldives") |
110 | << i18n ("+06:00 Indian/Chagos") | 110 | << i18n ("+06:00 Indian/Chagos") |
111 | << i18n ("+07:00 Asia/Bangkok") | 111 | << i18n ("+07:00 Asia/Bangkok") |
112 | << i18n ("+08:00 Asia/Hongkong") | 112 | << i18n ("+08:00 Asia/Hongkong") |
113 | << i18n ("+09:00 Asia/Tokyo") | 113 | << i18n ("+09:00 Asia/Tokyo") |
114 | << i18n ("+10:00 Asia/Vladivostok") | 114 | << i18n ("+10:00 Asia/Vladivostok") |
115 | << i18n ("+11:00 Asia/Magadan") | 115 | << i18n ("+11:00 Asia/Magadan") |
116 | << i18n ("+12:00 Asia/Kamchatka") | 116 | << i18n ("+12:00 Asia/Kamchatka") |
117 | // << i18n (" xx:xx User defined offset") | 117 | // << i18n (" xx:xx User defined offset") |
118 | << i18n (" Local Time"); | 118 | << i18n (" Local Time"); |
119 | mSouthDaylight = false; | 119 | mSouthDaylight = false; |
120 | mTimeZoneOffset = 0; | 120 | mTimeZoneOffset = 0; |
121 | daylightEnabled = false; | 121 | daylightEnabled = false; |
122 | } | 122 | } |
123 | 123 | ||
124 | void KLocale::setDateFormat( QString s ) | 124 | void KLocale::setDateFormat( QString s ) |
125 | { | 125 | { |
126 | mDateFormat = s; | 126 | mDateFormat = s; |
127 | } | 127 | } |
128 | 128 | ||
129 | void KLocale::setDateFormatShort( QString s ) | 129 | void KLocale::setDateFormatShort( QString s ) |
130 | { | 130 | { |
131 | mDateFormatShort = s; | 131 | mDateFormatShort = s; |
132 | } | 132 | } |
133 | 133 | ||
134 | void KLocale::setHore24Format ( bool b ) | 134 | void KLocale::setHore24Format ( bool b ) |
135 | { | 135 | { |
136 | mHourF24Format = b; | 136 | mHourF24Format = b; |
137 | } | 137 | } |
138 | void KLocale::setWeekStartMonday( bool b ) | 138 | void KLocale::setWeekStartMonday( bool b ) |
139 | { | 139 | { |
140 | mWeekStartsMonday = b; | 140 | mWeekStartsMonday = b; |
141 | } | 141 | } |
142 | int KLocale::getIntDateFormat( ) | 142 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
143 | { | 143 | { |
144 | return mIntDateFormat ; | 144 | return mIntDateFormat; |
145 | 145 | ||
146 | } | 146 | } |
147 | void KLocale::setIntDateFormat( int i ) | 147 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) |
148 | { | 148 | { |
149 | mIntDateFormat = i; | 149 | mIntDateFormat = i; |
150 | } | 150 | } |
151 | void KLocale::setLanguage( int i ) | 151 | void KLocale::setLanguage( int i ) |
152 | { | 152 | { |
153 | mLanguage = i; | 153 | mLanguage = i; |
154 | } | 154 | } |
155 | QString KLocale::translate( const char *index ) const | 155 | QString KLocale::translate( const char *index ) const |
156 | { | 156 | { |
157 | return i18n( index ); | 157 | return i18n( index ); |
158 | } | 158 | } |
159 | 159 | ||
160 | QString KLocale::translate( const char *, const char *fallback) const | 160 | QString KLocale::translate( const char *, const char *fallback) const |
161 | { | 161 | { |
162 | return i18n( fallback ); | 162 | return i18n( fallback ); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const | 165 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const |
166 | { | 166 | { |
167 | const QString rst = timeFormat(); | 167 | const QString rst = timeFormat(); |
168 | 168 | ||
169 | // only "pm/am" here can grow, the rest shrinks, but | 169 | // only "pm/am" here can grow, the rest shrinks, but |
170 | // I'm rather safe than sorry | 170 | // I'm rather safe than sorry |
171 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | 171 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; |
172 | 172 | ||
173 | uint index = 0; | 173 | uint index = 0; |
174 | bool escape = false; | 174 | bool escape = false; |
175 | int number = 0; | 175 | int number = 0; |
176 | 176 | ||
177 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | 177 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) |
178 | { | 178 | { |
179 | if ( !escape ) | 179 | if ( !escape ) |
180 | { | 180 | { |
181 | if ( rst.at( format_index ).unicode() == '%' ) | 181 | if ( rst.at( format_index ).unicode() == '%' ) |
182 | escape = true; | 182 | escape = true; |
183 | else | 183 | else |
184 | buffer[index++] = rst.at( format_index ); | 184 | buffer[index++] = rst.at( format_index ); |
185 | } | 185 | } |
186 | else | 186 | else |
187 | { | 187 | { |
188 | switch ( rst.at( format_index ).unicode() ) | 188 | switch ( rst.at( format_index ).unicode() ) |
189 | { | 189 | { |
190 | case '%': | 190 | case '%': |
191 | buffer[index++] = '%'; | 191 | buffer[index++] = '%'; |
192 | break; | 192 | break; |
193 | case 'H': | 193 | case 'H': |
194 | put_it_in( buffer, index, pTime.hour() ); | 194 | put_it_in( buffer, index, pTime.hour() ); |
195 | break; | 195 | break; |
196 | case 'I': | 196 | case 'I': |
197 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | 197 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); |
198 | break; | 198 | break; |
199 | case 'M': | 199 | case 'M': |
200 | put_it_in( buffer, index, pTime.minute() ); | 200 | put_it_in( buffer, index, pTime.minute() ); |
201 | break; | 201 | break; |
202 | case 'S': | 202 | case 'S': |
203 | if (includeSecs) | 203 | if (includeSecs) |
204 | put_it_in( buffer, index, pTime.second() ); | 204 | put_it_in( buffer, index, pTime.second() ); |
205 | else | 205 | else |
206 | { | 206 | { |
207 | // we remove the seperator sign before the seconds and | 207 | // we remove the seperator sign before the seconds and |
208 | // assume that works everywhere | 208 | // assume that works everywhere |
209 | --index; | 209 | --index; |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | break; | 212 | break; |
213 | case 'k': | 213 | case 'k': |
214 | number = pTime.hour(); | 214 | number = pTime.hour(); |
215 | case 'l': | 215 | case 'l': |
216 | // to share the code | 216 | // to share the code |
217 | if ( rst.at( format_index ).unicode() == 'l' ) | 217 | if ( rst.at( format_index ).unicode() == 'l' ) |
218 | number = (pTime.hour() + 11) % 12 + 1; | 218 | number = (pTime.hour() + 11) % 12 + 1; |
219 | if ( number / 10 ) | 219 | if ( number / 10 ) |
220 | buffer[index++] = number / 10 + '0'; | 220 | buffer[index++] = number / 10 + '0'; |
221 | buffer[index++] = number % 10 + '0'; | 221 | buffer[index++] = number % 10 + '0'; |
222 | break; | 222 | break; |
223 | case 'p': | 223 | case 'p': |
224 | { | 224 | { |
225 | QString s; | 225 | QString s; |
226 | if ( pTime.hour() >= 12 ) | 226 | if ( pTime.hour() >= 12 ) |
227 | put_it_in( buffer, index, i18n("pm") ); | 227 | put_it_in( buffer, index, i18n("pm") ); |
228 | else | 228 | else |
229 | put_it_in( buffer, index, i18n("am") ); | 229 | put_it_in( buffer, index, i18n("am") ); |
230 | break; | 230 | break; |
231 | } | 231 | } |
232 | default: | 232 | default: |
233 | buffer[index++] = rst.at( format_index ); | 233 | buffer[index++] = rst.at( format_index ); |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | escape = false; | 236 | escape = false; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | QString ret( buffer, index ); | 239 | QString ret( buffer, index ); |
240 | delete [] buffer; | 240 | delete [] buffer; |
241 | return ret; | 241 | return ret; |
242 | } | 242 | } |
243 | 243 | ||
244 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const | 244 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const |
245 | { | 245 | { |
246 | const QString rst = shortFormat?dateFormatShort():dateFormat(); | 246 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); |
247 | 247 | ||
248 | // I'm rather safe than sorry | 248 | // I'm rather safe than sorry |
249 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; | 249 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; |
250 | 250 | ||
251 | unsigned int index = 0; | 251 | unsigned int index = 0; |
252 | bool escape = false; | 252 | bool escape = false; |
253 | int number = 0; | 253 | int number = 0; |
254 | 254 | ||
255 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) | 255 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) |
256 | { | 256 | { |
257 | if ( !escape ) | 257 | if ( !escape ) |
258 | { | 258 | { |
259 | if ( rst.at( format_index ).unicode() == '%' ) | 259 | if ( rst.at( format_index ).unicode() == '%' ) |
260 | escape = true; | 260 | escape = true; |
261 | else | 261 | else |
262 | buffer[index++] = rst.at( format_index ); | 262 | buffer[index++] = rst.at( format_index ); |
263 | } | 263 | } |
264 | else | 264 | else |
265 | { | 265 | { |
266 | switch ( rst.at( format_index ).unicode() ) | 266 | switch ( rst.at( format_index ).unicode() ) |
267 | { | 267 | { |
268 | case '%': | 268 | case '%': |
269 | buffer[index++] = '%'; | 269 | buffer[index++] = '%'; |
270 | break; | 270 | break; |
271 | case 'Y': | 271 | case 'Y': |
272 | put_it_in( buffer, index, pDate.year() / 100 ); | 272 | put_it_in( buffer, index, pDate.year() / 100 ); |
273 | case 'y': | 273 | case 'y': |
274 | put_it_in( buffer, index, pDate.year() % 100 ); | 274 | put_it_in( buffer, index, pDate.year() % 100 ); |
275 | break; | 275 | break; |
276 | case 'n': | 276 | case 'n': |
277 | number = pDate.month(); | 277 | number = pDate.month(); |
278 | case 'e': | 278 | case 'e': |
279 | // to share the code | 279 | // to share the code |
280 | if ( rst.at( format_index ).unicode() == 'e' ) | 280 | if ( rst.at( format_index ).unicode() == 'e' ) |
281 | number = pDate.day(); | 281 | number = pDate.day(); |
282 | if ( number / 10 ) | 282 | if ( number / 10 ) |
283 | buffer[index++] = number / 10 + '0'; | 283 | buffer[index++] = number / 10 + '0'; |
284 | buffer[index++] = number % 10 + '0'; | 284 | buffer[index++] = number % 10 + '0'; |
285 | break; | 285 | break; |
286 | case 'm': | 286 | case 'm': |
287 | put_it_in( buffer, index, pDate.month() ); | 287 | put_it_in( buffer, index, pDate.month() ); |
288 | break; | 288 | break; |
289 | case 'b': | 289 | case 'b': |
290 | put_it_in( buffer, index, monthName(pDate.month(), true) ); | 290 | put_it_in( buffer, index, monthName(pDate.month(), true) ); |
291 | break; | 291 | break; |
292 | case 'B': | 292 | case 'B': |
293 | put_it_in( buffer, index, monthName(pDate.month(), false) ); | 293 | put_it_in( buffer, index, monthName(pDate.month(), false) ); |
294 | break; | 294 | break; |
295 | case 'd': | 295 | case 'd': |
296 | put_it_in( buffer, index, pDate.day() ); | 296 | put_it_in( buffer, index, pDate.day() ); |
297 | break; | 297 | break; |
298 | case 'a': | 298 | case 'a': |
299 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); | 299 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); |
300 | break; | 300 | break; |
301 | case 'A': | 301 | case 'A': |
302 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); | 302 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); |
303 | break; | 303 | break; |
304 | default: | 304 | default: |
305 | buffer[index++] = rst.at( format_index ); | 305 | buffer[index++] = rst.at( format_index ); |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | escape = false; | 308 | escape = false; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | QString ret( buffer, index ); | 311 | QString ret( buffer, index ); |
312 | delete [] buffer; | 312 | delete [] buffer; |
313 | return ret; | 313 | return ret; |
314 | } | 314 | } |
315 | 315 | ||
316 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 316 | QString KLocale::formatDateTime(const QDateTime &pDateTime, |
317 | bool shortFormat, | 317 | bool shortFormat, |
318 | bool includeSeconds) const | 318 | bool includeSeconds) const |
319 | { | 319 | { |
320 | return QString( "%1 %2") | 320 | return QString( "%1 %2") |
321 | .arg( formatDate( pDateTime.date(), shortFormat ) ) | 321 | .arg( formatDate( pDateTime.date(), shortFormat ) ) |
322 | .arg( formatTime( pDateTime.time(), includeSeconds ) ); | 322 | .arg( formatTime( pDateTime.time(), includeSeconds ) ); |
323 | } | 323 | } |
324 | 324 | ||
325 | QString KLocale::formatDateTime(const QDateTime &pDateTime) const | 325 | QString KLocale::formatDateTime(const QDateTime &pDateTime) const |
326 | { | 326 | { |
327 | return formatDateTime(pDateTime, true); | 327 | return formatDateTime(pDateTime, true); |
328 | } | 328 | } |
329 | 329 | ||
330 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 330 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
331 | { | 331 | { |
332 | QDate date; | 332 | QDate date; |
333 | date = readDate(intstr, true, ok); | 333 | date = readDate(intstr, true, ok); |
334 | if (date.isValid()) return date; | 334 | if (date.isValid()) return date; |
335 | return readDate(intstr, false, ok); | 335 | return readDate(intstr, false, ok); |
336 | } | 336 | } |
337 | 337 | ||
338 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | 338 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const |
339 | { | 339 | { |
340 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | 340 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); |
341 | return readDate( intstr, fmt, ok ); | 341 | return readDate( intstr, fmt, ok ); |
342 | } | 342 | } |
343 | 343 | ||
344 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const | 344 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const |
345 | { | 345 | { |
346 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; | 346 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; |
347 | QString str = intstr.simplifyWhiteSpace().lower(); | 347 | QString str = intstr.simplifyWhiteSpace().lower(); |
348 | int day = -1, month = -1; | 348 | int day = -1, month = -1; |
349 | // allow the year to be omitted if not in the format | 349 | // allow the year to be omitted if not in the format |
350 | int year = QDate::currentDate().year(); | 350 | int year = QDate::currentDate().year(); |
351 | uint strpos = 0; | 351 | uint strpos = 0; |
352 | uint fmtpos = 0; | 352 | uint fmtpos = 0; |
353 | 353 | ||
354 | while (fmt.length() > fmtpos || str.length() > strpos) | 354 | while (fmt.length() > fmtpos || str.length() > strpos) |
355 | { | 355 | { |
356 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | 356 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) |
357 | goto error; | 357 | goto error; |
358 | 358 | ||
359 | QChar c = fmt.at(fmtpos++); | 359 | QChar c = fmt.at(fmtpos++); |
360 | 360 | ||
361 | if (c != '%') { | 361 | if (c != '%') { |
362 | if (c.isSpace()) | 362 | if (c.isSpace()) |
363 | strpos++; | 363 | strpos++; |
364 | else if (c != str.at(strpos++)) | 364 | else if (c != str.at(strpos++)) |
365 | goto error; | 365 | goto error; |
366 | continue; | 366 | continue; |
367 | } | 367 | } |
368 | 368 | ||
369 | // remove space at the begining | 369 | // remove space at the begining |
370 | if (str.length() > strpos && str.at(strpos).isSpace()) | 370 | if (str.length() > strpos && str.at(strpos).isSpace()) |
371 | strpos++; | 371 | strpos++; |
372 | 372 | ||
373 | c = fmt.at(fmtpos++); | 373 | c = fmt.at(fmtpos++); |
374 | switch (c) | 374 | switch (c) |
375 | { | 375 | { |
376 | case 'a': | 376 | case 'a': |
377 | case 'A': | 377 | case 'A': |
378 | // this will just be ignored | 378 | // this will just be ignored |
379 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 379 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
380 | for (int j = 1; j < 8; j++) { | 380 | for (int j = 1; j < 8; j++) { |
381 | QString s = weekDayName(j, c == 'a').lower(); | 381 | QString s = weekDayName(j, c == 'a').lower(); |
382 | int len = s.length(); | 382 | int len = s.length(); |
383 | if (str.mid(strpos, len) == s) | 383 | if (str.mid(strpos, len) == s) |
384 | strpos += len; | 384 | strpos += len; |
385 | } | 385 | } |
386 | break; | 386 | break; |
387 | } | 387 | } |
388 | case 'b': | 388 | case 'b': |
389 | case 'B': | 389 | case 'B': |
390 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 390 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
391 | for (int j = 1; j < 13; j++) { | 391 | for (int j = 1; j < 13; j++) { |
392 | QString s = monthName(j, c == 'b').lower(); | 392 | QString s = monthName(j, c == 'b').lower(); |
393 | int len = s.length(); | 393 | int len = s.length(); |
394 | if (str.mid(strpos, len) == s) { | 394 | if (str.mid(strpos, len) == s) { |
395 | month = j; | 395 | month = j; |
396 | strpos += len; | 396 | strpos += len; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | break; | 399 | break; |
400 | } | 400 | } |
401 | case 'd': | 401 | case 'd': |
402 | case 'e': | 402 | case 'e': |
403 | day = readInt(str, strpos); | 403 | day = readInt(str, strpos); |
404 | if (day < 1 || day > 31) | 404 | if (day < 1 || day > 31) |
405 | goto error; | 405 | goto error; |
406 | 406 | ||
407 | break; | 407 | break; |
408 | 408 | ||
409 | case 'n': | 409 | case 'n': |
410 | case 'm': | 410 | case 'm': |
411 | month = readInt(str, strpos); | 411 | month = readInt(str, strpos); |
412 | if (month < 1 || month > 12) | 412 | if (month < 1 || month > 12) |
413 | goto error; | 413 | goto error; |
414 | 414 | ||
415 | break; | 415 | break; |
416 | 416 | ||
417 | case 'Y': | 417 | case 'Y': |
418 | case 'y': | 418 | case 'y': |
419 | year = readInt(str, strpos); | 419 | year = readInt(str, strpos); |
420 | if (year < 0) | 420 | if (year < 0) |
421 | goto error; | 421 | goto error; |
422 | // Qt treats a year in the range 0-100 as 1900-1999. | 422 | // Qt treats a year in the range 0-100 as 1900-1999. |
423 | // It is nicer for the user if we treat 0-68 as 2000-2068 | 423 | // It is nicer for the user if we treat 0-68 as 2000-2068 |
424 | if (year < 69) | 424 | if (year < 69) |
425 | year += 2000; | 425 | year += 2000; |
426 | else if (c == 'y') | 426 | else if (c == 'y') |
427 | year += 1900; | 427 | year += 1900; |
428 | 428 | ||
429 | break; | 429 | break; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | 432 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; |
433 | if ( year != -1 && month != -1 && day != -1 ) | 433 | if ( year != -1 && month != -1 && day != -1 ) |
434 | { | 434 | { |
435 | if (ok) *ok = true; | 435 | if (ok) *ok = true; |
436 | return QDate(year, month, day); | 436 | return QDate(year, month, day); |
437 | } | 437 | } |
438 | error: | 438 | error: |
439 | if (ok) *ok = false; | 439 | if (ok) *ok = false; |
440 | return QDate(); // invalid date | 440 | return QDate(); // invalid date |
441 | } | 441 | } |
442 | 442 | ||
443 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | 443 | QTime KLocale::readTime(const QString &intstr, bool *ok) const |
444 | { | 444 | { |
445 | QTime _time; | 445 | QTime _time; |
446 | _time = readTime(intstr, true, ok); | 446 | _time = readTime(intstr, true, ok); |
447 | if (_time.isValid()) return _time; | 447 | if (_time.isValid()) return _time; |
448 | return readTime(intstr, false, ok); | 448 | return readTime(intstr, false, ok); |
449 | } | 449 | } |
450 | 450 | ||
451 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | 451 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const |
452 | { | 452 | { |
453 | QString str = intstr.simplifyWhiteSpace().lower(); | 453 | QString str = intstr.simplifyWhiteSpace().lower(); |
454 | QString Format = timeFormat().simplifyWhiteSpace(); | 454 | QString Format = timeFormat().simplifyWhiteSpace(); |
455 | if (!seconds) | 455 | if (!seconds) |
456 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 456 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
457 | 457 | ||
458 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 458 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
459 | bool g_12h = false; | 459 | bool g_12h = false; |
460 | bool pm = false; | 460 | bool pm = false; |
461 | uint strpos = 0; | 461 | uint strpos = 0; |
462 | uint Formatpos = 0; | 462 | uint Formatpos = 0; |
463 | 463 | ||
464 | while (Format.length() > Formatpos || str.length() > strpos) | 464 | while (Format.length() > Formatpos || str.length() > strpos) |
465 | { | 465 | { |
466 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | 466 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; |
467 | 467 | ||
468 | QChar c = Format.at(Formatpos++); | 468 | QChar c = Format.at(Formatpos++); |
469 | 469 | ||
470 | if (c != '%') | 470 | if (c != '%') |
471 | { | 471 | { |
472 | if (c.isSpace()) | 472 | if (c.isSpace()) |
473 | strpos++; | 473 | strpos++; |
474 | else if (c != str.at(strpos++)) | 474 | else if (c != str.at(strpos++)) |
475 | goto error; | 475 | goto error; |
476 | continue; | 476 | continue; |
477 | } | 477 | } |
478 | 478 | ||
479 | // remove space at the begining | 479 | // remove space at the begining |
480 | if (str.length() > strpos && str.at(strpos).isSpace()) | 480 | if (str.length() > strpos && str.at(strpos).isSpace()) |
481 | strpos++; | 481 | strpos++; |
482 | 482 | ||
483 | c = Format.at(Formatpos++); | 483 | c = Format.at(Formatpos++); |
484 | switch (c) | 484 | switch (c) |
485 | { | 485 | { |
486 | case 'p': | 486 | case 'p': |
487 | { | 487 | { |
488 | QString s; | 488 | QString s; |
489 | s = i18n("pm").lower(); | 489 | s = i18n("pm").lower(); |
490 | int len = s.length(); | 490 | int len = s.length(); |
491 | if (str.mid(strpos, len) == s) | 491 | if (str.mid(strpos, len) == s) |
492 | { | 492 | { |
493 | pm = true; | 493 | pm = true; |
494 | strpos += len; | 494 | strpos += len; |
495 | } | 495 | } |
496 | else | 496 | else |
497 | { | 497 | { |
498 | s = i18n("am").lower(); | 498 | s = i18n("am").lower(); |
499 | len = s.length(); | 499 | len = s.length(); |
500 | if (str.mid(strpos, len) == s) { | 500 | if (str.mid(strpos, len) == s) { |
501 | pm = false; | 501 | pm = false; |
502 | strpos += len; | 502 | strpos += len; |
503 | } | 503 | } |
504 | else | 504 | else |
505 | goto error; | 505 | goto error; |
506 | } | 506 | } |
507 | } | 507 | } |
508 | break; | 508 | break; |
509 | 509 | ||
510 | case 'k': | 510 | case 'k': |
511 | case 'H': | 511 | case 'H': |
512 | g_12h = false; | 512 | g_12h = false; |
513 | hour = readInt(str, strpos); | 513 | hour = readInt(str, strpos); |
514 | if (hour < 0 || hour > 23) | 514 | if (hour < 0 || hour > 23) |
515 | goto error; | 515 | goto error; |
516 | 516 | ||
517 | break; | 517 | break; |
518 | 518 | ||
519 | case 'l': | 519 | case 'l': |
520 | case 'I': | 520 | case 'I': |
521 | g_12h = true; | 521 | g_12h = true; |
522 | hour = readInt(str, strpos); | 522 | hour = readInt(str, strpos); |
523 | if (hour < 1 || hour > 12) | 523 | if (hour < 1 || hour > 12) |
524 | goto error; | 524 | goto error; |
525 | 525 | ||
526 | break; | 526 | break; |
527 | 527 | ||
528 | case 'M': | 528 | case 'M': |
529 | minute = readInt(str, strpos); | 529 | minute = readInt(str, strpos); |
530 | if (minute < 0 || minute > 59) | 530 | if (minute < 0 || minute > 59) |
531 | goto error; | 531 | goto error; |
532 | 532 | ||
533 | break; | 533 | break; |
534 | 534 | ||
535 | case 'S': | 535 | case 'S': |
536 | second = readInt(str, strpos); | 536 | second = readInt(str, strpos); |
537 | if (second < 0 || second > 59) | 537 | if (second < 0 || second > 59) |
538 | goto error; | 538 | goto error; |
539 | 539 | ||
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | } | 542 | } |
543 | if (g_12h) | 543 | if (g_12h) |
544 | { | 544 | { |
545 | hour %= 12; | 545 | hour %= 12; |
546 | if (pm) hour += 12; | 546 | if (pm) hour += 12; |
547 | } | 547 | } |
548 | 548 | ||
549 | if (ok) *ok = true; | 549 | if (ok) *ok = true; |
550 | return QTime(hour, minute, second); | 550 | return QTime(hour, minute, second); |
551 | 551 | ||
552 | error: | 552 | error: |
553 | if (ok) *ok = false; | 553 | if (ok) *ok = false; |
554 | return QTime(-1, -1, -1); // return invalid date if it didn't work | 554 | return QTime(-1, -1, -1); // return invalid date if it didn't work |
555 | // This will be removed in the near future, since it gives a warning on stderr. | 555 | // This will be removed in the near future, since it gives a warning on stderr. |
556 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | 556 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. |
557 | } | 557 | } |
558 | 558 | ||
559 | bool KLocale::use12Clock() const | 559 | bool KLocale::use12Clock() const |
560 | { | 560 | { |
561 | return !mHourF24Format ;; | 561 | return !mHourF24Format ;; |
562 | } | 562 | } |
563 | 563 | ||
564 | bool KLocale::weekStartsMonday() const | 564 | bool KLocale::weekStartsMonday() const |
565 | { | 565 | { |
566 | return mWeekStartsMonday; | 566 | return mWeekStartsMonday; |
567 | } | 567 | } |
568 | 568 | ||
569 | int KLocale::weekStartDay() const | 569 | int KLocale::weekStartDay() const |
570 | { | 570 | { |
571 | if ( mWeekStartsMonday ) | 571 | if ( mWeekStartsMonday ) |
572 | return 1; | 572 | return 1; |
573 | return 7; | 573 | return 7; |
574 | } | 574 | } |
575 | 575 | ||
576 | QString KLocale::weekDayName(int i,bool shortName) const | 576 | QString KLocale::weekDayName(int i,bool shortName) const |
577 | { | 577 | { |
578 | if ( shortName ) | 578 | if ( shortName ) |
579 | switch ( i ) | 579 | switch ( i ) |
580 | { | 580 | { |
581 | case 1: return i18n("Monday", "Mon"); | 581 | case 1: return i18n("Monday", "Mon"); |
582 | case 2: return i18n("Tuesday", "Tue"); | 582 | case 2: return i18n("Tuesday", "Tue"); |
583 | case 3: return i18n("Wednesday", "Wed"); | 583 | case 3: return i18n("Wednesday", "Wed"); |
584 | case 4: return i18n("Thursday", "Thu"); | 584 | case 4: return i18n("Thursday", "Thu"); |
585 | case 5: return i18n("Friday", "Fri"); | 585 | case 5: return i18n("Friday", "Fri"); |
586 | case 6: return i18n("Saturday", "Sat"); | 586 | case 6: return i18n("Saturday", "Sat"); |
587 | case 7: return i18n("Sunday", "Sun"); | 587 | case 7: return i18n("Sunday", "Sun"); |
588 | } | 588 | } |
589 | else | 589 | else |
590 | switch ( i ) | 590 | switch ( i ) |
591 | { | 591 | { |
592 | case 1: return i18n("Monday"); | 592 | case 1: return i18n("Monday"); |
593 | case 2: return i18n("Tuesday"); | 593 | case 2: return i18n("Tuesday"); |
594 | case 3: return i18n("Wednesday"); | 594 | case 3: return i18n("Wednesday"); |
595 | case 4: return i18n("Thursday"); | 595 | case 4: return i18n("Thursday"); |
596 | case 5: return i18n("Friday"); | 596 | case 5: return i18n("Friday"); |
597 | case 6: return i18n("Saturday"); | 597 | case 6: return i18n("Saturday"); |
598 | case 7: return i18n("Sunday"); | 598 | case 7: return i18n("Sunday"); |
599 | } | 599 | } |
600 | 600 | ||
601 | return QString::null; | 601 | return QString::null; |
602 | } | 602 | } |
603 | 603 | ||
604 | QString KLocale::monthName(int i,bool shortName) const | 604 | QString KLocale::monthName(int i,bool shortName) const |
605 | { | 605 | { |
606 | if ( shortName ) | 606 | if ( shortName ) |
607 | switch ( i ) | 607 | switch ( i ) |
608 | { | 608 | { |
609 | case 1: return i18n("January", "Jan"); | 609 | case 1: return i18n("January", "Jan"); |
610 | case 2: return i18n("February", "Feb"); | 610 | case 2: return i18n("February", "Feb"); |
611 | case 3: return i18n("March", "Mar"); | 611 | case 3: return i18n("March", "Mar"); |
612 | case 4: return i18n("April", "Apr"); | 612 | case 4: return i18n("April", "Apr"); |
613 | case 5: return i18n("May short", "May"); | 613 | case 5: return i18n("May short", "May"); |
614 | case 6: return i18n("June", "Jun"); | 614 | case 6: return i18n("June", "Jun"); |
615 | case 7: return i18n("July", "Jul"); | 615 | case 7: return i18n("July", "Jul"); |
616 | case 8: return i18n("August", "Aug"); | 616 | case 8: return i18n("August", "Aug"); |
617 | case 9: return i18n("September", "Sep"); | 617 | case 9: return i18n("September", "Sep"); |
618 | case 10: return i18n("October", "Oct"); | 618 | case 10: return i18n("October", "Oct"); |
619 | case 11: return i18n("November", "Nov"); | 619 | case 11: return i18n("November", "Nov"); |
620 | case 12: return i18n("December", "Dec"); | 620 | case 12: return i18n("December", "Dec"); |
621 | } | 621 | } |
622 | else | 622 | else |
623 | switch (i) | 623 | switch (i) |
624 | { | 624 | { |
625 | case 1: return i18n("January"); | 625 | case 1: return i18n("January"); |
626 | case 2: return i18n("February"); | 626 | case 2: return i18n("February"); |
627 | case 3: return i18n("March"); | 627 | case 3: return i18n("March"); |
628 | case 4: return i18n("April"); | 628 | case 4: return i18n("April"); |
629 | case 5: return i18n("May long", "May"); | 629 | case 5: return i18n("May long", "May"); |
630 | case 6: return i18n("June"); | 630 | case 6: return i18n("June"); |
631 | case 7: return i18n("July"); | 631 | case 7: return i18n("July"); |
632 | case 8: return i18n("August"); | 632 | case 8: return i18n("August"); |
633 | case 9: return i18n("September"); | 633 | case 9: return i18n("September"); |
634 | case 10: return i18n("October"); | 634 | case 10: return i18n("October"); |
635 | case 11: return i18n("November"); | 635 | case 11: return i18n("November"); |
636 | case 12: return i18n("December"); | 636 | case 12: return i18n("December"); |
637 | } | 637 | } |
638 | 638 | ||
639 | return QString::null; | 639 | return QString::null; |
640 | } | 640 | } |
641 | 641 | ||
642 | QString KLocale::country() const | 642 | QString KLocale::country() const |
643 | { | 643 | { |
644 | return QString::null; | 644 | return QString::null; |
645 | } | 645 | } |
646 | 646 | ||
647 | QString KLocale::dateFormat() const | 647 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const |
648 | { | 648 | { |
649 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | ||
650 | |||
649 | if ( QApplication::desktop()->width() < 480 ) { | 651 | if ( QApplication::desktop()->width() < 480 ) { |
650 | if ( mIntDateFormat == 0 ) | 652 | if ( dformat == Default ) |
651 | return "%a %d %b %Y"; | 653 | return "%a %d %b %Y"; |
652 | else if ( mIntDateFormat == 1 ) | 654 | else if ( dformat == Format1 ) |
653 | return "%a %b %d %Y"; | 655 | return "%a %b %d %Y"; |
654 | else if ( mIntDateFormat == 2 ) | 656 | else if ( dformat == ISODate ) |
655 | return "%a %Y %b %d"; | 657 | return "%a %Y %b %d"; |
656 | } else { | 658 | } else { |
657 | 659 | ||
658 | if ( mIntDateFormat == 0 ) | 660 | if ( dformat == Default ) |
659 | return "%A %d %B %Y"; | 661 | return "%A %d %B %Y"; |
660 | else if ( mIntDateFormat == 1 ) | 662 | else if ( dformat == Format1 ) |
661 | return "%A %B %d %Y"; | 663 | return "%A %B %d %Y"; |
662 | else if ( mIntDateFormat == 2 ) | 664 | else if ( dformat == ISODate ) |
663 | return "%A %Y %B %d"; | 665 | return "%A %Y %B %d"; |
664 | } | 666 | } |
665 | return mDateFormat ; | 667 | return mDateFormat ; |
666 | } | 668 | } |
667 | 669 | ||
668 | QString KLocale::dateFormatShort() const | 670 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const |
669 | { | 671 | { |
672 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | ||
670 | 673 | ||
671 | if ( mIntDateFormat == 0 ) | 674 | if ( dformat == Default ) |
672 | return "%d.%m.%Y"; | 675 | return "%d.%m.%Y"; |
673 | else if ( mIntDateFormat == 1 ) | 676 | else if ( dformat == Format1 ) |
674 | return "%m.%d.%Y"; | 677 | return "%m.%d.%Y"; |
675 | else if ( mIntDateFormat == 2 ) | 678 | else if ( dformat == ISODate ) // = Qt::ISODate |
676 | return "%Y-%m-%d"; | 679 | return "%Y-%m-%d"; |
677 | return mDateFormatShort ; | 680 | return mDateFormatShort ; |
678 | 681 | ||
679 | } | 682 | } |
680 | 683 | ||
681 | 684 | ||
682 | QString KLocale::timeFormat() const | 685 | QString KLocale::timeFormat() const |
683 | { | 686 | { |
684 | if ( mHourF24Format) | 687 | if ( mHourF24Format) |
685 | return "%H:%M:%S"; | 688 | return "%H:%M:%S"; |
686 | return "%I:%M:%S%p"; | 689 | return "%I:%M:%S%p"; |
687 | } | 690 | } |
688 | 691 | ||
689 | void KLocale::insertCatalogue ( const QString & ) | 692 | void KLocale::insertCatalogue ( const QString & ) |
690 | { | 693 | { |
691 | } | 694 | } |
692 | 695 | ||
693 | KCalendarSystem *KLocale::calendar() | 696 | KCalendarSystem *KLocale::calendar() |
694 | { | 697 | { |
695 | if ( !mCalendarSystem ) { | 698 | if ( !mCalendarSystem ) { |
696 | mCalendarSystem = new KCalendarSystemGregorian; | 699 | mCalendarSystem = new KCalendarSystemGregorian; |
697 | } | 700 | } |
698 | 701 | ||
699 | return mCalendarSystem; | 702 | return mCalendarSystem; |
700 | } | 703 | } |
701 | 704 | ||
702 | int KLocale::timezoneOffset( QString timeZone ) | 705 | int KLocale::timezoneOffset( QString timeZone ) |
703 | { | 706 | { |
704 | int ret = 1001; | 707 | int ret = 1001; |
705 | int index = mTimeZoneList.findIndex( timeZone ); | 708 | int index = mTimeZoneList.findIndex( timeZone ); |
706 | if ( index < 24 ) | 709 | if ( index < 24 ) |
707 | ret = ( index-11 ) * 60 ; | 710 | ret = ( index-11 ) * 60 ; |
708 | return ret; | 711 | return ret; |
709 | } | 712 | } |
710 | 713 | ||
711 | QStringList KLocale::timeZoneList() const | 714 | QStringList KLocale::timeZoneList() const |
712 | { | 715 | { |
713 | return mTimeZoneList; | 716 | return mTimeZoneList; |
714 | } | 717 | } |
715 | void KLocale::setTimezone( const QString &timeZone ) | 718 | void KLocale::setTimezone( const QString &timeZone ) |
716 | { | 719 | { |
717 | mTimeZoneOffset = timezoneOffset( timeZone ); | 720 | mTimeZoneOffset = timezoneOffset( timeZone ); |
718 | } | 721 | } |
719 | 722 | ||
720 | void KLocale::setDaylightSaving( bool b, int start , int end ) | 723 | void KLocale::setDaylightSaving( bool b, int start , int end ) |
721 | { | 724 | { |
722 | daylightEnabled = b; | 725 | daylightEnabled = b; |
723 | daylightStart = start; | 726 | daylightStart = start; |
724 | daylightEnd = end; | 727 | daylightEnd = end; |
725 | mSouthDaylight = (end < start); | 728 | mSouthDaylight = (end < start); |
726 | // qDebug("klocale daylight %d %d %d ", b, start , end ); | 729 | // qDebug("klocale daylight %d %d %d ", b, start , end ); |
727 | } | 730 | } |
728 | 731 | ||
729 | int KLocale::localTimeOffset( const QDateTime &dt ) | 732 | int KLocale::localTimeOffset( const QDateTime &dt ) |
730 | { | 733 | { |
731 | bool addDaylight = false; | 734 | bool addDaylight = false; |
732 | if ( daylightEnabled ) { | 735 | if ( daylightEnabled ) { |
733 | int d_end, d_start; | 736 | int d_end, d_start; |
734 | int dayofyear = dt.date().dayOfYear(); | 737 | int dayofyear = dt.date().dayOfYear(); |
735 | int year = dt.date().year(); | 738 | int year = dt.date().year(); |
736 | int add = 0; | 739 | int add = 0; |
737 | if ( QDate::leapYear(year) ) | 740 | if ( QDate::leapYear(year) ) |
738 | add = 1; | 741 | add = 1; |
739 | QDate date ( year,1,1 ); | 742 | QDate date ( year,1,1 ); |
740 | if ( daylightEnd > 59 ) | 743 | if ( daylightEnd > 59 ) |
741 | d_end = daylightEnd +add; | 744 | d_end = daylightEnd +add; |
742 | else | 745 | else |
743 | d_end = daylightEnd; | 746 | d_end = daylightEnd; |
744 | if ( daylightStart > 59 ) | 747 | if ( daylightStart > 59 ) |
745 | d_start = daylightStart +add; | 748 | d_start = daylightStart +add; |
746 | else | 749 | else |
747 | d_start = daylightStart; | 750 | d_start = daylightStart; |
748 | QDate s_date = date.addDays( d_start -1 ); | 751 | QDate s_date = date.addDays( d_start -1 ); |
749 | QDate e_date = date.addDays( d_end -1 ); | 752 | QDate e_date = date.addDays( d_end -1 ); |
750 | int dof = s_date.dayOfWeek(); | 753 | int dof = s_date.dayOfWeek(); |
751 | if ( dof < 7 ) | 754 | if ( dof < 7 ) |
752 | s_date = s_date.addDays( -dof ); | 755 | s_date = s_date.addDays( -dof ); |
753 | dof = e_date.dayOfWeek(); | 756 | dof = e_date.dayOfWeek(); |
754 | if ( dof < 7 ) | 757 | if ( dof < 7 ) |
755 | e_date = e_date.addDays( -dof ); | 758 | e_date = e_date.addDays( -dof ); |
756 | QTime startTime ( 3,0,0 ); | 759 | QTime startTime ( 3,0,0 ); |
757 | QDateTime startDt( s_date, startTime ); | 760 | QDateTime startDt( s_date, startTime ); |
758 | QDateTime endDt( e_date, startTime ); | 761 | QDateTime endDt( e_date, startTime ); |
759 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); | 762 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); |
760 | if ( mSouthDaylight ) { | 763 | if ( mSouthDaylight ) { |
761 | if ( ! ( endDt < dt && dt < startDt) ) | 764 | if ( ! ( endDt < dt && dt < startDt) ) |
762 | addDaylight = true; | 765 | addDaylight = true; |
763 | } else { | 766 | } else { |
764 | if ( startDt < dt && dt < endDt ) | 767 | if ( startDt < dt && dt < endDt ) |
765 | addDaylight = true; | 768 | addDaylight = true; |
766 | 769 | ||
767 | 770 | ||
768 | } | 771 | } |
769 | } | 772 | } |
770 | int addMin = 0; | 773 | int addMin = 0; |
771 | if ( addDaylight ) | 774 | if ( addDaylight ) |
772 | addMin = 60; | 775 | addMin = 60; |
773 | return mTimeZoneOffset + addMin; | 776 | return mTimeZoneOffset + addMin; |
774 | } | 777 | } |
775 | // ****************************************************************** | 778 | // ****************************************************************** |
776 | // added LR | 779 | // added LR |
777 | QString KLocale::formatNumber(double num, int precision) const | 780 | QString KLocale::formatNumber(double num, int precision) const |
778 | { | 781 | { |
779 | bool neg = num < 0; | 782 | bool neg = num < 0; |
780 | if (precision == -1) precision = 2; | 783 | if (precision == -1) precision = 2; |
781 | QString res = QString::number(neg?-num:num, 'f', precision); | 784 | QString res = QString::number(neg?-num:num, 'f', precision); |
782 | int pos = res.find('.'); | 785 | int pos = res.find('.'); |
783 | if (pos == -1) pos = res.length(); | 786 | if (pos == -1) pos = res.length(); |
784 | else res.replace(pos, 1, decimalSymbol()); | 787 | else res.replace(pos, 1, decimalSymbol()); |
785 | 788 | ||
786 | while (0 < (pos -= 3)) | 789 | while (0 < (pos -= 3)) |
787 | res.insert(pos, thousandsSeparator()); // thousand sep | 790 | res.insert(pos, thousandsSeparator()); // thousand sep |
788 | 791 | ||
789 | // How can we know where we should put the sign? | 792 | // How can we know where we should put the sign? |
790 | res.prepend(neg?negativeSign():positiveSign()); | 793 | res.prepend(neg?negativeSign():positiveSign()); |
791 | 794 | ||
792 | return res; | 795 | return res; |
793 | } | 796 | } |
794 | QString KLocale::formatNumber(const QString &numStr) const | 797 | QString KLocale::formatNumber(const QString &numStr) const |
795 | { | 798 | { |
796 | return formatNumber(numStr.toDouble()); | 799 | return formatNumber(numStr.toDouble()); |
797 | } | 800 | } |
798 | double KLocale::readNumber(const QString &_str, bool * ok) const | 801 | double KLocale::readNumber(const QString &_str, bool * ok) const |
799 | { | 802 | { |
800 | QString str = _str.stripWhiteSpace(); | 803 | QString str = _str.stripWhiteSpace(); |
801 | bool neg = str.find(negativeSign()) == 0; | 804 | bool neg = str.find(negativeSign()) == 0; |
802 | if (neg) | 805 | if (neg) |
803 | str.remove( 0, negativeSign().length() ); | 806 | str.remove( 0, negativeSign().length() ); |
804 | 807 | ||
805 | /* will hold the scientific notation portion of the number. | 808 | /* will hold the scientific notation portion of the number. |
806 | Example, with 2.34E+23, exponentialPart == "E+23" | 809 | Example, with 2.34E+23, exponentialPart == "E+23" |
807 | */ | 810 | */ |
808 | QString exponentialPart; | 811 | QString exponentialPart; |
809 | int EPos; | 812 | int EPos; |
810 | 813 | ||
811 | EPos = str.find('E', 0, false); | 814 | EPos = str.find('E', 0, false); |
812 | 815 | ||
813 | if (EPos != -1) | 816 | if (EPos != -1) |
814 | { | 817 | { |
815 | exponentialPart = str.mid(EPos); | 818 | exponentialPart = str.mid(EPos); |
816 | str = str.left(EPos); | 819 | str = str.left(EPos); |
817 | } | 820 | } |
818 | 821 | ||
819 | int pos = str.find(decimalSymbol()); | 822 | int pos = str.find(decimalSymbol()); |
820 | QString major; | 823 | QString major; |
821 | QString minor; | 824 | QString minor; |
822 | if ( pos == -1 ) | 825 | if ( pos == -1 ) |
823 | major = str; | 826 | major = str; |
824 | else | 827 | else |
825 | { | 828 | { |
826 | major = str.left(pos); | 829 | major = str.left(pos); |
827 | minor = str.mid(pos + decimalSymbol().length()); | 830 | minor = str.mid(pos + decimalSymbol().length()); |
828 | } | 831 | } |
829 | 832 | ||
830 | // Remove thousand separators | 833 | // Remove thousand separators |
831 | int thlen = thousandsSeparator().length(); | 834 | int thlen = thousandsSeparator().length(); |
832 | int lastpos = 0; | 835 | int lastpos = 0; |
833 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) | 836 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) |
834 | { | 837 | { |
835 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N | 838 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N |
836 | int fromEnd = major.length() - pos; | 839 | int fromEnd = major.length() - pos; |
837 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error | 840 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error |
838 | || pos - lastpos > 3 // More than 3 digits between two separators -> error | 841 | || pos - lastpos > 3 // More than 3 digits between two separators -> error |
839 | || pos == 0 // Can't start with a separator | 842 | || pos == 0 // Can't start with a separator |
840 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators | 843 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators |
841 | { | 844 | { |
842 | if (ok) *ok = false; | 845 | if (ok) *ok = false; |
843 | return 0.0; | 846 | return 0.0; |
844 | } | 847 | } |
845 | 848 | ||
846 | lastpos = pos; | 849 | lastpos = pos; |
847 | major.remove( pos, thlen ); | 850 | major.remove( pos, thlen ); |
848 | } | 851 | } |
849 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator | 852 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator |
850 | { | 853 | { |
851 | if (ok) *ok = false; | 854 | if (ok) *ok = false; |
852 | return 0.0; | 855 | return 0.0; |
853 | } | 856 | } |
854 | 857 | ||
855 | QString tot; | 858 | QString tot; |
856 | if (neg) tot = '-'; | 859 | if (neg) tot = '-'; |
857 | 860 | ||
858 | tot += major + '.' + minor + exponentialPart; | 861 | tot += major + '.' + minor + exponentialPart; |
859 | 862 | ||
860 | return tot.toDouble(ok); | 863 | return tot.toDouble(ok); |
861 | } | 864 | } |
862 | QString KLocale::decimalSymbol() const | 865 | QString KLocale::decimalSymbol() const |
863 | { | 866 | { |
864 | 867 | ||
865 | return m_decimalSymbol; | 868 | return m_decimalSymbol; |
866 | } | 869 | } |
867 | 870 | ||
868 | QString KLocale::thousandsSeparator() const | 871 | QString KLocale::thousandsSeparator() const |
869 | { | 872 | { |
870 | 873 | ||
871 | return m_thousandsSeparator; | 874 | return m_thousandsSeparator; |
872 | } | 875 | } |
873 | QString KLocale::positiveSign() const | 876 | QString KLocale::positiveSign() const |
874 | { | 877 | { |
875 | return m_positiveSign; | 878 | return m_positiveSign; |
876 | } | 879 | } |
877 | 880 | ||
878 | QString KLocale::negativeSign() const | 881 | QString KLocale::negativeSign() const |
879 | { | 882 | { |
880 | return m_negativeSign; | 883 | return m_negativeSign; |
881 | } | 884 | } |
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 7470cd2..f6c0253 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h | |||
@@ -1,110 +1,112 @@ | |||
1 | #ifndef MINIKDE_KLOCALE_H | 1 | #ifndef MINIKDE_KLOCALE_H |
2 | #define MINIKDE_KLOCALE_H | 2 | #define MINIKDE_KLOCALE_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qdatetime.h> | 6 | #include <qdatetime.h> |
7 | #include <qdict.h> | 7 | #include <qdict.h> |
8 | 8 | ||
9 | #ifndef I18N_NOOP | 9 | #ifndef I18N_NOOP |
10 | #define I18N_NOOP(x) (x) | 10 | #define I18N_NOOP(x) (x) |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | class KCalendarSystem; | 13 | class KCalendarSystem; |
14 | void setLocaleDict( QDict<QString> * dict ); | 14 | void setLocaleDict( QDict<QString> * dict ); |
15 | QString i18n(const char *text); | 15 | QString i18n(const char *text); |
16 | QString i18n(const char *hint, const char *text); | 16 | QString i18n(const char *hint, const char *text); |
17 | QString i18n(const char *text1, const char *textn, int num); | 17 | QString i18n(const char *text1, const char *textn, int num); |
18 | 18 | ||
19 | // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict | 19 | // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict |
20 | // with our i18n method. we use uic -tr tr2i18n to redirect | 20 | // with our i18n method. we use uic -tr tr2i18n to redirect |
21 | // to the right i18n() function | 21 | // to the right i18n() function |
22 | inline QString tr2i18n(const char* message, const char* =0) { | 22 | inline QString tr2i18n(const char* message, const char* =0) { |
23 | return i18n( message); | 23 | return i18n( message); |
24 | } | 24 | } |
25 | 25 | ||
26 | class KLocale | 26 | class KLocale |
27 | { | 27 | { |
28 | public: | 28 | public: |
29 | KLocale(); | 29 | KLocale(); |
30 | 30 | ||
31 | QString formatNumber(double num, int precision = -1) const; | 31 | QString formatNumber(double num, int precision = -1) const; |
32 | QString formatNumber(const QString &numStr) const; | 32 | QString formatNumber(const QString &numStr) const; |
33 | double readNumber(const QString &numStr, bool * ok = 0) const; | 33 | double readNumber(const QString &numStr, bool * ok = 0) const; |
34 | 34 | ||
35 | QString decimalSymbol() const; | 35 | QString decimalSymbol() const; |
36 | QString thousandsSeparator() const; | 36 | QString thousandsSeparator() const; |
37 | QString positiveSign() const; | 37 | QString positiveSign() const; |
38 | QString negativeSign() const; | 38 | QString negativeSign() const; |
39 | 39 | ||
40 | 40 | ||
41 | QString translate( const char *index ) const; | 41 | QString translate( const char *index ) const; |
42 | QString translate( const char *index, const char *fallback) const; | 42 | QString translate( const char *index, const char *fallback) const; |
43 | 43 | ||
44 | QString formatDate(const QDate &pDate, bool shortFormat = false) const; | 44 | enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; |
45 | |||
46 | QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; | ||
45 | QString formatTime(const QTime &pTime, bool includeSecs = false) const; | 47 | QString formatTime(const QTime &pTime, bool includeSecs = false) const; |
46 | QString formatDateTime(const QDateTime &pDateTime) const; | 48 | QString formatDateTime(const QDateTime &pDateTime) const; |
47 | QString formatDateTime(const QDateTime &pDateTime, | 49 | QString formatDateTime(const QDateTime &pDateTime, |
48 | bool shortFormat, | 50 | bool shortFormat, |
49 | bool includeSecs = false) const; | 51 | bool includeSecs = false) const; |
50 | 52 | ||
51 | QDate readDate(const QString &str, bool* ok = 0) const; | 53 | QDate readDate(const QString &str, bool* ok = 0) const; |
52 | QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; | 54 | QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; |
53 | QTime readTime(const QString &str, bool* ok = 0) const; | 55 | QTime readTime(const QString &str, bool* ok = 0) const; |
54 | 56 | ||
55 | bool use12Clock() const; | 57 | bool use12Clock() const; |
56 | bool weekStartsMonday() const; | 58 | bool weekStartsMonday() const; |
57 | int weekStartDay() const; | 59 | int weekStartDay() const; |
58 | 60 | ||
59 | QString weekDayName(int,bool=false) const; | 61 | QString weekDayName(int,bool=false) const; |
60 | QString monthName(int,bool=false) const; | 62 | QString monthName(int,bool=false) const; |
61 | 63 | ||
62 | QString country() const; | 64 | QString country() const; |
63 | 65 | ||
64 | QString dateFormat() const; | 66 | QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; |
65 | QString dateFormatShort() const; | 67 | QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; |
66 | QString timeFormat() const; | 68 | QString timeFormat() const; |
67 | 69 | ||
68 | void insertCatalogue ( const QString & ); | 70 | void insertCatalogue ( const QString & ); |
69 | 71 | ||
70 | KCalendarSystem *calendar(); | 72 | KCalendarSystem *calendar(); |
71 | void setHore24Format ( bool ); | 73 | void setHore24Format ( bool ); |
72 | void setWeekStartMonday( bool ); | 74 | void setWeekStartMonday( bool ); |
73 | void setIntDateFormat( int ); | 75 | void setIntDateFormat( IntDateFormat ); |
74 | int getIntDateFormat( ); | 76 | IntDateFormat getIntDateFormat( ); |
75 | void setLanguage( int ); | 77 | void setLanguage( int ); |
76 | void setDateFormat( QString ); | 78 | void setDateFormat( QString ); |
77 | void setDateFormatShort( QString ); | 79 | void setDateFormatShort( QString ); |
78 | 80 | ||
79 | QString m_decimalSymbol; | 81 | QString m_decimalSymbol; |
80 | QString m_thousandsSeparator; | 82 | QString m_thousandsSeparator; |
81 | QString m_currencySymbol; | 83 | QString m_currencySymbol; |
82 | QString m_monetaryDecimalSymbol; | 84 | QString m_monetaryDecimalSymbol; |
83 | QString m_monetaryThousandsSeparator; | 85 | QString m_monetaryThousandsSeparator; |
84 | QString m_positiveSign; | 86 | QString m_positiveSign; |
85 | QString m_negativeSign; | 87 | QString m_negativeSign; |
86 | 88 | ||
87 | int timezoneOffset( QString ); | 89 | int timezoneOffset( QString ); |
88 | QStringList timeZoneList() const; | 90 | QStringList timeZoneList() const; |
89 | void setDaylightSaving( bool, int , int ); | 91 | void setDaylightSaving( bool, int , int ); |
90 | int localTimeOffset(const QDateTime &); | 92 | int localTimeOffset(const QDateTime &); |
91 | void setTimezone( const QString &timeZone ); | 93 | void setTimezone( const QString &timeZone ); |
92 | private: | 94 | private: |
93 | QTime readTime(const QString &str, bool seconds, bool *ok) const; | 95 | QTime readTime(const QString &str, bool seconds, bool *ok) const; |
94 | QDate readDate(const QString &str, bool shortFormat, bool *ok) const; | 96 | QDate readDate(const QString &str, bool shortFormat, bool *ok) const; |
95 | KCalendarSystem *mCalendarSystem; | 97 | KCalendarSystem *mCalendarSystem; |
96 | bool mWeekStartsMonday; | 98 | bool mWeekStartsMonday; |
97 | bool mHourF24Format; | 99 | bool mHourF24Format; |
98 | int mIntDateFormat; | 100 | IntDateFormat mIntDateFormat; |
99 | int mLanguage; | 101 | int mLanguage; |
100 | QString mDateFormat; | 102 | QString mDateFormat; |
101 | QString mDateFormatShort; | 103 | QString mDateFormatShort; |
102 | QStringList mTimeZoneList; | 104 | QStringList mTimeZoneList; |
103 | bool daylightEnabled; | 105 | bool daylightEnabled; |
104 | int mDaylightTZoffset; | 106 | int mDaylightTZoffset; |
105 | int mNondaylightTZoffset; | 107 | int mNondaylightTZoffset; |
106 | bool mSouthDaylight; | 108 | bool mSouthDaylight; |
107 | int daylightStart, daylightEnd, mTimeZoneOffset; | 109 | int daylightStart, daylightEnd, mTimeZoneOffset; |
108 | }; | 110 | }; |
109 | 111 | ||
110 | #endif | 112 | #endif |