-rw-r--r-- | kde2file/abdump/main.cpp | 3 | ||||
-rw-r--r-- | kde2file/caldump/main.cpp | 3 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 10 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 4 | ||||
-rw-r--r-- | korganizer/koglobals.cpp | 31 | ||||
-rw-r--r-- | korganizer/koglobals.h | 5 | ||||
-rw-r--r-- | korganizer/koincidenceeditor.cpp | 1 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 9 | ||||
-rw-r--r-- | korganizer/kolistview.h | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 14 | ||||
-rw-r--r-- | korganizer/korganizer.pro | 2 | ||||
-rw-r--r-- | korganizer/korganizerE.pro | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 31 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 10 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 2 | ||||
-rw-r--r-- | korganizer/ktimeedit.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 9 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 3 |
23 files changed, 33 insertions, 129 deletions
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp index b359cfe..824d054 100644 --- a/kde2file/abdump/main.cpp +++ b/kde2file/abdump/main.cpp | |||
@@ -1,196 +1,197 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * main.cpp * | 2 | * main.cpp * |
3 | * * | 3 | * * |
4 | * | 4 | * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | * * | 10 | * * |
11 | * This program is distributed in the hope that it will be useful, * | 11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * | 14 | * GNU General Public License for more details. * |
15 | * * | 15 | * * |
16 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the Free Software * | 17 | * along with this program; if not, write to the Free Software * |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | * * | 19 | * * |
20 | * As a special exception, permission is given to link this program * | 20 | * As a special exception, permission is given to link this program * |
21 | * with any edition of Qt, and distribute the resulting executable, * | 21 | * with any edition of Qt, and distribute the resulting executable, * |
22 | * without including the source code for Qt in the source distribution. * | 22 | * without including the source code for Qt in the source distribution. * |
23 | * * | 23 | * * |
24 | ******************************************************************************/ | 24 | ******************************************************************************/ |
25 | 25 | ||
26 | #include <kcmdlineargs.h> | 26 | #include <kcmdlineargs.h> |
27 | #include <kaboutdata.h> | 27 | #include <kaboutdata.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kstandarddirs.h> | 31 | #include <kstandarddirs.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | 33 | ||
34 | #include <kabc/addressbook.h> | 34 | #include <kabc/addressbook.h> |
35 | #include <kabc/stdaddressbook.h> | 35 | #include <kabc/stdaddressbook.h> |
36 | #include <kabc/resource.h> | 36 | #include <kabc/resource.h> |
37 | #include <kabc/vcardconverter.h> | 37 | #include <kabc/vcardconverter.h> |
38 | 38 | ||
39 | #include <qdatetime.h> | 39 | #include <qdatetime.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qapplication.h> | 42 | #include <qapplication.h> |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <iostream> | 45 | #include <iostream> |
46 | 46 | ||
47 | using namespace std; | 47 | using namespace std; |
48 | 48 | ||
49 | static const char progName[] = "kdecalendar"; | 49 | static const char progName[] = "kdecalendar"; |
50 | static const char progDisplay[] = "KDE_Addressbook"; | 50 | static const char progDisplay[] = "KDE_Addressbook"; |
51 | static const char progVersion[] = "33.1/3"; | 51 | static const char progVersion[] = "33.1/3"; |
52 | static const char progDesc[] = "A command line interface to KDE addressbooks"; | 52 | static const char progDesc[] = "A command line interface to KDE addressbooks"; |
53 | 53 | ||
54 | 54 | ||
55 | static KCmdLineOptions options[] = | 55 | static KCmdLineOptions options[] = |
56 | { | 56 | { |
57 | { "dump", | 57 | { "dump", |
58 | I18N_NOOP( "Dumps addressbook" ), 0 }, | 58 | I18N_NOOP( "Dumps addressbook" ), 0 }, |
59 | { "read", | 59 | { "read", |
60 | I18N_NOOP( "Reads addressbook" ), 0 }, | 60 | I18N_NOOP( "Reads addressbook" ), 0 }, |
61 | KCmdLineLastOption | 61 | KCmdLineLastOption |
62 | }; | 62 | }; |
63 | 63 | ||
64 | int main( int argc, char *argv[] ) | 64 | int main( int argc, char *argv[] ) |
65 | { | 65 | { |
66 | KAboutData aboutData( | 66 | KAboutData aboutData( |
67 | progName, // internal program name | 67 | progName, // internal program name |
68 | I18N_NOOP( progDisplay ), // displayable program name. | 68 | I18N_NOOP( progDisplay ), // displayable program name. |
69 | progVersion, // version string | 69 | progVersion, // version string |
70 | I18N_NOOP( progDesc ), // short porgram description | 70 | I18N_NOOP( progDesc ), // short porgram description |
71 | KAboutData::License_GPL, // license type | 71 | KAboutData::License_GPL, // license type |
72 | "(c) 2004, Lutz Rogowski", // copyright statement | 72 | "(c) 2004, Lutz Rogowski", // copyright statement |
73 | 0, // any free form text | 73 | 0, // any free form text |
74 | "", // program home page address | 74 | "", // program home page address |
75 | "bugs.kde.org" // bug report email address | 75 | "bugs.kde.org" // bug report email address |
76 | ); | 76 | ); |
77 | 77 | ||
78 | 78 | ||
79 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options | 79 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options |
80 | // for QApplication/KApplication (no KDE or Qt options) | 80 | // for QApplication/KApplication (no KDE or Qt options) |
81 | KCmdLineArgs::init( argc, argv, &aboutData, true ); | 81 | KCmdLineArgs::init( argc, argv, &aboutData, true ); |
82 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. | 82 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. |
83 | 83 | ||
84 | KInstance ins ( progName ); | 84 | KInstance ins ( progName ); |
85 | 85 | ||
86 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 86 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
87 | 87 | ||
88 | bool read = false; | 88 | bool read = false; |
89 | if ( args->isSet( "read" ) ) { | 89 | if ( args->isSet( "read" ) ) { |
90 | read = true; | 90 | read = true; |
91 | qDebug("read "); | 91 | qDebug("read "); |
92 | } | 92 | } |
93 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 93 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
94 | 94 | ||
95 | KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); | 95 | KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); |
96 | standardAddressBook->setAutomaticSave( false ); | 96 | standardAddressBook->setAutomaticSave( false ); |
97 | qDebug("************************************* "); | 97 | qDebug("************************************* "); |
98 | qDebug("***************kdeABdump************* "); | 98 | qDebug("***************kdeABdump************* "); |
99 | qDebug("************************************* "); | 99 | qDebug("************************************* "); |
100 | if ( !read ) { | 100 | if ( !read ) { |
101 | KABC::AddressBook::Iterator it; | 101 | KABC::AddressBook::Iterator it; |
102 | KABC::VCardConverter converter; | 102 | KABC::VCardConverter converter; |
103 | QString datastream; | 103 | QString datastream; |
104 | for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { | 104 | for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { |
105 | if ( (*it).isEmpty() || ! (*it).resource() ) | 105 | // if ( (*it).isEmpty() || ! (*it).resource() ) |
106 | if ( (*it).isEmpty() ) | ||
106 | continue; | 107 | continue; |
107 | KABC::Addressee a = ( *it ); | 108 | KABC::Addressee a = ( *it ); |
108 | QString vcard = converter.createVCard( a ); | 109 | QString vcard = converter.createVCard( a ); |
109 | vcard += QString("\r\n"); | 110 | vcard += QString("\r\n"); |
110 | datastream += vcard; | 111 | datastream += vcard; |
111 | } | 112 | } |
112 | QFile outFile(fileName); | 113 | QFile outFile(fileName); |
113 | if ( outFile.open(IO_WriteOnly) ) { | 114 | if ( outFile.open(IO_WriteOnly) ) { |
114 | QTextStream t( &outFile ); // use a text stream | 115 | QTextStream t( &outFile ); // use a text stream |
115 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 116 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
116 | t <<datastream; | 117 | t <<datastream; |
117 | t << "\r\n\r\n"; | 118 | t << "\r\n\r\n"; |
118 | outFile.close(); | 119 | outFile.close(); |
119 | } | 120 | } |
120 | } else { | 121 | } else { |
121 | //Addressee::List aList;//parseVCards( const QString& vcard ); | 122 | //Addressee::List aList;//parseVCards( const QString& vcard ); |
122 | KABC::Addressee::List list; | 123 | KABC::Addressee::List list; |
123 | int added = 0, changedC = 0, deleted = 0; | 124 | int added = 0, changedC = 0, deleted = 0; |
124 | QFile file( fileName ); | 125 | QFile file( fileName ); |
125 | if ( file.open( IO_ReadOnly ) ) { | 126 | if ( file.open( IO_ReadOnly ) ) { |
126 | QTextStream t( &file ); // use a text stream | 127 | QTextStream t( &file ); // use a text stream |
127 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 128 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
128 | QString data; | 129 | QString data; |
129 | data = t.read(); | 130 | data = t.read(); |
130 | file.close(); | 131 | file.close(); |
131 | KABC::VCardConverter converter; | 132 | KABC::VCardConverter converter; |
132 | list = converter.parseVCards( data ); | 133 | list = converter.parseVCards( data ); |
133 | qDebug("kdeABdump::file has %d entries", list.count()); | 134 | qDebug("kdeABdump::file has %d entries", list.count()); |
134 | 135 | ||
135 | KABC::Addressee::List::Iterator it; | 136 | KABC::Addressee::List::Iterator it; |
136 | for ( it = list.begin();it != list.end();++it) { | 137 | for ( it = list.begin();it != list.end();++it) { |
137 | (*it).setChanged( true ); | 138 | (*it).setChanged( true ); |
138 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); | 139 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); |
139 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 140 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
140 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); | 141 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); |
141 | if ( changed ) { | 142 | if ( changed ) { |
142 | //qDebug("changed Addressee found! "); | 143 | //qDebug("changed Addressee found! "); |
143 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 144 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
144 | if ( ! std.isEmpty() ) | 145 | if ( ! std.isEmpty() ) |
145 | (*it).setResource(std.resource()); | 146 | (*it).setResource(std.resource()); |
146 | standardAddressBook->insertAddressee( (*it) ); | 147 | standardAddressBook->insertAddressee( (*it) ); |
147 | ++changedC; | 148 | ++changedC; |
148 | } else { | 149 | } else { |
149 | //maybe added? | 150 | //maybe added? |
150 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 151 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
151 | if ( std.isEmpty() ) { | 152 | if ( std.isEmpty() ) { |
152 | standardAddressBook->insertAddressee( (*it) ); | 153 | standardAddressBook->insertAddressee( (*it) ); |
153 | ++added; | 154 | ++added; |
154 | } | 155 | } |
155 | } | 156 | } |
156 | } | 157 | } |
157 | KABC::AddressBook::Iterator itA = standardAddressBook->begin(); | 158 | KABC::AddressBook::Iterator itA = standardAddressBook->begin(); |
158 | KABC::AddressBook::Iterator it2 ; | 159 | KABC::AddressBook::Iterator it2 ; |
159 | while ( itA != standardAddressBook->end() ) { | 160 | while ( itA != standardAddressBook->end() ) { |
160 | bool found = false; | 161 | bool found = false; |
161 | KABC::Addressee::List::Iterator itL; | 162 | KABC::Addressee::List::Iterator itL; |
162 | for ( itL = list.begin();itL != list.end();++itL) { | 163 | for ( itL = list.begin();itL != list.end();++itL) { |
163 | if ( (*itL).uid() == (*itA).uid() ) { | 164 | if ( (*itL).uid() == (*itA).uid() ) { |
164 | found = true; | 165 | found = true; |
165 | break; | 166 | break; |
166 | } | 167 | } |
167 | } | 168 | } |
168 | if ( !found ) { | 169 | if ( !found ) { |
169 | it2 = itA; | 170 | it2 = itA; |
170 | ++itA; | 171 | ++itA; |
171 | standardAddressBook->removeAddressee( it2 ); | 172 | standardAddressBook->removeAddressee( it2 ); |
172 | ++deleted; | 173 | ++deleted; |
173 | } else { | 174 | } else { |
174 | ++itA; | 175 | ++itA; |
175 | } | 176 | } |
176 | } | 177 | } |
177 | 178 | ||
178 | //standardAddressBook->saveAll(); | 179 | //standardAddressBook->saveAll(); |
179 | standardAddressBook->setAutomaticSave( true ); | 180 | standardAddressBook->setAutomaticSave( true ); |
180 | qDebug("************************************* "); | 181 | qDebug("************************************* "); |
181 | qDebug("*************kdeABdump*************** "); | 182 | qDebug("*************kdeABdump*************** "); |
182 | qDebug("************************************* "); | 183 | qDebug("************************************* "); |
183 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); | 184 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); |
184 | } else | 185 | } else |
185 | qDebug("error open file "); | 186 | qDebug("error open file "); |
186 | } | 187 | } |
187 | standardAddressBook->close(); | 188 | standardAddressBook->close(); |
188 | // line not needed by KDE 3.4: | 189 | // line not needed by KDE 3.4: |
189 | // delete standardAddressBook; | 190 | // delete standardAddressBook; |
190 | 191 | ||
191 | 192 | ||
192 | //KABC::StdAddressBook::close(); | 193 | //KABC::StdAddressBook::close(); |
193 | //StdAddressBook::mSelf = 0; | 194 | //StdAddressBook::mSelf = 0; |
194 | qDebug("ente "); | 195 | qDebug("ente "); |
195 | return 0; | 196 | return 0; |
196 | } | 197 | } |
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index 9cc1a73..c8755cd 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp | |||
@@ -1,253 +1,254 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * main.cpp * | 2 | * main.cpp * |
3 | * * | 3 | * * |
4 | * | 4 | * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | * * | 10 | * * |
11 | * This program is distributed in the hope that it will be useful, * | 11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * | 14 | * GNU General Public License for more details. * |
15 | * * | 15 | * * |
16 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the Free Software * | 17 | * along with this program; if not, write to the Free Software * |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | * * | 19 | * * |
20 | * As a special exception, permission is given to link this program * | 20 | * As a special exception, permission is given to link this program * |
21 | * with any edition of Qt, and distribute the resulting executable, * | 21 | * with any edition of Qt, and distribute the resulting executable, * |
22 | * without including the source code for Qt in the source distribution. * | 22 | * without including the source code for Qt in the source distribution. * |
23 | * * | 23 | * * |
24 | ******************************************************************************/ | 24 | ******************************************************************************/ |
25 | 25 | ||
26 | #ifdef HAVE_CONFIG_H | 26 | #ifdef HAVE_CONFIG_H |
27 | #include "config.h" | 27 | #include "config.h" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #if TIME_WITH_SYS_TIME | 30 | #if TIME_WITH_SYS_TIME |
31 | # include <sys/time.h> | 31 | # include <sys/time.h> |
32 | # include <time.h> | 32 | # include <time.h> |
33 | #else | 33 | #else |
34 | # if HAVE_SYS_TIME_H | 34 | # if HAVE_SYS_TIME_H |
35 | # include <sys/time.h> | 35 | # include <sys/time.h> |
36 | # else | 36 | # else |
37 | # include <time.h> | 37 | # include <time.h> |
38 | # endif | 38 | # endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #include <kcmdlineargs.h> | 41 | #include <kcmdlineargs.h> |
42 | #include <kaboutdata.h> | 42 | #include <kaboutdata.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <kconfig.h> | 45 | #include <kconfig.h> |
46 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | 48 | ||
49 | #include <libkcal/calformat.h> | 49 | #include <libkcal/calformat.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcelocal.h> | 51 | #include <libkcal/resourcelocal.h> |
52 | #include <libkcal/filestorage.h> | 52 | #include <libkcal/filestorage.h> |
53 | #include <libkcal/icalformat.h> | 53 | #include <libkcal/icalformat.h> |
54 | 54 | ||
55 | #include <qdatetime.h> | 55 | #include <qdatetime.h> |
56 | #include <qfile.h> | 56 | #include <qfile.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qapplication.h> | 58 | #include <qapplication.h> |
59 | 59 | ||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <iostream> | 61 | #include <iostream> |
62 | 62 | ||
63 | using namespace KCal; | 63 | using namespace KCal; |
64 | using namespace std; | 64 | using namespace std; |
65 | 65 | ||
66 | static const char progName[] = "kdecalendar"; | 66 | static const char progName[] = "kdecalendar"; |
67 | static const char progDisplay[] = "KDE_Calendar"; | 67 | static const char progDisplay[] = "KDE_Calendar"; |
68 | static const char progVersion[] = "33.1/3"; | 68 | static const char progVersion[] = "33.1/3"; |
69 | static const char progDesc[] = "A command line interface to KDE calendars"; | 69 | static const char progDesc[] = "A command line interface to KDE calendars"; |
70 | 70 | ||
71 | 71 | ||
72 | static KCmdLineOptions options[] = | 72 | static KCmdLineOptions options[] = |
73 | { | 73 | { |
74 | { "dump", | 74 | { "dump", |
75 | I18N_NOOP( "Dumps calendar" ), 0 }, | 75 | I18N_NOOP( "Dumps calendar" ), 0 }, |
76 | { "read", | 76 | { "read", |
77 | I18N_NOOP( "Reads calendar" ), 0 }, | 77 | I18N_NOOP( "Reads calendar" ), 0 }, |
78 | KCmdLineLastOption | 78 | KCmdLineLastOption |
79 | }; | 79 | }; |
80 | 80 | ||
81 | int main( int argc, char *argv[] ) | 81 | int main( int argc, char *argv[] ) |
82 | { | 82 | { |
83 | KAboutData aboutData( | 83 | KAboutData aboutData( |
84 | progName, // internal program name | 84 | progName, // internal program name |
85 | I18N_NOOP( progDisplay ), // displayable program name. | 85 | I18N_NOOP( progDisplay ), // displayable program name. |
86 | progVersion, // version string | 86 | progVersion, // version string |
87 | I18N_NOOP( progDesc ), // short porgram description | 87 | I18N_NOOP( progDesc ), // short porgram description |
88 | KAboutData::License_GPL, // license type | 88 | KAboutData::License_GPL, // license type |
89 | "(c) 2004, Lutz Rogowski", // copyright statement | 89 | "(c) 2004, Lutz Rogowski", // copyright statement |
90 | 0, // any free form text | 90 | 0, // any free form text |
91 | "", // program home page address | 91 | "", // program home page address |
92 | "bugs.kde.org" // bug report email address | 92 | "bugs.kde.org" // bug report email address |
93 | ); | 93 | ); |
94 | 94 | ||
95 | 95 | ||
96 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options | 96 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options |
97 | // for QApplication/KApplication (no KDE or Qt options) | 97 | // for QApplication/KApplication (no KDE or Qt options) |
98 | KCmdLineArgs::init( argc, argv, &aboutData, true ); | 98 | KCmdLineArgs::init( argc, argv, &aboutData, true ); |
99 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. | 99 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. |
100 | 100 | ||
101 | KInstance ins ( progName ); | 101 | KInstance ins ( progName ); |
102 | 102 | ||
103 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 103 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
104 | 104 | ||
105 | bool read = false; | 105 | bool read = false; |
106 | if ( args->isSet( "read" ) ) { | 106 | if ( args->isSet( "read" ) ) { |
107 | read = true; | 107 | read = true; |
108 | qDebug("read "); | 108 | qDebug("read "); |
109 | } | 109 | } |
110 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 110 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
111 | CalendarResources *calendarResource = 0; | 111 | CalendarResources *calendarResource = 0; |
112 | CalendarLocal *localCalendar = 0; | 112 | CalendarLocal *localCalendar = 0; |
113 | KConfig c( locate( "config", "korganizerrc" ) ); | 113 | KConfig c( locate( "config", "korganizerrc" ) ); |
114 | c.setGroup( "Time & Date" ); | 114 | c.setGroup( "Time & Date" ); |
115 | QString tz = c.readEntry( "TimeZoneId" ); | 115 | QString tz = c.readEntry( "TimeZoneId" ); |
116 | calendarResource = new CalendarResources( tz ); | 116 | calendarResource = new CalendarResources( tz ); |
117 | calendarResource->readConfig(); | 117 | calendarResource->readConfig(); |
118 | calendarResource->load(); | 118 | calendarResource->load(); |
119 | qDebug("************************************* "); | 119 | qDebug("************************************* "); |
120 | qDebug("**************kdecaldump************* "); | 120 | qDebug("**************kdecaldump************* "); |
121 | qDebug("************************************* "); | 121 | qDebug("************************************* "); |
122 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); | 122 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); |
123 | 123 | ||
124 | if ( !read ) { | 124 | if ( !read ) { |
125 | localCalendar = new CalendarLocal(); | 125 | localCalendar = new CalendarLocal(); |
126 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 126 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
127 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 127 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
128 | Incidence::List::ConstIterator it; | 128 | Incidence::List::ConstIterator it; |
129 | int num = 0; | 129 | int num = 0; |
130 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 130 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
131 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 131 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
132 | if ( re ) { | 132 | //if ( re ) |
133 | { | ||
133 | ++num; | 134 | ++num; |
134 | Incidence* cl = (*it)->clone(); | 135 | Incidence* cl = (*it)->clone(); |
135 | cl->setLastModified( (*it)->lastModified() ); | 136 | cl->setLastModified( (*it)->lastModified() ); |
136 | if ( cl->type() == "Journal" ) | 137 | if ( cl->type() == "Journal" ) |
137 | localCalendar->addJournal( (Journal *) cl ); | 138 | localCalendar->addJournal( (Journal *) cl ); |
138 | else if ( cl->type() == "Todo" ) | 139 | else if ( cl->type() == "Todo" ) |
139 | localCalendar->addTodo( (Todo *) cl ); | 140 | localCalendar->addTodo( (Todo *) cl ); |
140 | else if ( cl->type() == "Event" ) | 141 | else if ( cl->type() == "Event" ) |
141 | localCalendar->addEvent( (Event *) cl ); | 142 | localCalendar->addEvent( (Event *) cl ); |
142 | } | 143 | } |
143 | } | 144 | } |
144 | 145 | ||
145 | FileStorage* storage = new FileStorage( calendarResource ); | 146 | FileStorage* storage = new FileStorage( calendarResource ); |
146 | storage->setFileName( fileName ); | 147 | storage->setFileName( fileName ); |
147 | storage->setSaveFormat( new ICalFormat() ); | 148 | storage->setSaveFormat( new ICalFormat() ); |
148 | storage->save(); | 149 | storage->save(); |
149 | delete storage; | 150 | delete storage; |
150 | qDebug("************************************* "); | 151 | qDebug("************************************* "); |
151 | qDebug("************kdecaldump*************** "); | 152 | qDebug("************kdecaldump*************** "); |
152 | qDebug("************************************* "); | 153 | qDebug("************************************* "); |
153 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); | 154 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); |
154 | 155 | ||
155 | } else { | 156 | } else { |
156 | qDebug("************load"); | 157 | qDebug("************load"); |
157 | localCalendar = new CalendarLocal(); | 158 | localCalendar = new CalendarLocal(); |
158 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 159 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
159 | FileStorage* storage = new FileStorage( localCalendar ); | 160 | FileStorage* storage = new FileStorage( localCalendar ); |
160 | storage->setFileName( fileName ); | 161 | storage->setFileName( fileName ); |
161 | int num = 0; | 162 | int num = 0; |
162 | int del = 0; | 163 | int del = 0; |
163 | int add = 0; | 164 | int add = 0; |
164 | if ( storage->load() ) { | 165 | if ( storage->load() ) { |
165 | qDebug("***********loaded!"); | 166 | qDebug("***********loaded!"); |
166 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); | 167 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); |
167 | Incidence::List::ConstIterator it; | 168 | Incidence::List::ConstIterator it; |
168 | for( it = newInc.begin(); it != newInc.end(); ++it ) { | 169 | for( it = newInc.begin(); it != newInc.end(); ++it ) { |
169 | if ( (*it)->pilotId() > 1 ) { //changed | 170 | if ( (*it)->pilotId() > 1 ) { //changed |
170 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); | 171 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); |
171 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); | 172 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
172 | ResourceCalendar * res = 0; | 173 | ResourceCalendar * res = 0; |
173 | if ( incOld ) | 174 | if ( incOld ) |
174 | res = calendarResource->resource( incOld ); | 175 | res = calendarResource->resource( incOld ); |
175 | if ( res ) { | 176 | if ( res ) { |
176 | Incidence* cl = (*it)->clone(); | 177 | Incidence* cl = (*it)->clone(); |
177 | cl->setPilotId( incOld->pilotId() ); | 178 | cl->setPilotId( incOld->pilotId() ); |
178 | ++num; | 179 | ++num; |
179 | if ( incOld->type() == "Journal" ) | 180 | if ( incOld->type() == "Journal" ) |
180 | calendarResource->deleteJournal( (Journal *) incOld ); | 181 | calendarResource->deleteJournal( (Journal *) incOld ); |
181 | else if ( incOld->type() == "Todo" ) | 182 | else if ( incOld->type() == "Todo" ) |
182 | calendarResource->deleteTodo( (Todo *) incOld ); | 183 | calendarResource->deleteTodo( (Todo *) incOld ); |
183 | else if ( incOld->type() == "Event" ) | 184 | else if ( incOld->type() == "Event" ) |
184 | calendarResource->deleteEvent( (Event *) incOld ); | 185 | calendarResource->deleteEvent( (Event *) incOld ); |
185 | qDebug("*********change incidence %s ",cl->summary().latin1()); | 186 | qDebug("*********change incidence %s ",cl->summary().latin1()); |
186 | if ( cl->type() == "Journal" ) | 187 | if ( cl->type() == "Journal" ) |
187 | calendarResource->addJournal( (Journal *) cl, res ); | 188 | calendarResource->addJournal( (Journal *) cl, res ); |
188 | else if ( cl->type() == "Todo" ) | 189 | else if ( cl->type() == "Todo" ) |
189 | calendarResource->addTodo( (Todo *) cl, res ); | 190 | calendarResource->addTodo( (Todo *) cl, res ); |
190 | else if ( cl->type() == "Event" ) | 191 | else if ( cl->type() == "Event" ) |
191 | calendarResource->addEvent( (Event *) cl, res ); | 192 | calendarResource->addEvent( (Event *) cl, res ); |
192 | 193 | ||
193 | } else { | 194 | } else { |
194 | Incidence* cl = (*it)->clone(); | 195 | Incidence* cl = (*it)->clone(); |
195 | qDebug("*********add incidence %s ",cl->summary().latin1()); | 196 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
196 | calendarResource->addIncidence( cl ); | 197 | calendarResource->addIncidence( cl ); |
197 | ++add; | 198 | ++add; |
198 | } | 199 | } |
199 | } else { // maybe added | 200 | } else { // maybe added |
200 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); | 201 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
201 | if ( !incOld ) { //added | 202 | if ( !incOld ) { //added |
202 | Incidence* cl = (*it)->clone(); | 203 | Incidence* cl = (*it)->clone(); |
203 | qDebug("*********add incidence %s ",cl->summary().latin1()); | 204 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
204 | calendarResource->addIncidence( cl ); | 205 | calendarResource->addIncidence( cl ); |
205 | ++add; | 206 | ++add; |
206 | } | 207 | } |
207 | } | 208 | } |
208 | } | 209 | } |
209 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 210 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
210 | 211 | ||
211 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 212 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
212 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 213 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
213 | if ( re && !re->readOnly() ) { | 214 | if ( re && !re->readOnly() ) { |
214 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); | 215 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); |
215 | if ( !cl ) { | 216 | if ( !cl ) { |
216 | ++del; | 217 | ++del; |
217 | cl = (*it); | 218 | cl = (*it); |
218 | if ( cl->type() == "Journal" ) | 219 | if ( cl->type() == "Journal" ) |
219 | calendarResource->deleteJournal( (Journal *) cl ); | 220 | calendarResource->deleteJournal( (Journal *) cl ); |
220 | else if ( cl->type() == "Todo" ) | 221 | else if ( cl->type() == "Todo" ) |
221 | calendarResource->deleteTodo( (Todo *) cl ); | 222 | calendarResource->deleteTodo( (Todo *) cl ); |
222 | else if ( cl->type() == "Event" ) | 223 | else if ( cl->type() == "Event" ) |
223 | calendarResource->deleteEvent( (Event *) cl ); | 224 | calendarResource->deleteEvent( (Event *) cl ); |
224 | //QDateTime lm = cl->lastModified(); | 225 | //QDateTime lm = cl->lastModified(); |
225 | //cl->setResources( (*it)->resources() ); | 226 | //cl->setResources( (*it)->resources() ); |
226 | //cl->setLastModified(lm); | 227 | //cl->setLastModified(lm); |
227 | } | 228 | } |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | calendarResource->save(); | 232 | calendarResource->save(); |
232 | qDebug("************************************* "); | 233 | qDebug("************************************* "); |
233 | qDebug("************kdecaldump*************** "); | 234 | qDebug("************kdecaldump*************** "); |
234 | qDebug("************************************* "); | 235 | qDebug("************************************* "); |
235 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); | 236 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); |
236 | 237 | ||
237 | } else | 238 | } else |
238 | qDebug("ERROR loading file %s",fileName.latin1() ); | 239 | qDebug("ERROR loading file %s",fileName.latin1() ); |
239 | 240 | ||
240 | } | 241 | } |
241 | 242 | ||
242 | if ( localCalendar ) { | 243 | if ( localCalendar ) { |
243 | localCalendar->close(); | 244 | localCalendar->close(); |
244 | delete localCalendar; | 245 | delete localCalendar; |
245 | } | 246 | } |
246 | if ( calendarResource ) { | 247 | if ( calendarResource ) { |
247 | calendarResource->close(); | 248 | calendarResource->close(); |
248 | delete calendarResource; | 249 | delete calendarResource; |
249 | } | 250 | } |
250 | 251 | ||
251 | qDebug("ente "); | 252 | qDebug("ente "); |
252 | return 0; | 253 | return 0; |
253 | } | 254 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 5aa1c9b..6697602 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,467 +1,465 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 64 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
65 | mNavigatorBar = new NavigatorBar( startDate, this ); | 65 | mNavigatorBar = new NavigatorBar( startDate, this ); |
66 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 66 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
67 | //mNavigatorBar->resize( 1,1); | 67 | //mNavigatorBar->resize( 1,1); |
68 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 68 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
69 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 72 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
73 | 73 | ||
74 | // get the day of the week on the first day | 74 | // get the day of the week on the first day |
75 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 75 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
76 | m_fstDayOfWk = dayone.dayOfWeek(); | 76 | m_fstDayOfWk = dayone.dayOfWeek(); |
77 | 77 | ||
78 | int i; | 78 | int i; |
79 | 79 | ||
80 | // Set up the heading fields. | 80 | // Set up the heading fields. |
81 | for( i = 0; i < 7; i++ ) { | 81 | for( i = 0; i < 7; i++ ) { |
82 | headings[i] = new QLabel("",this); | 82 | headings[i] = new QLabel("",this); |
83 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 83 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
84 | headings[i]->setAlignment(AlignCenter); | 84 | headings[i]->setAlignment(AlignCenter); |
85 | headings[i]->installEventFilter(this); | 85 | headings[i]->installEventFilter(this); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter ); | 93 | weeknos[i]->setAlignment(AlignCenter ); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | mySizeHint = sizeHintTwoButtons(); | 118 | mySizeHint = sizeHintTwoButtons(); |
119 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 119 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
120 | mFontChanged = false; | 120 | mFontChanged = false; |
121 | //resize ( 3,3 ); | 121 | //resize ( 3,3 ); |
122 | 122 | ||
123 | } | 123 | } |
124 | void KDateNavigator::changeFont ( QFont fo ) | 124 | void KDateNavigator::changeFont ( QFont fo ) |
125 | { | 125 | { |
126 | setFont( fo ); | 126 | setFont( fo ); |
127 | mNavigatorBar->resetFont( fo ); | 127 | mNavigatorBar->resetFont( fo ); |
128 | } | 128 | } |
129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
130 | { | 130 | { |
131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
132 | *b = false; | 132 | *b = false; |
133 | int fontPoint = fo.pointSize(); | 133 | int fontPoint = fo.pointSize(); |
134 | while ( fontPoint > 5 ) { | 134 | while ( fontPoint > 5 ) { |
135 | --fontPoint; | 135 | --fontPoint; |
136 | fo.setPointSize( fontPoint ); | 136 | fo.setPointSize( fontPoint ); |
137 | setFont( fo ); | 137 | setFont( fo ); |
138 | mFontChanged = true; | 138 | mFontChanged = true; |
139 | mNavigatorBar->resetFont( fo ); | 139 | mNavigatorBar->resetFont( fo ); |
140 | QSize sh = sizeHintTwoButtons( 2 ); | 140 | QSize sh = sizeHintTwoButtons( 2 ); |
141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
142 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 142 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
143 | if ( si.width() / sh.width() == 1 ) { | 143 | if ( si.width() / sh.width() == 1 ) { |
144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
145 | continue; | 145 | continue; |
146 | } | 146 | } |
147 | *b = true; | 147 | *b = true; |
148 | //qDebug("fooooooooooooooooooooooouuuuund "); | ||
149 | break; | 148 | break; |
150 | } | 149 | } |
151 | } | 150 | } |
152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | ||
153 | return fo; | 151 | return fo; |
154 | } | 152 | } |
155 | QSize KDateNavigator::sizeHint() const | 153 | QSize KDateNavigator::sizeHint() const |
156 | { | 154 | { |
157 | QFontMetrics fm ( font() ); | 155 | QFontMetrics fm ( font() ); |
158 | QSize day = daymatrix->sizeHint(); | 156 | QSize day = daymatrix->sizeHint(); |
159 | QSize nav = mNavigatorBar->sizeHint(); | 157 | QSize nav = mNavigatorBar->sizeHint(); |
160 | int wid = fm.width( "30") + day.width()+3; | 158 | int wid = fm.width( "30") + day.width()+3; |
161 | int hei = fm.height() +day.height()+nav.height()+2; | 159 | int hei = fm.height() +day.height()+nav.height()+2; |
162 | if ( wid < nav.width() ) | 160 | if ( wid < nav.width() ) |
163 | wid = nav.width() ; | 161 | wid = nav.width() ; |
164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 162 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
165 | return QSize ( wid, hei ); | 163 | return QSize ( wid, hei ); |
166 | } | 164 | } |
167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 165 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
168 | { | 166 | { |
169 | QFontMetrics fm ( font() ); | 167 | QFontMetrics fm ( font() ); |
170 | QSize day = daymatrix->sizeHint(); | 168 | QSize day = daymatrix->sizeHint(); |
171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 169 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
172 | int wid = fm.width( "30") + day.width()+3; | 170 | int wid = fm.width( "30") + day.width()+3; |
173 | int hei = fm.height() +day.height()+nav.height()+2; | 171 | int hei = fm.height() +day.height()+nav.height()+2; |
174 | if ( wid < nav.width() ) | 172 | if ( wid < nav.width() ) |
175 | wid = nav.width() ; | 173 | wid = nav.width() ; |
176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 174 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
177 | return QSize ( wid, hei ); | 175 | return QSize ( wid, hei ); |
178 | } | 176 | } |
179 | void KDateNavigator::slotMonthSelected( int m ) | 177 | void KDateNavigator::slotMonthSelected( int m ) |
180 | { | 178 | { |
181 | if ( m_MthYr.month() <= mMonthSignalOffset) | 179 | if ( m_MthYr.month() <= mMonthSignalOffset) |
182 | m += 12; | 180 | m += 12; |
183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 181 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
184 | emit monthSelected( m - mMonthSignalOffset ); | 182 | emit monthSelected( m - mMonthSignalOffset ); |
185 | 183 | ||
186 | } | 184 | } |
187 | void KDateNavigator::setCalendar( Calendar *cal ) | 185 | void KDateNavigator::setCalendar( Calendar *cal ) |
188 | { | 186 | { |
189 | daymatrix->setCalendar( cal ); | 187 | daymatrix->setCalendar( cal ); |
190 | } | 188 | } |
191 | 189 | ||
192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 190 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
193 | { | 191 | { |
194 | m_MthYr = date; | 192 | m_MthYr = date; |
195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 193 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
196 | 194 | ||
197 | updateDates(); | 195 | updateDates(); |
198 | updateView(); | 196 | updateView(); |
199 | 197 | ||
200 | KCal::DateList dates; | 198 | KCal::DateList dates; |
201 | dates.append( date ); | 199 | dates.append( date ); |
202 | mNavigatorBar->selectDates( dates ); | 200 | mNavigatorBar->selectDates( dates ); |
203 | 201 | ||
204 | daymatrix->clearSelection(); | 202 | daymatrix->clearSelection(); |
205 | if ( doRepaint ) | 203 | if ( doRepaint ) |
206 | daymatrix->repaint( false ); | 204 | daymatrix->repaint( false ); |
207 | } | 205 | } |
208 | 206 | ||
209 | void KDateNavigator::enableRollover(RolloverType r) | 207 | void KDateNavigator::enableRollover(RolloverType r) |
210 | { | 208 | { |
211 | switch(r) | 209 | switch(r) |
212 | { | 210 | { |
213 | case None : | 211 | case None : |
214 | if (updateTimer) | 212 | if (updateTimer) |
215 | { | 213 | { |
216 | updateTimer->stop(); | 214 | updateTimer->stop(); |
217 | delete updateTimer; | 215 | delete updateTimer; |
218 | updateTimer=0L; | 216 | updateTimer=0L; |
219 | } | 217 | } |
220 | break; | 218 | break; |
221 | case FollowDay : | 219 | case FollowDay : |
222 | case FollowMonth : | 220 | case FollowMonth : |
223 | if (!updateTimer) | 221 | if (!updateTimer) |
224 | { | 222 | { |
225 | updateTimer = new QTimer(this); | 223 | updateTimer = new QTimer(this); |
226 | QObject::connect(updateTimer,SIGNAL(timeout()), | 224 | QObject::connect(updateTimer,SIGNAL(timeout()), |
227 | this,SLOT(possiblyPastMidnight())); | 225 | this,SLOT(possiblyPastMidnight())); |
228 | } | 226 | } |
229 | updateTimer->start(0,true); | 227 | updateTimer->start(0,true); |
230 | lastDayChecked = QDate::currentDate(); | 228 | lastDayChecked = QDate::currentDate(); |
231 | } | 229 | } |
232 | updateRollover=r; | 230 | updateRollover=r; |
233 | } | 231 | } |
234 | 232 | ||
235 | 233 | ||
236 | KDateNavigator::~KDateNavigator() | 234 | KDateNavigator::~KDateNavigator() |
237 | { | 235 | { |
238 | } | 236 | } |
239 | 237 | ||
240 | 238 | ||
241 | void KDateNavigator::passedMidnight() | 239 | void KDateNavigator::passedMidnight() |
242 | { | 240 | { |
243 | QDate today = QDate::currentDate(); | 241 | QDate today = QDate::currentDate(); |
244 | bool emitMonth = false; | 242 | bool emitMonth = false; |
245 | 243 | ||
246 | if (today.month() != lastDayChecked.month()) | 244 | if (today.month() != lastDayChecked.month()) |
247 | { | 245 | { |
248 | if (updateRollover==FollowMonth && | 246 | if (updateRollover==FollowMonth && |
249 | daymatrix->isEndOfMonth()) { | 247 | daymatrix->isEndOfMonth()) { |
250 | goNextMonth(); | 248 | goNextMonth(); |
251 | emitMonth=true; | 249 | emitMonth=true; |
252 | } | 250 | } |
253 | } | 251 | } |
254 | daymatrix->recalculateToday(); | 252 | daymatrix->recalculateToday(); |
255 | daymatrix->repaint( false ); | 253 | daymatrix->repaint( false ); |
256 | emit dayPassed(today); | 254 | emit dayPassed(today); |
257 | if (emitMonth) { emit monthPassed(today); } | 255 | if (emitMonth) { emit monthPassed(today); } |
258 | } | 256 | } |
259 | 257 | ||
260 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 258 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
261 | { | 259 | { |
262 | if (lastDayChecked!=QDate::currentDate()) | 260 | if (lastDayChecked!=QDate::currentDate()) |
263 | { | 261 | { |
264 | passedMidnight(); | 262 | passedMidnight(); |
265 | lastDayChecked=QDate::currentDate(); | 263 | lastDayChecked=QDate::currentDate(); |
266 | } | 264 | } |
267 | // Set the timer to go off 1 second after midnight | 265 | // Set the timer to go off 1 second after midnight |
268 | // or after 8 minutes, whichever comes first. | 266 | // or after 8 minutes, whichever comes first. |
269 | if (updateTimer) | 267 | if (updateTimer) |
270 | { | 268 | { |
271 | QTime now = QTime::currentTime(); | 269 | QTime now = QTime::currentTime(); |
272 | QTime midnight = QTime(23,59,59); | 270 | QTime midnight = QTime(23,59,59); |
273 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 271 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
274 | 272 | ||
275 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 273 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
276 | //.arg(now.toString()).arg(midnight.toString())); | 274 | //.arg(now.toString()).arg(midnight.toString())); |
277 | 275 | ||
278 | updateTimer->stop(); | 276 | updateTimer->stop(); |
279 | updateTimer->start(msecsWait,true); | 277 | updateTimer->start(msecsWait,true); |
280 | } | 278 | } |
281 | } | 279 | } |
282 | 280 | ||
283 | void KDateNavigator::updateDates() | 281 | void KDateNavigator::updateDates() |
284 | { | 282 | { |
285 | // Find the first day of the week of the current month. | 283 | // Find the first day of the week of the current month. |
286 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 284 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
287 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 285 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
288 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 286 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
289 | //int di = d1 - d2 + 1; | 287 | //int di = d1 - d2 + 1; |
290 | dayone = dayone.addDays( -d2 + 1 ); | 288 | dayone = dayone.addDays( -d2 + 1 ); |
291 | 289 | ||
292 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 290 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
293 | 291 | ||
294 | // If month begins on Monday and Monday is first day of week, | 292 | // If month begins on Monday and Monday is first day of week, |
295 | // month should begin on second line. Sunday doesn't have this problem. | 293 | // month should begin on second line. Sunday doesn't have this problem. |
296 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 294 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
297 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 295 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
298 | 296 | ||
299 | // update the matrix dates | 297 | // update the matrix dates |
300 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 298 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
301 | 299 | ||
302 | 300 | ||
303 | daymatrix->updateView(dayone.addDays(index)); | 301 | daymatrix->updateView(dayone.addDays(index)); |
304 | //each updateDates is followed by an updateView -> repaint is issued there ! | 302 | //each updateDates is followed by an updateView -> repaint is issued there ! |
305 | // daymatrix->repaint(); | 303 | // daymatrix->repaint(); |
306 | } | 304 | } |
307 | 305 | ||
308 | void KDateNavigator::updateDayMatrix() | 306 | void KDateNavigator::updateDayMatrix() |
309 | { | 307 | { |
310 | daymatrix->updateView(); | 308 | daymatrix->updateView(); |
311 | //daymatrix->repaint(); | 309 | //daymatrix->repaint(); |
312 | } | 310 | } |
313 | 311 | ||
314 | 312 | ||
315 | void KDateNavigator::updateView() | 313 | void KDateNavigator::updateView() |
316 | { | 314 | { |
317 | 315 | ||
318 | setUpdatesEnabled( false ); | 316 | setUpdatesEnabled( false ); |
319 | 317 | ||
320 | int i; | 318 | int i; |
321 | 319 | ||
322 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 320 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
323 | daymatrix->updateView(); | 321 | daymatrix->updateView(); |
324 | int sub = 4; | 322 | int sub = 4; |
325 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 323 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
326 | --sub; | 324 | --sub; |
327 | // set the week numbers. | 325 | // set the week numbers. |
328 | for(i = 0; i < 6; i++) { | 326 | for(i = 0; i < 6; i++) { |
329 | // remember, according to ISO 8601, the first week of the year is the | 327 | // remember, according to ISO 8601, the first week of the year is the |
330 | // first week that contains a thursday. Thus we must subtract off 4, | 328 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 329 | // not just 1. |
332 | 330 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 331 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); | 332 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); |
335 | int weekNo; | 333 | int weekNo; |
336 | if (dayOfYear % 7 != 0) | 334 | if (dayOfYear % 7 != 0) |
337 | weekNo = (dayOfYear / 7 + 1); | 335 | weekNo = (dayOfYear / 7 + 1); |
338 | else | 336 | else |
339 | weekNo = (dayOfYear / 7); | 337 | weekNo = (dayOfYear / 7); |
340 | weeknos[i]->setText(QString::number( weekNo )); | 338 | weeknos[i]->setText(QString::number( weekNo )); |
341 | } | 339 | } |
342 | 340 | ||
343 | setUpdatesEnabled( true ); | 341 | setUpdatesEnabled( true ); |
344 | // kdDebug() << "updateView() -> repaint()" << endl; | 342 | // kdDebug() << "updateView() -> repaint()" << endl; |
345 | repaint(); | 343 | repaint(); |
346 | // daymatrix->repaint(); | 344 | // daymatrix->repaint(); |
347 | } | 345 | } |
348 | 346 | ||
349 | void KDateNavigator::updateConfig() | 347 | void KDateNavigator::updateConfig() |
350 | { | 348 | { |
351 | int day; | 349 | int day; |
352 | for(int i=0; i<7; i++) { | 350 | for(int i=0; i<7; i++) { |
353 | // take the first letter of the day name to be the abbreviation | 351 | // take the first letter of the day name to be the abbreviation |
354 | if (KGlobal::locale()->weekStartsMonday()) { | 352 | if (KGlobal::locale()->weekStartsMonday()) { |
355 | day = i+1; | 353 | day = i+1; |
356 | } else { | 354 | } else { |
357 | if (i==0) day = 7; | 355 | if (i==0) day = 7; |
358 | else day = i; | 356 | else day = i; |
359 | } | 357 | } |
360 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 358 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
361 | true ); | 359 | true ); |
362 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 360 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
363 | headings[i]->setText( dayName ); | 361 | headings[i]->setText( dayName ); |
364 | } | 362 | } |
365 | updateDates(); | 363 | updateDates(); |
366 | updateView(); | 364 | updateView(); |
367 | } | 365 | } |
368 | 366 | ||
369 | void KDateNavigator::setShowWeekNums(bool enabled) | 367 | void KDateNavigator::setShowWeekNums(bool enabled) |
370 | { | 368 | { |
371 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | 369 | |
372 | m_bShowWeekNums = enabled; | 370 | m_bShowWeekNums = enabled; |
373 | for(int i=0; i<6; i++) { | 371 | for(int i=0; i<6; i++) { |
374 | if(enabled) | 372 | if(enabled) |
375 | weeknos[i]->show(); | 373 | weeknos[i]->show(); |
376 | else | 374 | else |
377 | weeknos[i]->hide(); | 375 | weeknos[i]->hide(); |
378 | } | 376 | } |
379 | resize(size()); | 377 | resize(size()); |
380 | } | 378 | } |
381 | 379 | ||
382 | void KDateNavigator::selectDates(const DateList& dateList) | 380 | void KDateNavigator::selectDates(const DateList& dateList) |
383 | { | 381 | { |
384 | 382 | ||
385 | if (dateList.count() > 0) { | 383 | if (dateList.count() > 0) { |
386 | mNavigatorBar->selectDates( dateList ); | 384 | mNavigatorBar->selectDates( dateList ); |
387 | mSelectedDates = dateList; | 385 | mSelectedDates = dateList; |
388 | 386 | ||
389 | // set our record of the month and year that this datetbl is | 387 | // set our record of the month and year that this datetbl is |
390 | // displaying. | 388 | // displaying. |
391 | m_MthYr = mSelectedDates.first(); | 389 | m_MthYr = mSelectedDates.first(); |
392 | 390 | ||
393 | 391 | ||
394 | // set our record of the first day of the week of the current | 392 | // set our record of the first day of the week of the current |
395 | // month. This needs to be done before calling dayToIndex, since it | 393 | // month. This needs to be done before calling dayToIndex, since it |
396 | // relies on this information being up to date. | 394 | // relies on this information being up to date. |
397 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 395 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
398 | m_fstDayOfWk = dayone.dayOfWeek(); | 396 | m_fstDayOfWk = dayone.dayOfWeek(); |
399 | 397 | ||
400 | updateDates(); | 398 | updateDates(); |
401 | 399 | ||
402 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 400 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
403 | 401 | ||
404 | updateView(); | 402 | updateView(); |
405 | } | 403 | } |
406 | } | 404 | } |
407 | 405 | ||
408 | int KDateNavigator::dayNum(int row, int col) | 406 | int KDateNavigator::dayNum(int row, int col) |
409 | { | 407 | { |
410 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 408 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
411 | } | 409 | } |
412 | 410 | ||
413 | int KDateNavigator::dayToIndex(int dayNum) | 411 | int KDateNavigator::dayToIndex(int dayNum) |
414 | { | 412 | { |
415 | int row, col; | 413 | int row, col; |
416 | 414 | ||
417 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 415 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
418 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 416 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
419 | row++; | 417 | row++; |
420 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 418 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
421 | return row * 7 + col; | 419 | return row * 7 + col; |
422 | } | 420 | } |
423 | 421 | ||
424 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 422 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
425 | { | 423 | { |
426 | if(e->delta()>0) emit goPrevious(); | 424 | if(e->delta()>0) emit goPrevious(); |
427 | else emit goNext(); | 425 | else emit goNext(); |
428 | 426 | ||
429 | e->accept(); | 427 | e->accept(); |
430 | } | 428 | } |
431 | 429 | ||
432 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 430 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
433 | { | 431 | { |
434 | if (e->type() == QEvent::MouseButtonPress) { | 432 | if (e->type() == QEvent::MouseButtonPress) { |
435 | int i; | 433 | int i; |
436 | for(i=0;i<6;++i) { | 434 | for(i=0;i<6;++i) { |
437 | if (o == weeknos[i]) { | 435 | if (o == weeknos[i]) { |
438 | QDate weekstart = daymatrix->getDate(i*7); | 436 | QDate weekstart = daymatrix->getDate(i*7); |
439 | emit weekClicked(weekstart); | 437 | emit weekClicked(weekstart); |
440 | break; | 438 | break; |
441 | } | 439 | } |
442 | } | 440 | } |
443 | for(i=0;i<7;++i) { | 441 | for(i=0;i<7;++i) { |
444 | if (o == headings[i]) { | 442 | if (o == headings[i]) { |
445 | KCal::DateList selDays; | 443 | KCal::DateList selDays; |
446 | QDate date = daymatrix->getDate(14); | 444 | QDate date = daymatrix->getDate(14); |
447 | emit showMonth(date ); | 445 | emit showMonth(date ); |
448 | #if 0 | 446 | #if 0 |
449 | int dio = date.daysInMonth(); | 447 | int dio = date.daysInMonth(); |
450 | int j; | 448 | int j; |
451 | int ye = date.year(); | 449 | int ye = date.year(); |
452 | int mo = date.month(); | 450 | int mo = date.month(); |
453 | for ( j = 1; j <= dio; ++j ) { | 451 | for ( j = 1; j <= dio; ++j ) { |
454 | selDays.append( QDate( ye, mo, j ) ); | 452 | selDays.append( QDate( ye, mo, j ) ); |
455 | } | 453 | } |
456 | emit datesSelected( selDays ); | 454 | emit datesSelected( selDays ); |
457 | #endif | 455 | #endif |
458 | break; | 456 | break; |
459 | } | 457 | } |
460 | } | 458 | } |
461 | return true; | 459 | return true; |
462 | } else { | 460 | } else { |
463 | return false; | 461 | return false; |
464 | } | 462 | } |
465 | } | 463 | } |
466 | 464 | ||
467 | //#include "kdatenavigator.moc" | 465 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index b43c40e..b5a4199 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -727,636 +727,636 @@ void KOAgendaView::createDayLabels() | |||
727 | dayLabel->setNum( -1 ); | 727 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 728 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | 729 | ||
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
731 | dayLabel->show(); | 731 | dayLabel->show(); |
732 | DateList::ConstIterator dit; | 732 | DateList::ConstIterator dit; |
733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
734 | int counter = -1; | 734 | int counter = -1; |
735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
736 | ++counter; | 736 | ++counter; |
737 | QDate date = *dit; | 737 | QDate date = *dit; |
738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
739 | if ( ! appendLabels ) { | 739 | if ( ! appendLabels ) { |
740 | dayLabel = mDayLabelsList.next(); | 740 | dayLabel = mDayLabelsList.next(); |
741 | if ( !dayLabel ) | 741 | if ( !dayLabel ) |
742 | appendLabels = true; | 742 | appendLabels = true; |
743 | } | 743 | } |
744 | if ( appendLabels ) { | 744 | if ( appendLabels ) { |
745 | dayLabel = getNewDaylabel(); | 745 | dayLabel = getNewDaylabel(); |
746 | } | 746 | } |
747 | dayLabel->setMinimumWidth( 1 ); | 747 | dayLabel->setMinimumWidth( 1 ); |
748 | dayLabel->setMaximumWidth( 10240 ); | 748 | dayLabel->setMaximumWidth( 10240 ); |
749 | dayLabel->setFont( dlf ); | 749 | dayLabel->setFont( dlf ); |
750 | dayLabel->show(); | 750 | dayLabel->show(); |
751 | dayLabel->setAutoRepeat( false ); | 751 | dayLabel->setAutoRepeat( false ); |
752 | dayLabel->setNum( counter ); | 752 | dayLabel->setNum( counter ); |
753 | QString str; | 753 | QString str; |
754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
756 | switch ( maxLen ) { | 756 | switch ( maxLen ) { |
757 | case 2: | 757 | case 2: |
758 | str = QString::number( date.day() ); | 758 | str = QString::number( date.day() ); |
759 | break; | 759 | break; |
760 | 760 | ||
761 | case 3: | 761 | case 3: |
762 | str = dayName.left( 1 ) +QString::number( date.day()); | 762 | str = dayName.left( 1 ) +QString::number( date.day()); |
763 | 763 | ||
764 | break; | 764 | break; |
765 | case 4: | 765 | case 4: |
766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
767 | 767 | ||
768 | break; | 768 | break; |
769 | case 5: | 769 | case 5: |
770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
771 | 771 | ||
772 | break; | 772 | break; |
773 | case 6: | 773 | case 6: |
774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
775 | break; | 775 | break; |
776 | 776 | ||
777 | default: | 777 | default: |
778 | break; | 778 | break; |
779 | } | 779 | } |
780 | if ( oneday ) { | 780 | if ( oneday ) { |
781 | QString addString; | 781 | QString addString; |
782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
783 | addString = i18n("Today"); | 783 | addString = i18n("Today"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
785 | addString = i18n("Tomorrow"); | 785 | addString = i18n("Tomorrow"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
787 | addString = i18n("Yesterday"); | 787 | addString = i18n("Yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
789 | addString = i18n("Day before yesterday"); | 789 | addString = i18n("Day before yesterday"); |
790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
791 | addString = i18n("Day after tomorrow"); | 791 | addString = i18n("Day after tomorrow"); |
792 | if ( !addString.isEmpty() ) { | 792 | if ( !addString.isEmpty() ) { |
793 | str = addString+", " + str; | 793 | str = addString+", " + str; |
794 | } else { | 794 | } else { |
795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | dayLabel->setText(str); | 798 | dayLabel->setText(str); |
799 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 799 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
800 | if (date == QDate::currentDate()) { | 800 | if (date == QDate::currentDate()) { |
801 | QFont bFont = dlf; | 801 | QFont bFont = dlf; |
802 | bFont.setBold( true ); | 802 | bFont.setBold( true ); |
803 | dayLabel->setFont(bFont); | 803 | dayLabel->setFont(bFont); |
804 | } | 804 | } |
805 | //dayLayout->addWidget(dayLabel); | 805 | //dayLayout->addWidget(dayLabel); |
806 | 806 | ||
807 | #ifndef KORG_NOPLUGINS | 807 | #ifndef KORG_NOPLUGINS |
808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
809 | CalendarDecoration *it; | 809 | CalendarDecoration *it; |
810 | for(it = cds.first(); it; it = cds.next()) { | 810 | for(it = cds.first(); it; it = cds.next()) { |
811 | QString text = it->shortText( date ); | 811 | QString text = it->shortText( date ); |
812 | if ( !text.isEmpty() ) { | 812 | if ( !text.isEmpty() ) { |
813 | QLabel *label = new QLabel(text,mDayLabels); | 813 | QLabel *label = new QLabel(text,mDayLabels); |
814 | label->setAlignment(AlignCenter); | 814 | label->setAlignment(AlignCenter); |
815 | dayLayout->addWidget(label); | 815 | dayLayout->addWidget(label); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | for(it = cds.first(); it; it = cds.next()) { | 819 | for(it = cds.first(); it; it = cds.next()) { |
820 | QWidget *wid = it->smallWidget(mDayLabels,date); | 820 | QWidget *wid = it->smallWidget(mDayLabels,date); |
821 | if ( wid ) { | 821 | if ( wid ) { |
822 | // wid->setHeight(20); | 822 | // wid->setHeight(20); |
823 | dayLayout->addWidget(wid); | 823 | dayLayout->addWidget(wid); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | #endif | 826 | #endif |
827 | } | 827 | } |
828 | if ( ! appendLabels ) { | 828 | if ( ! appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
830 | if ( !dayLabel ) | 830 | if ( !dayLabel ) |
831 | appendLabels = true; | 831 | appendLabels = true; |
832 | } | 832 | } |
833 | if ( appendLabels ) { | 833 | if ( appendLabels ) { |
834 | dayLabel = getNewDaylabel(); | 834 | dayLabel = getNewDaylabel(); |
835 | } | 835 | } |
836 | //dayLabel->hide();//test only | 836 | //dayLabel->hide();//test only |
837 | 837 | ||
838 | dayLabel->setText(">"); | 838 | dayLabel->setText(">"); |
839 | dayLabel->setFont( dlf ); | 839 | dayLabel->setFont( dlf ); |
840 | dayLabel->setAutoRepeat( true ); | 840 | dayLabel->setAutoRepeat( true ); |
841 | dayLabel->show(); | 841 | dayLabel->show(); |
842 | dayLabel->setNum( -2 ); | 842 | dayLabel->setNum( -2 ); |
843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
844 | 844 | ||
845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | if ( !appendLabels ) { | 846 | if ( !appendLabels ) { |
847 | dayLabel = mDayLabelsList.next(); | 847 | dayLabel = mDayLabelsList.next(); |
848 | while ( dayLabel ) { | 848 | while ( dayLabel ) { |
849 | //qDebug("!dayLabel %d",dayLabel ); | 849 | //qDebug("!dayLabel %d",dayLabel ); |
850 | dayLabel->hide(); | 850 | dayLabel->hide(); |
851 | dayLabel = mDayLabelsList.next(); | 851 | dayLabel = mDayLabelsList.next(); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
856 | } | 856 | } |
857 | 857 | ||
858 | int KOAgendaView::maxDatesHint() | 858 | int KOAgendaView::maxDatesHint() |
859 | { | 859 | { |
860 | // Not sure about the max number of events, so return 0 for now. | 860 | // Not sure about the max number of events, so return 0 for now. |
861 | return 0; | 861 | return 0; |
862 | } | 862 | } |
863 | 863 | ||
864 | int KOAgendaView::currentDateCount() | 864 | int KOAgendaView::currentDateCount() |
865 | { | 865 | { |
866 | return mSelectedDates.count(); | 866 | return mSelectedDates.count(); |
867 | } | 867 | } |
868 | 868 | ||
869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
870 | { | 870 | { |
871 | QPtrList<Incidence> selected; | 871 | QPtrList<Incidence> selected; |
872 | Incidence *incidence; | 872 | Incidence *incidence; |
873 | 873 | ||
874 | incidence = mAgenda->selectedIncidence(); | 874 | incidence = mAgenda->selectedIncidence(); |
875 | if (incidence) selected.append(incidence); | 875 | if (incidence) selected.append(incidence); |
876 | 876 | ||
877 | incidence = mAllDayAgenda->selectedIncidence(); | 877 | incidence = mAllDayAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | return selected; | 880 | return selected; |
881 | } | 881 | } |
882 | 882 | ||
883 | DateList KOAgendaView::selectedDates() | 883 | DateList KOAgendaView::selectedDates() |
884 | { | 884 | { |
885 | DateList selected; | 885 | DateList selected; |
886 | QDate qd; | 886 | QDate qd; |
887 | 887 | ||
888 | qd = mAgenda->selectedIncidenceDate(); | 888 | qd = mAgenda->selectedIncidenceDate(); |
889 | if (qd.isValid()) selected.append(qd); | 889 | if (qd.isValid()) selected.append(qd); |
890 | 890 | ||
891 | qd = mAllDayAgenda->selectedIncidenceDate(); | 891 | qd = mAllDayAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | return selected; | 894 | return selected; |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | void KOAgendaView::updateView() | 898 | void KOAgendaView::updateView() |
899 | { | 899 | { |
900 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
901 | return; | 901 | return; |
902 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
903 | fillAgenda(); | 903 | fillAgenda(); |
904 | 904 | ||
905 | } | 905 | } |
906 | 906 | ||
907 | 907 | ||
908 | /* | 908 | /* |
909 | Update configuration settings for the agenda view. This method is not | 909 | Update configuration settings for the agenda view. This method is not |
910 | complete. | 910 | complete. |
911 | */ | 911 | */ |
912 | void KOAgendaView::updateConfig() | 912 | void KOAgendaView::updateConfig() |
913 | { | 913 | { |
914 | if ( mBlockUpdating ) | 914 | if ( mBlockUpdating ) |
915 | return; | 915 | return; |
916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
917 | int old = KOPrefs::instance()->mHourSize; | 917 | int old = KOPrefs::instance()->mHourSize; |
918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
919 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 919 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
920 | } | 920 | } |
921 | 921 | ||
922 | 922 | ||
923 | // update config for children | 923 | // update config for children |
924 | mTimeLabels->updateConfig(); | 924 | mTimeLabels->updateConfig(); |
925 | mAgenda->storePosition(); | 925 | mAgenda->storePosition(); |
926 | mAgenda->updateConfig(); | 926 | mAgenda->updateConfig(); |
927 | mAllDayAgenda->updateConfig(); | 927 | mAllDayAgenda->updateConfig(); |
928 | // widget synchronization | 928 | // widget synchronization |
929 | //TODO: find a better way, maybe signal/slot | 929 | //TODO: find a better way, maybe signal/slot |
930 | mTimeLabels->positionChanged(); | 930 | mTimeLabels->positionChanged(); |
931 | 931 | ||
932 | // for some reason, this needs to be called explicitly | 932 | // for some reason, this needs to be called explicitly |
933 | mTimeLabels->repaint(); | 933 | mTimeLabels->repaint(); |
934 | 934 | ||
935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
936 | 936 | ||
937 | // ToolTips displaying summary of events | 937 | // ToolTips displaying summary of events |
938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
939 | ->mEnableToolTips); | 939 | ->mEnableToolTips); |
940 | 940 | ||
941 | //setHolidayMasks(); | 941 | //setHolidayMasks(); |
942 | 942 | ||
943 | //createDayLabels(); called by via updateView(); | 943 | //createDayLabels(); called by via updateView(); |
944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
945 | updateView(); | 945 | updateView(); |
946 | mAgenda->restorePosition(); | 946 | mAgenda->restorePosition(); |
947 | } | 947 | } |
948 | 948 | ||
949 | 949 | ||
950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
951 | { | 951 | { |
952 | 952 | ||
953 | 953 | ||
954 | int xxx = item->cellX(); | 954 | int xxx = item->cellX(); |
955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
956 | if ( mMinY.at(xxx) > item->cellYTop() ) | 956 | if ( mMinY.at(xxx) > item->cellYTop() ) |
957 | mMinY.at(xxx) = item->cellYTop(); | 957 | mMinY.at(xxx) = item->cellYTop(); |
958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
959 | mMaxY.at(xxx) = item->cellYBottom(); | 959 | mMaxY.at(xxx) = item->cellYBottom(); |
960 | 960 | ||
961 | QDateTime startDt,endDt; | 961 | QDateTime startDt,endDt; |
962 | QDate startDate; | 962 | QDate startDate; |
963 | int lenInSecs; | 963 | int lenInSecs; |
964 | // if ( type == KOAgenda::RESIZETOP ) | 964 | // if ( type == KOAgenda::RESIZETOP ) |
965 | // qDebug("RESIZETOP "); | 965 | // qDebug("RESIZETOP "); |
966 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 966 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
967 | // qDebug("RESIZEBOTTOM "); | 967 | // qDebug("RESIZEBOTTOM "); |
968 | // if ( type == KOAgenda::MOVE ) | 968 | // if ( type == KOAgenda::MOVE ) |
969 | // qDebug("MOVE "); | 969 | // qDebug("MOVE "); |
970 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->type() == "Event" ) { |
971 | startDt =item->incidence()->dtStart(); | 971 | startDt =item->incidence()->dtStart(); |
972 | endDt = item->incidence()->dtEnd(); | 972 | endDt = item->incidence()->dtEnd(); |
973 | lenInSecs = startDt.secsTo( endDt ); | 973 | lenInSecs = startDt.secsTo( endDt ); |
974 | } | 974 | } |
975 | 975 | ||
976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
977 | 977 | ||
978 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 978 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
979 | startDate = mSelectedDates[item->mLastMoveXPos]; | 979 | startDate = mSelectedDates[item->mLastMoveXPos]; |
980 | } else { | 980 | } else { |
981 | if (item->cellX() < 0) { | 981 | if (item->cellX() < 0) { |
982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
983 | } else { | 983 | } else { |
984 | startDate = mSelectedDates[item->cellX()]; | 984 | startDate = mSelectedDates[item->cellX()]; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | startDt.setDate(startDate); | 987 | startDt.setDate(startDate); |
988 | 988 | ||
989 | if (item->incidence()->doesFloat()) { | 989 | if (item->incidence()->doesFloat()) { |
990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
991 | } else { | 991 | } else { |
992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
994 | if ( item->incidence()->type() == "Event" ) { | 994 | if ( item->incidence()->type() == "Event" ) { |
995 | if ( type == KOAgenda::MOVE ) { | 995 | if ( type == KOAgenda::MOVE ) { |
996 | endDt = startDt.addSecs(lenInSecs); | 996 | endDt = startDt.addSecs(lenInSecs); |
997 | 997 | ||
998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
999 | if (item->lastMultiItem()) { | 999 | if (item->lastMultiItem()) { |
1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1001 | endDt.setDate(startDate. | 1001 | endDt.setDate(startDate. |
1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1003 | } else { | 1003 | } else { |
1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1005 | endDt.setDate(startDate); | 1005 | endDt.setDate(startDate); |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | } else { | 1008 | } else { |
1009 | // todo | 1009 | // todo |
1010 | if (item->lastMultiItem()) { | 1010 | if (item->lastMultiItem()) { |
1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1012 | endDt.setDate(startDate. | 1012 | endDt.setDate(startDate. |
1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1014 | } else { | 1014 | } else { |
1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1016 | if ( item->cellYBottom() > 0 ) | 1016 | if ( item->cellYBottom() > 0 ) |
1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1018 | else | 1018 | else |
1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1020 | endDt.setDate(startDate); | 1020 | endDt.setDate(startDate); |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | if ( item->incidence()->type() == "Event" ) { | 1024 | if ( item->incidence()->type() == "Event" ) { |
1025 | item->incidence()->setDtStart(startDt); | 1025 | item->incidence()->setDtStart(startDt); |
1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1027 | } else if ( item->incidence()->type() == "Todo" ) { | 1027 | } else if ( item->incidence()->type() == "Todo" ) { |
1028 | Todo* to = static_cast<Todo*>(item->incidence()); | 1028 | Todo* to = static_cast<Todo*>(item->incidence()); |
1029 | 1029 | ||
1030 | to->setDtDue(endDt); | 1030 | to->setDtDue(endDt); |
1031 | if ( to->hasStartDate() ) { | 1031 | if ( to->hasStartDate() ) { |
1032 | if (to->dtStart() >= to->dtDue() ) | 1032 | if (to->dtStart() >= to->dtDue() ) |
1033 | to->setDtStart(to->dtDue().addDays( -2 )); | 1033 | to->setDtStart(to->dtDue().addDays( -2 )); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | } | 1036 | } |
1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1038 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1038 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1039 | item->setItemDate(startDt.date()); | 1039 | item->setItemDate(startDt.date()); |
1040 | //item->updateItem(); | 1040 | //item->updateItem(); |
1041 | if ( item->incidence()->type() == "Todo" ) { | 1041 | if ( item->incidence()->type() == "Todo" ) { |
1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | else | 1045 | else |
1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1047 | item->updateItem(); | 1047 | item->updateItem(); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1051 | { | 1051 | { |
1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1053 | 1053 | ||
1054 | mSelectedDates.clear(); | 1054 | mSelectedDates.clear(); |
1055 | // qDebug("KOAgendaView::showDates "); | 1055 | // qDebug("KOAgendaView::showDates "); |
1056 | QDate d = start; | 1056 | QDate d = start; |
1057 | while (d <= end) { | 1057 | while (d <= end) { |
1058 | mSelectedDates.append(d); | 1058 | mSelectedDates.append(d); |
1059 | d = d.addDays( 1 ); | 1059 | d = d.addDays( 1 ); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | // and update the view | 1062 | // and update the view |
1063 | fillAgenda(); | 1063 | fillAgenda(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | 1066 | ||
1067 | void KOAgendaView::showEvents(QPtrList<Event>) | 1067 | void KOAgendaView::showEvents(QPtrList<Event>) |
1068 | { | 1068 | { |
1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KOAgendaView::changeEventDisplay(Event *, int) | 1072 | void KOAgendaView::changeEventDisplay(Event *, int) |
1073 | { | 1073 | { |
1074 | // qDebug("KOAgendaView::changeEventDisplay "); | 1074 | // qDebug("KOAgendaView::changeEventDisplay "); |
1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1076 | // this should be re-written to be MUCH smarter. Right now we | 1076 | // this should be re-written to be MUCH smarter. Right now we |
1077 | // are just playing dumb. | 1077 | // are just playing dumb. |
1078 | fillAgenda(); | 1078 | fillAgenda(); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void KOAgendaView::fillAgenda(const QDate &) | 1081 | void KOAgendaView::fillAgenda(const QDate &) |
1082 | { | 1082 | { |
1083 | // qDebug("KOAgendaView::fillAgenda "); | 1083 | // qDebug("KOAgendaView::fillAgenda "); |
1084 | fillAgenda(); | 1084 | fillAgenda(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void KOAgendaView::fillAgenda() | 1087 | void KOAgendaView::fillAgenda() |
1088 | { | 1088 | { |
1089 | if ( globalFlagBlockStartup ) | 1089 | if ( globalFlagBlockStartup ) |
1090 | return; | 1090 | return; |
1091 | if ( globalFlagBlockAgenda == 1 ) | 1091 | if ( globalFlagBlockAgenda == 1 ) |
1092 | return; | 1092 | return; |
1093 | static bool onlyOne = false; | 1093 | static bool onlyOne = false; |
1094 | if ( onlyOne ) | 1094 | if ( onlyOne ) |
1095 | return; | 1095 | return; |
1096 | onlyOne = true; | 1096 | onlyOne = true; |
1097 | //if ( globalFlagBlockAgenda == 2 ) | 1097 | //if ( globalFlagBlockAgenda == 2 ) |
1098 | //globalFlagBlockAgenda = 0; | 1098 | //globalFlagBlockAgenda = 0; |
1099 | // globalFlagBlockPainting = false; | 1099 | // globalFlagBlockPainting = false; |
1100 | if ( globalFlagBlockAgenda == 0 ) | 1100 | if ( globalFlagBlockAgenda == 0 ) |
1101 | globalFlagBlockAgenda = 1; | 1101 | globalFlagBlockAgenda = 1; |
1102 | // clearView(); | 1102 | // clearView(); |
1103 | //qDebug("fillAgenda()++++ "); | 1103 | //qDebug("fillAgenda()++++ "); |
1104 | globalFlagBlockAgendaItemPaint = 1; | 1104 | globalFlagBlockAgendaItemPaint = 1; |
1105 | 1105 | ||
1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1107 | mAgenda->changeColumns(mSelectedDates.count()); | 1107 | mAgenda->changeColumns(mSelectedDates.count()); |
1108 | qApp->processEvents(); | 1108 | qApp->processEvents(); |
1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1111 | setHolidayMasks(); | 1111 | setHolidayMasks(); |
1112 | 1112 | ||
1113 | //mAgenda->hideUnused(); | 1113 | //mAgenda->hideUnused(); |
1114 | //mAllDayAgenda->hideUnused(); | 1114 | //mAllDayAgenda->hideUnused(); |
1115 | 1115 | ||
1116 | // mAgenda->blockNextRepaint( false ); | 1116 | // mAgenda->blockNextRepaint( false ); |
1117 | // mAgenda->viewport()->repaint(); | 1117 | // mAgenda->viewport()->repaint(); |
1118 | // mAgenda->blockNextRepaint( true ); | 1118 | // mAgenda->blockNextRepaint( true ); |
1119 | mMinY.resize(mSelectedDates.count()); | 1119 | mMinY.resize(mSelectedDates.count()); |
1120 | mMaxY.resize(mSelectedDates.count()); | 1120 | mMaxY.resize(mSelectedDates.count()); |
1121 | 1121 | ||
1122 | QPtrList<Event> dayEvents; | 1122 | QPtrList<Event> dayEvents; |
1123 | 1123 | ||
1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1125 | // Therefore, gtodoset all of them. | 1125 | // Therefore, gtodoset all of them. |
1126 | QPtrList<Todo> todos = calendar()->todos(); | 1126 | QPtrList<Todo> todos = calendar()->todos(); |
1127 | 1127 | ||
1128 | mAgenda->setDateList(mSelectedDates); | 1128 | mAgenda->setDateList(mSelectedDates); |
1129 | 1129 | ||
1130 | QDate today = QDate::currentDate(); | 1130 | QDate today = QDate::currentDate(); |
1131 | 1131 | ||
1132 | DateList::ConstIterator dit; | 1132 | DateList::ConstIterator dit; |
1133 | int curCol = 0; | 1133 | int curCol = 0; |
1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1135 | QDate currentDate = *dit; | 1135 | QDate currentDate = *dit; |
1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1137 | // << endl; | 1137 | // << endl; |
1138 | 1138 | ||
1139 | dayEvents = calendar()->events(currentDate,true); | 1139 | dayEvents = calendar()->events(currentDate,true); |
1140 | 1140 | ||
1141 | // Default values, which can never be reached | 1141 | // Default values, which can never be reached |
1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1144 | 1144 | ||
1145 | unsigned int numEvent; | 1145 | unsigned int numEvent; |
1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1147 | Event *event = dayEvents.at(numEvent); | 1147 | Event *event = dayEvents.at(numEvent); |
1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1150 | continue; | 1150 | continue; |
1151 | // kdDebug() << " Event: " << event->summary() << endl; | 1151 | // kdDebug() << " Event: " << event->summary() << endl; |
1152 | 1152 | ||
1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1155 | 1155 | ||
1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1157 | 1157 | ||
1158 | if (event->doesFloat()) { | 1158 | if (event->doesFloat()) { |
1159 | if (event->recurrence()->doesRecur()) { | 1159 | if (event->recurrence()->doesRecur()) { |
1160 | if (event->isMultiDay() ) { | 1160 | if (event->isMultiDay() ) { |
1161 | endX = endX - beginX;// endX is now number of days | 1161 | endX = endX - beginX;// endX is now number of days |
1162 | if ( event->recursOn( currentDate ) ) { | 1162 | if ( event->recursOn( currentDate ) ) { |
1163 | endX += curCol; | 1163 | endX += curCol; |
1164 | beginX = curCol; | 1164 | beginX = curCol; |
1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1166 | } else { | 1166 | } else { |
1167 | qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1167 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); |
1168 | QDate dateit = currentDate.addDays( -endX ); | 1168 | QDate dateit = currentDate.addDays( -endX ); |
1169 | if ( event->recursOn( dateit ) ) { | 1169 | if ( event->recursOn( dateit ) ) { |
1170 | qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1170 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1171 | if ( curCol-endX < 0 ) { | 1171 | if ( curCol-endX < 0 ) { |
1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | } else { | 1176 | } else { |
1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | } else { | 1180 | } else { |
1181 | if (beginX <= 0 && curCol == 0) { | 1181 | if (beginX <= 0 && curCol == 0) { |
1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1183 | } else if (beginX == curCol) { | 1183 | } else if (beginX == curCol) { |
1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | } else if (event->isMultiDay()) { | 1187 | } else if (event->isMultiDay()) { |
1188 | if ( event->doesRecur () ) { | 1188 | if ( event->doesRecur () ) { |
1189 | QDate dateit = currentDate; | 1189 | QDate dateit = currentDate; |
1190 | int count = 0; | 1190 | int count = 0; |
1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1192 | while (! event->recursOn( dateit ) && count <= max ) { | 1192 | while (! event->recursOn( dateit ) && count <= max ) { |
1193 | ++count; | 1193 | ++count; |
1194 | dateit = dateit.addDays( -1 ); | 1194 | dateit = dateit.addDays( -1 ); |
1195 | } | 1195 | } |
1196 | bool ok; | 1196 | bool ok; |
1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1198 | if ( ok ) | 1198 | if ( ok ) |
1199 | { | 1199 | { |
1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1207 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1211 | //qDebug("insert!!! "); | 1211 | //qDebug("insert!!! "); |
1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1213 | } | 1213 | } |
1214 | if (beginX == curCol) { | 1214 | if (beginX == curCol) { |
1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1217 | } else if (endX == curCol) { | 1217 | } else if (endX == curCol) { |
1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1220 | } else { | 1220 | } else { |
1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1223 | } | 1223 | } |
1224 | } else { | 1224 | } else { |
1225 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1225 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1227 | if (endY < startY) endY = startY; | 1227 | if (endY < startY) endY = startY; |
1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | // ---------- [display Todos -------------- | 1233 | // ---------- [display Todos -------------- |
1234 | unsigned int numTodo; | 1234 | unsigned int numTodo; |
1235 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1235 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1236 | Todo *todo = todos.at(numTodo); | 1236 | Todo *todo = todos.at(numTodo); |
1237 | 1237 | ||
1238 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1238 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1239 | 1239 | ||
1240 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1240 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1241 | // Already completed items can be displayed on their original due date | 1241 | // Already completed items can be displayed on their original due date |
1242 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1242 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1243 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1243 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1244 | bool fillIn = false; | 1244 | bool fillIn = false; |
1245 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1245 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1246 | fillIn = true; | 1246 | fillIn = true; |
1247 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1247 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1248 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1248 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1249 | if ( fillIn ) { | 1249 | if ( fillIn ) { |
1250 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1250 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1251 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1251 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1252 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1252 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1253 | } | 1253 | } |
1254 | else { | 1254 | else { |
1255 | QDateTime dt; | 1255 | QDateTime dt; |
1256 | if ( todo->hasCompletedDate() ) | 1256 | if ( todo->hasCompletedDate() ) |
1257 | dt = todo->completed(); | 1257 | dt = todo->completed(); |
1258 | else | 1258 | else |
1259 | dt = todo->dtDue();; | 1259 | dt = todo->dtDue();; |
1260 | 1260 | ||
1261 | 1261 | ||
1262 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1262 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1263 | int hi = (18/KOPrefs::instance()->mHourSize); | 1263 | int hi = (18/KOPrefs::instance()->mHourSize); |
1264 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1264 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1265 | int startY = endY -hi; | 1265 | int startY = endY -hi; |
1266 | 1266 | ||
1267 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1267 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1268 | 1268 | ||
1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1270 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1270 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | // ---------- display Todos] -------------- | 1274 | // ---------- display Todos] -------------- |
1275 | 1275 | ||
1276 | ++curCol; | 1276 | ++curCol; |
1277 | } | 1277 | } |
1278 | mAgenda->hideUnused(); | 1278 | mAgenda->hideUnused(); |
1279 | mAllDayAgenda->hideUnused(); | 1279 | mAllDayAgenda->hideUnused(); |
1280 | mAgenda->checkScrollBoundaries(); | 1280 | mAgenda->checkScrollBoundaries(); |
1281 | 1281 | ||
1282 | deleteSelectedDateTime(); | 1282 | deleteSelectedDateTime(); |
1283 | 1283 | ||
1284 | createDayLabels(); | 1284 | createDayLabels(); |
1285 | emit incidenceSelected( 0 ); | 1285 | emit incidenceSelected( 0 ); |
1286 | 1286 | ||
1287 | if ( globalFlagBlockAgenda == 2 ) { | 1287 | if ( globalFlagBlockAgenda == 2 ) { |
1288 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1288 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1289 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1289 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1290 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1290 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1291 | setStartHour( QTime::currentTime ().hour() ); | 1291 | setStartHour( QTime::currentTime ().hour() ); |
1292 | // qApp->processEvents(); | 1292 | // qApp->processEvents(); |
1293 | } | 1293 | } |
1294 | qApp->processEvents(); | 1294 | qApp->processEvents(); |
1295 | //qDebug("qApp->processEvents(); END "); | 1295 | //qDebug("qApp->processEvents(); END "); |
1296 | globalFlagBlockAgenda = 0; | 1296 | globalFlagBlockAgenda = 0; |
1297 | 1297 | ||
1298 | // mAgenda->hideUnused(); | 1298 | // mAgenda->hideUnused(); |
1299 | //mAllDayAgenda->hideUnused(); | 1299 | //mAllDayAgenda->hideUnused(); |
1300 | mAllDayAgenda->drawContentsToPainter(); | 1300 | mAllDayAgenda->drawContentsToPainter(); |
1301 | mAgenda->drawContentsToPainter(); | 1301 | mAgenda->drawContentsToPainter(); |
1302 | repaintAgenda(); | 1302 | repaintAgenda(); |
1303 | onlyOne = false; | 1303 | onlyOne = false; |
1304 | // mAgenda->finishUpdate(); | 1304 | // mAgenda->finishUpdate(); |
1305 | //mAllDayAgenda->finishUpdate(); | 1305 | //mAllDayAgenda->finishUpdate(); |
1306 | 1306 | ||
1307 | // repaintAgenda(); | 1307 | // repaintAgenda(); |
1308 | //qApp->processEvents(); | 1308 | //qApp->processEvents(); |
1309 | // globalFlagBlockAgenda = 0; | 1309 | // globalFlagBlockAgenda = 0; |
1310 | } | 1310 | } |
1311 | void KOAgendaView::repaintAgenda() | 1311 | void KOAgendaView::repaintAgenda() |
1312 | { | 1312 | { |
1313 | // mAllDayAgenda->drawContentsToPainter(); | 1313 | // mAllDayAgenda->drawContentsToPainter(); |
1314 | // mAllDayAgenda->viewport()->repaint( false ); | 1314 | // mAllDayAgenda->viewport()->repaint( false ); |
1315 | // mAgenda->drawContentsToPainter(); | 1315 | // mAgenda->drawContentsToPainter(); |
1316 | // mAgenda->viewport()->repaint( false ); | 1316 | // mAgenda->viewport()->repaint( false ); |
1317 | // qApp->processEvents(); | 1317 | // qApp->processEvents(); |
1318 | 1318 | ||
1319 | //qDebug("KOAgendaView::repaintAgenda() "); | 1319 | //qDebug("KOAgendaView::repaintAgenda() "); |
1320 | //qApp->processEvents(); | 1320 | //qApp->processEvents(); |
1321 | mAgenda->viewport()->repaint( false ); | 1321 | mAgenda->viewport()->repaint( false ); |
1322 | mAllDayAgenda->viewport()->repaint( false ); | 1322 | mAllDayAgenda->viewport()->repaint( false ); |
1323 | mAgenda->finishUpdate(); | 1323 | mAgenda->finishUpdate(); |
1324 | mAllDayAgenda->finishUpdate(); | 1324 | mAllDayAgenda->finishUpdate(); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | 1327 | ||
1328 | void KOAgendaView::clearView() | 1328 | void KOAgendaView::clearView() |
1329 | { | 1329 | { |
1330 | // kdDebug() << "ClearView" << endl; | 1330 | // kdDebug() << "ClearView" << endl; |
1331 | mAllDayAgenda->clear(); | 1331 | mAllDayAgenda->clear(); |
1332 | mAgenda->clear(); | 1332 | mAgenda->clear(); |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1335 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1336 | const QDate &td) | 1336 | const QDate &td) |
1337 | { | 1337 | { |
1338 | #ifndef KORG_NOPRINTER | 1338 | #ifndef KORG_NOPRINTER |
1339 | if (fd == td) | 1339 | if (fd == td) |
1340 | calPrinter->preview(CalPrinter::Day, fd, td); | 1340 | calPrinter->preview(CalPrinter::Day, fd, td); |
1341 | else | 1341 | else |
1342 | calPrinter->preview(CalPrinter::Week, fd, td); | 1342 | calPrinter->preview(CalPrinter::Week, fd, td); |
1343 | #endif | 1343 | #endif |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | // void KOAgendaView::updateMovedTodo() | 1346 | // void KOAgendaView::updateMovedTodo() |
1347 | // { | 1347 | // { |
1348 | // // updateConfig(); | 1348 | // // updateConfig(); |
1349 | // // emit updateTodoViews(); | 1349 | // // emit updateTodoViews(); |
1350 | // } | 1350 | // } |
1351 | 1351 | ||
1352 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1352 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1353 | { | 1353 | { |
1354 | if ( d >= mSelectedDates.count() ) { | 1354 | if ( d >= mSelectedDates.count() ) { |
1355 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1355 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1356 | 1356 | ||
1357 | } else { | 1357 | } else { |
1358 | QDate day = mSelectedDates[d]; | 1358 | QDate day = mSelectedDates[d]; |
1359 | emit showDateView(mode , day ); | 1359 | emit showDateView(mode , day ); |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | } | 1362 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ecca374..17a1d13 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -308,385 +308,384 @@ bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | |||
308 | } | 308 | } |
309 | 309 | ||
310 | return true; | 310 | return true; |
311 | } | 311 | } |
312 | void KODayMatrix::clearSelection() | 312 | void KODayMatrix::clearSelection() |
313 | { | 313 | { |
314 | mSelEnd = mSelStart = NOSELECTION; | 314 | mSelEnd = mSelStart = NOSELECTION; |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void KODayMatrix::recalculateToday() | 318 | void KODayMatrix::recalculateToday() |
319 | { | 319 | { |
320 | today = -1; | 320 | today = -1; |
321 | for (int i=0; i<NUMDAYS; i++) { | 321 | for (int i=0; i<NUMDAYS; i++) { |
322 | //events[i] = 0; | 322 | //events[i] = 0; |
323 | days[i] = startdate.addDays(i); | 323 | days[i] = startdate.addDays(i); |
324 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 324 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
325 | 325 | ||
326 | // if today is in the currently displayed month, hilight today | 326 | // if today is in the currently displayed month, hilight today |
327 | if (days[i].year() == QDate::currentDate().year() && | 327 | if (days[i].year() == QDate::currentDate().year() && |
328 | days[i].month() == QDate::currentDate().month() && | 328 | days[i].month() == QDate::currentDate().month() && |
329 | days[i].day() == QDate::currentDate().day()) { | 329 | days[i].day() == QDate::currentDate().day()) { |
330 | today = i; | 330 | today = i; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | // qDebug(QString("Today is visible at %1.").arg(today)); | 333 | // qDebug(QString("Today is visible at %1.").arg(today)); |
334 | } | 334 | } |
335 | 335 | ||
336 | void KODayMatrix::updateView() | 336 | void KODayMatrix::updateView() |
337 | { | 337 | { |
338 | updateView(startdate); | 338 | updateView(startdate); |
339 | } | 339 | } |
340 | void KODayMatrix::repaintViewTimed() | 340 | void KODayMatrix::repaintViewTimed() |
341 | { | 341 | { |
342 | mRedrawNeeded = true; | 342 | mRedrawNeeded = true; |
343 | // bDays.fill( false); | 343 | // bDays.fill( false); |
344 | //pDays.fill( false); | 344 | //pDays.fill( false); |
345 | //hDays.fill( false); | 345 | //hDays.fill( false); |
346 | //eDays.fill( false); | 346 | //eDays.fill( false); |
347 | mRepaintTimer->stop(); | 347 | mRepaintTimer->stop(); |
348 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 348 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
349 | int i; | 349 | int i; |
350 | for(i = 0; i < NUMDAYS; i++) { | 350 | for(i = 0; i < NUMDAYS; i++) { |
351 | if ( ( (i+startDay) % 7 == 0 ) ) { | 351 | if ( ( (i+startDay) % 7 == 0 ) ) { |
352 | pDays.setBit(i); | 352 | pDays.setBit(i); |
353 | } | 353 | } |
354 | } | 354 | } |
355 | repaint(false); | 355 | repaint(false); |
356 | } | 356 | } |
357 | void KODayMatrix::computeEvent(Event *event, int i ) | 357 | void KODayMatrix::computeEvent(Event *event, int i ) |
358 | { | 358 | { |
359 | QString holiStr = mHolidays[i]; | 359 | QString holiStr = mHolidays[i]; |
360 | if ( event->isHoliday()) { | 360 | if ( event->isHoliday()) { |
361 | pDays.setBit(i); | 361 | pDays.setBit(i); |
362 | hDays.setBit(i); | 362 | hDays.setBit(i); |
363 | if ( !holiStr.isEmpty() ) | 363 | if ( !holiStr.isEmpty() ) |
364 | holiStr += "\n"; | 364 | holiStr += "\n"; |
365 | holiStr += event->summary(); | 365 | holiStr += event->summary(); |
366 | if ( !event->location().isEmpty() ) | 366 | if ( !event->location().isEmpty() ) |
367 | holiStr += " (" + event->location() + ")"; | 367 | holiStr += " (" + event->location() + ")"; |
368 | mHolidays[i] =holiStr ; | 368 | mHolidays[i] =holiStr ; |
369 | } | 369 | } |
370 | if ( event->isBirthday()) { | 370 | if ( event->isBirthday()) { |
371 | pDays.setBit(i); | 371 | pDays.setBit(i); |
372 | if ( !holiStr.isEmpty() ) | 372 | if ( !holiStr.isEmpty() ) |
373 | holiStr += "\n"; | 373 | holiStr += "\n"; |
374 | holiStr += i18n("Birthday") + ": "+event->summary(); | 374 | holiStr += i18n("Birthday") + ": "+event->summary(); |
375 | if ( !event->location().isEmpty() ) | 375 | if ( !event->location().isEmpty() ) |
376 | holiStr += " (" + event->location() + ")"; | 376 | holiStr += " (" + event->location() + ")"; |
377 | bDays.setBit(i); | 377 | bDays.setBit(i); |
378 | mHolidays[i] =holiStr ; | 378 | mHolidays[i] =holiStr ; |
379 | } | 379 | } |
380 | eDays.setBit(i); | 380 | eDays.setBit(i); |
381 | } | 381 | } |
382 | void KODayMatrix::updateViewTimed() | 382 | void KODayMatrix::updateViewTimed() |
383 | { | 383 | { |
384 | mUpdateTimer->stop(); | 384 | mUpdateTimer->stop(); |
385 | if ( !mCalendar ) { | 385 | if ( !mCalendar ) { |
386 | qDebug("NOT CAL "); | 386 | qDebug("NOT CAL "); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | #if 1 | 389 | #if 1 |
390 | 390 | ||
391 | int i; | 391 | int i; |
392 | int timeSpan = NUMDAYS-1; | 392 | int timeSpan = NUMDAYS-1; |
393 | QPtrList<Event> events = mCalendar->events(); | 393 | QPtrList<Event> events = mCalendar->events(); |
394 | Event *event; | 394 | Event *event; |
395 | QDateTime dt; | 395 | QDateTime dt; |
396 | bool ok; | 396 | bool ok; |
397 | bDays.fill( false); | 397 | bDays.fill( false); |
398 | pDays.fill( false); | 398 | pDays.fill( false); |
399 | hDays.fill( false); | 399 | hDays.fill( false); |
400 | eDays.fill( false); | 400 | eDays.fill( false); |
401 | mHolidays.clear(); | 401 | mHolidays.clear(); |
402 | QDate mStartDate = days[0]; | 402 | QDate mStartDate = days[0]; |
403 | QDate endDate = mStartDate.addDays( timeSpan ); | 403 | QDate endDate = mStartDate.addDays( timeSpan ); |
404 | for( event = events.first(); event; event = events.next() ) { // for event | 404 | for( event = events.first(); event; event = events.next() ) { // for event |
405 | ushort recurType = event->recurrence()->doesRecur(); | 405 | ushort recurType = event->recurrence()->doesRecur(); |
406 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 406 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
407 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 407 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
408 | continue; | 408 | continue; |
409 | } | 409 | } |
410 | if ( event->doesRecur() ) { | 410 | if ( event->doesRecur() ) { |
411 | bool last; | 411 | bool last; |
412 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 412 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
413 | QDateTime incidenceEnd; | 413 | QDateTime incidenceEnd; |
414 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 414 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
415 | bool invalid = false; | 415 | bool invalid = false; |
416 | while( true ) { | 416 | while( true ) { |
417 | if ( incidenceStart.isValid() ) { | 417 | if ( incidenceStart.isValid() ) { |
418 | incidenceEnd = incidenceStart.addDays( eventlen ); | 418 | incidenceEnd = incidenceStart.addDays( eventlen ); |
419 | int st = incidenceStart.date().daysTo( endDate ); | 419 | int st = incidenceStart.date().daysTo( endDate ); |
420 | if ( st >= 0 ) { // start before timeend | 420 | if ( st >= 0 ) { // start before timeend |
421 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 421 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
422 | if ( end >= 0 ) { // end after timestart --- got one! | 422 | if ( end >= 0 ) { // end after timestart --- got one! |
423 | //normalize | 423 | //normalize |
424 | st = timeSpan - st; | 424 | st = timeSpan - st; |
425 | if ( st < 0 ) st = 0; | 425 | if ( st < 0 ) st = 0; |
426 | if ( end > timeSpan ) end = timeSpan; | 426 | if ( end > timeSpan ) end = timeSpan; |
427 | int iii; | 427 | int iii; |
428 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 428 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
429 | for ( iii = st;iii<= end;++iii) { | 429 | for ( iii = st;iii<= end;++iii) { |
430 | computeEvent( event, iii ); | 430 | computeEvent( event, iii ); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | } else { | 434 | } else { |
435 | if ( invalid ) | 435 | if ( invalid ) |
436 | break; | 436 | break; |
437 | invalid = true; | 437 | invalid = true; |
438 | //qDebug("invalid %s", event->summary().latin1()); | 438 | //qDebug("invalid %s", event->summary().latin1()); |
439 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 439 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
440 | } | 440 | } |
441 | if ( last ) | 441 | if ( last ) |
442 | break; | 442 | break; |
443 | bool ok; | 443 | bool ok; |
444 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 444 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
445 | if ( ! ok ) | 445 | if ( ! ok ) |
446 | break; | 446 | break; |
447 | if ( incidenceStart.date() > endDate ) | 447 | if ( incidenceStart.date() > endDate ) |
448 | break; | 448 | break; |
449 | } | 449 | } |
450 | } else { // no recur | 450 | } else { // no recur |
451 | int st = event->dtStart().date().daysTo( endDate ); | 451 | int st = event->dtStart().date().daysTo( endDate ); |
452 | if ( st >= 0 ) { // start before timeend | 452 | if ( st >= 0 ) { // start before timeend |
453 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 453 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
454 | if ( end >= 0 ) { // end after timestart --- got one! | 454 | if ( end >= 0 ) { // end after timestart --- got one! |
455 | //normalize | 455 | //normalize |
456 | st = timeSpan - st; | 456 | st = timeSpan - st; |
457 | if ( st < 0 ) st = 0; | 457 | if ( st < 0 ) st = 0; |
458 | if ( end > timeSpan ) end = timeSpan; | 458 | if ( end > timeSpan ) end = timeSpan; |
459 | int iii; | 459 | int iii; |
460 | for ( iii = st;iii<= end;++iii) | 460 | for ( iii = st;iii<= end;++iii) |
461 | computeEvent( event, iii ); | 461 | computeEvent( event, iii ); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 466 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
467 | for(i = 0; i < NUMDAYS; i++) { | 467 | for(i = 0; i < NUMDAYS; i++) { |
468 | if ( ( (i+startDay) % 7 == 0 ) ) { | 468 | if ( ( (i+startDay) % 7 == 0 ) ) { |
469 | pDays.setBit(i); | 469 | pDays.setBit(i); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | #if 0 | 473 | #if 0 |
474 | // insert due todos | 474 | // insert due todos |
475 | QPtrList<Todo> todos = calendar()->todos( ); | 475 | QPtrList<Todo> todos = calendar()->todos( ); |
476 | Todo *todo; | 476 | Todo *todo; |
477 | for(todo = todos.first(); todo; todo = todos.next()) { | 477 | for(todo = todos.first(); todo; todo = todos.next()) { |
478 | //insertTodo( todo ); | 478 | //insertTodo( todo ); |
479 | if ( todo->hasDueDate() ) { | 479 | if ( todo->hasDueDate() ) { |
480 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 480 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
481 | if ( day >= 0 && day < timeSpan + 1) { | 481 | if ( day >= 0 && day < timeSpan + 1) { |
482 | (*cells)[day]->insertTodo( todo ); | 482 | (*cells)[day]->insertTodo( todo ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | #endif | 486 | #endif |
487 | 487 | ||
488 | #else | 488 | #else |
489 | //qDebug("KODayMatrix::updateViewTimed "); | 489 | //qDebug("KODayMatrix::updateViewTimed "); |
490 | for(int i = 0; i < NUMDAYS; i++) { | 490 | for(int i = 0; i < NUMDAYS; i++) { |
491 | // if events are set for the day then remember to draw it bold | 491 | // if events are set for the day then remember to draw it bold |
492 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 492 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
493 | Event *event; | 493 | Event *event; |
494 | int numEvents = eventlist.count(); | 494 | int numEvents = eventlist.count(); |
495 | QString holiStr = ""; | 495 | QString holiStr = ""; |
496 | bDays.clearBit(i); | 496 | bDays.clearBit(i); |
497 | hDays.clearBit(i); | 497 | hDays.clearBit(i); |
498 | eDays.clearBit(i); | 498 | eDays.clearBit(i); |
499 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 499 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
500 | qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF "); | ||
501 | ushort recurType = event->recurrence()->doesRecur(); | 500 | ushort recurType = event->recurrence()->doesRecur(); |
502 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 501 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
503 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 502 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
504 | numEvents--; | 503 | numEvents--; |
505 | } | 504 | } |
506 | if ( event->isHoliday()) { | 505 | if ( event->isHoliday()) { |
507 | hDays.setBit(i); | 506 | hDays.setBit(i); |
508 | if ( !holiStr.isEmpty() ) | 507 | if ( !holiStr.isEmpty() ) |
509 | holiStr += "\n"; | 508 | holiStr += "\n"; |
510 | holiStr += event->summary(); | 509 | holiStr += event->summary(); |
511 | if ( !event->location().isEmpty() ) | 510 | if ( !event->location().isEmpty() ) |
512 | holiStr += " (" + event->location() + ")"; | 511 | holiStr += " (" + event->location() + ")"; |
513 | } | 512 | } |
514 | if ( event->isBirthday()) { | 513 | if ( event->isBirthday()) { |
515 | if ( !holiStr.isEmpty() ) | 514 | if ( !holiStr.isEmpty() ) |
516 | holiStr += "\n"; | 515 | holiStr += "\n"; |
517 | holiStr += i18n("Birthday") + ": "+event->summary(); | 516 | holiStr += i18n("Birthday") + ": "+event->summary(); |
518 | if ( !event->location().isEmpty() ) | 517 | if ( !event->location().isEmpty() ) |
519 | holiStr += " (" + event->location() + ")"; | 518 | holiStr += " (" + event->location() + ")"; |
520 | bDays.setBit(i); | 519 | bDays.setBit(i); |
521 | } | 520 | } |
522 | } | 521 | } |
523 | if ( numEvents ) | 522 | if ( numEvents ) |
524 | eDays.setBit(i); | 523 | eDays.setBit(i); |
525 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 524 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
526 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 525 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
527 | !holiStr.isEmpty()) { | 526 | !holiStr.isEmpty()) { |
528 | mHolidays[i] = holiStr; | 527 | mHolidays[i] = holiStr; |
529 | } else { | 528 | } else { |
530 | mHolidays[i] = QString::null; | 529 | mHolidays[i] = QString::null; |
531 | } | 530 | } |
532 | } | 531 | } |
533 | #endif | 532 | #endif |
534 | mRedrawNeeded = true; | 533 | mRedrawNeeded = true; |
535 | if ( ! mPendingUpdateBeforeRepaint ) | 534 | if ( ! mPendingUpdateBeforeRepaint ) |
536 | repaint(false); | 535 | repaint(false); |
537 | } | 536 | } |
538 | void KODayMatrix::updateView(QDate actdate) | 537 | void KODayMatrix::updateView(QDate actdate) |
539 | { | 538 | { |
540 | 539 | ||
541 | if ( ! actdate.isValid() ) { | 540 | if ( ! actdate.isValid() ) { |
542 | //qDebug("date not valid "); | 541 | //qDebug("date not valid "); |
543 | return; | 542 | return; |
544 | } | 543 | } |
545 | mDayChanged = false; | 544 | mDayChanged = false; |
546 | //flag to indicate if the starting day of the matrix has changed by this call | 545 | //flag to indicate if the starting day of the matrix has changed by this call |
547 | //mDayChanged = false; | 546 | //mDayChanged = false; |
548 | // if a new startdate is to be set then apply Cornelius's calculation | 547 | // if a new startdate is to be set then apply Cornelius's calculation |
549 | // of the first day to be shown | 548 | // of the first day to be shown |
550 | if (actdate != startdate) { | 549 | if (actdate != startdate) { |
551 | // reset index of selection according to shift of starting date from startdate to actdate | 550 | // reset index of selection according to shift of starting date from startdate to actdate |
552 | if (mSelStart != NOSELECTION) { | 551 | if (mSelStart != NOSELECTION) { |
553 | int tmp = actdate.daysTo(startdate); | 552 | int tmp = actdate.daysTo(startdate); |
554 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 553 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
555 | // shift selection if new one would be visible at least partly ! | 554 | // shift selection if new one would be visible at least partly ! |
556 | 555 | ||
557 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 556 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
558 | // nested if is required for next X display pushed from a different month - correction required | 557 | // nested if is required for next X display pushed from a different month - correction required |
559 | // otherwise, for month forward and backward, it must be avoided | 558 | // otherwise, for month forward and backward, it must be avoided |
560 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 559 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
561 | mSelStart = mSelStart + tmp; | 560 | mSelStart = mSelStart + tmp; |
562 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 561 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
563 | mSelEnd = mSelEnd + tmp; | 562 | mSelEnd = mSelEnd + tmp; |
564 | } | 563 | } |
565 | } | 564 | } |
566 | startdate = actdate; | 565 | startdate = actdate; |
567 | mDayChanged = true; | 566 | mDayChanged = true; |
568 | recalculateToday(); | 567 | recalculateToday(); |
569 | mRedrawNeeded = true; | 568 | mRedrawNeeded = true; |
570 | } | 569 | } |
571 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 570 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
572 | if ( !isVisible() ) { | 571 | if ( !isVisible() ) { |
573 | mPendingUpdateBeforeRepaint = true; | 572 | mPendingUpdateBeforeRepaint = true; |
574 | } else { | 573 | } else { |
575 | #ifdef DESKTOP_VERSION | 574 | #ifdef DESKTOP_VERSION |
576 | //mRepaintTimer->start( 100 ); | 575 | //mRepaintTimer->start( 100 ); |
577 | //updateViewTimed(); | 576 | //updateViewTimed(); |
578 | mUpdateTimer->start( 50 ); | 577 | mUpdateTimer->start( 50 ); |
579 | #else | 578 | #else |
580 | mRepaintTimer->start( 350 ); | 579 | mRepaintTimer->start( 350 ); |
581 | mUpdateTimer->start( 800 ); | 580 | mUpdateTimer->start( 800 ); |
582 | #endif | 581 | #endif |
583 | } | 582 | } |
584 | } | 583 | } |
585 | void KODayMatrix::updateEvents() | 584 | void KODayMatrix::updateEvents() |
586 | { | 585 | { |
587 | if ( !mCalendar ) return; | 586 | if ( !mCalendar ) return; |
588 | 587 | ||
589 | for( int i = 0; i < NUMDAYS; i++ ) { | 588 | for( int i = 0; i < NUMDAYS; i++ ) { |
590 | // if events are set for the day then remember to draw it bold | 589 | // if events are set for the day then remember to draw it bold |
591 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 590 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
592 | int numEvents = eventlist.count(); | 591 | int numEvents = eventlist.count(); |
593 | Event *event; | 592 | Event *event; |
594 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 593 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
595 | ushort recurType = event->doesRecur(); | 594 | ushort recurType = event->doesRecur(); |
596 | 595 | ||
597 | if ( ( recurType == Recurrence::rDaily && | 596 | if ( ( recurType == Recurrence::rDaily && |
598 | !KOPrefs::instance()->mDailyRecur ) || | 597 | !KOPrefs::instance()->mDailyRecur ) || |
599 | ( recurType == Recurrence::rWeekly && | 598 | ( recurType == Recurrence::rWeekly && |
600 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 599 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
601 | numEvents--; | 600 | numEvents--; |
602 | } | 601 | } |
603 | } | 602 | } |
604 | if ( numEvents ) | 603 | if ( numEvents ) |
605 | eDays.setBit(i); | 604 | eDays.setBit(i); |
606 | else | 605 | else |
607 | eDays.clearBit(i); | 606 | eDays.clearBit(i); |
608 | } | 607 | } |
609 | } | 608 | } |
610 | 609 | ||
611 | const QDate& KODayMatrix::getDate(int offset) | 610 | const QDate& KODayMatrix::getDate(int offset) |
612 | { | 611 | { |
613 | if (offset < 0 || offset > NUMDAYS-1) { | 612 | if (offset < 0 || offset > NUMDAYS-1) { |
614 | qDebug("Wrong offset2 %d", offset); | 613 | qDebug("Wrong offset2 %d", offset); |
615 | return days[0]; | 614 | return days[0]; |
616 | } | 615 | } |
617 | return days[offset]; | 616 | return days[offset]; |
618 | } | 617 | } |
619 | 618 | ||
620 | QString KODayMatrix::getHolidayLabel(int offset) | 619 | QString KODayMatrix::getHolidayLabel(int offset) |
621 | { | 620 | { |
622 | if (offset < 0 || offset > NUMDAYS-1) { | 621 | if (offset < 0 || offset > NUMDAYS-1) { |
623 | qDebug("Wrong offset1 %d", offset); | 622 | qDebug("Wrong offset1 %d", offset); |
624 | return QString(); | 623 | return QString(); |
625 | } | 624 | } |
626 | return mHolidays[offset]; | 625 | return mHolidays[offset]; |
627 | } | 626 | } |
628 | 627 | ||
629 | int KODayMatrix::getDayIndexFrom(int x, int y) | 628 | int KODayMatrix::getDayIndexFrom(int x, int y) |
630 | { | 629 | { |
631 | int colModulo = (width()-2) % 7; | 630 | int colModulo = (width()-2) % 7; |
632 | int rowModulo = (height()-2) % 6; | 631 | int rowModulo = (height()-2) % 6; |
633 | #if 0 | 632 | #if 0 |
634 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 633 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
635 | 6 - x/daysize.width() : x/daysize.width()); | 634 | 6 - x/daysize.width() : x/daysize.width()); |
636 | #endif | 635 | #endif |
637 | int xVal = (x-colModulo/2-2)/daysize.width(); | 636 | int xVal = (x-colModulo/2-2)/daysize.width(); |
638 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 637 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
639 | 638 | ||
640 | 639 | ||
641 | return 7*(yVal) + xVal; | 640 | return 7*(yVal) + xVal; |
642 | 641 | ||
643 | } | 642 | } |
644 | 643 | ||
645 | // ---------------------------------------------------------------------------- | 644 | // ---------------------------------------------------------------------------- |
646 | // M O U S E E V E N T H A N D L I N G | 645 | // M O U S E E V E N T H A N D L I N G |
647 | // ---------------------------------------------------------------------------- | 646 | // ---------------------------------------------------------------------------- |
648 | 647 | ||
649 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 648 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
650 | { | 649 | { |
651 | 650 | ||
652 | if ( e->button() == LeftButton ) | 651 | if ( e->button() == LeftButton ) |
653 | mouseDown = true; | 652 | mouseDown = true; |
654 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 653 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
655 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 654 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
656 | mSelInit = mSelStart; | 655 | mSelInit = mSelStart; |
657 | mSelEnd = mSelStart; | 656 | mSelEnd = mSelStart; |
658 | mRedrawNeeded = true; | 657 | mRedrawNeeded = true; |
659 | repaint(false); | 658 | repaint(false); |
660 | } | 659 | } |
661 | 660 | ||
662 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 661 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
663 | { | 662 | { |
664 | mRedrawNeeded = true; | 663 | mRedrawNeeded = true; |
665 | if ( e->button() == LeftButton ) | 664 | if ( e->button() == LeftButton ) |
666 | if ( ! mouseDown ) { | 665 | if ( ! mouseDown ) { |
667 | return; | 666 | return; |
668 | } | 667 | } |
669 | else | 668 | else |
670 | mouseDown = false; | 669 | mouseDown = false; |
671 | int tmp = getDayIndexFrom(e->x(), e->y()); | 670 | int tmp = getDayIndexFrom(e->x(), e->y()); |
672 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 671 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
673 | 672 | ||
674 | if (mSelInit > tmp) { | 673 | if (mSelInit > tmp) { |
675 | mSelEnd = mSelInit; | 674 | mSelEnd = mSelInit; |
676 | if (tmp != mSelStart) { | 675 | if (tmp != mSelStart) { |
677 | mSelStart = tmp; | 676 | mSelStart = tmp; |
678 | repaint(false); | 677 | repaint(false); |
679 | } | 678 | } |
680 | } else { | 679 | } else { |
681 | mSelStart = mSelInit; | 680 | mSelStart = mSelInit; |
682 | 681 | ||
683 | //repaint only if selection has changed | 682 | //repaint only if selection has changed |
684 | if (tmp != mSelEnd) { | 683 | if (tmp != mSelEnd) { |
685 | mSelEnd = tmp; | 684 | mSelEnd = tmp; |
686 | repaint(false); | 685 | repaint(false); |
687 | } | 686 | } |
688 | } | 687 | } |
689 | 688 | ||
690 | DateList daylist; | 689 | DateList daylist; |
691 | if ( mSelStart < 0 ) | 690 | if ( mSelStart < 0 ) |
692 | mSelStart = 0; | 691 | mSelStart = 0; |
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 9df76e7..0045b7f 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -43,385 +43,385 @@ | |||
43 | 43 | ||
44 | #include <libkcal/todo.h> | 44 | #include <libkcal/todo.h> |
45 | #include <libkcal/event.h> | 45 | #include <libkcal/event.h> |
46 | #include <libkdepim/categoryselectdialog.h> | 46 | #include <libkdepim/categoryselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "koglobals.h" | 50 | #include "koglobals.h" |
51 | 51 | ||
52 | #include "koeditorgeneral.h" | 52 | #include "koeditorgeneral.h" |
53 | #include "kolocationbox.h" | 53 | #include "kolocationbox.h" |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 60 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
61 | QObject( parent, name) | 61 | QObject( parent, name) |
62 | { | 62 | { |
63 | mNextFocus = 0; | 63 | mNextFocus = 0; |
64 | } | 64 | } |
65 | 65 | ||
66 | KOEditorGeneral::~KOEditorGeneral() | 66 | KOEditorGeneral::~KOEditorGeneral() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 70 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
71 | { | 71 | { |
72 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 72 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
73 | 73 | ||
74 | #if 0 | 74 | #if 0 |
75 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 75 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
76 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 76 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 79 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
80 | headerLayout->addWidget(summaryLabel,1,0); | 80 | headerLayout->addWidget(summaryLabel,1,0); |
81 | 81 | ||
82 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 82 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
83 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 83 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
84 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 84 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
85 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 85 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
86 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 86 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
87 | if ( QApplication::desktop()->width() > 320 ) | 87 | if ( QApplication::desktop()->width() > 320 ) |
88 | mSummaryEdit->setMaximumHeight( hei +6 ); | 88 | mSummaryEdit->setMaximumHeight( hei +6 ); |
89 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 89 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
90 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 90 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
91 | // mSummaryEdit = new QLineEdit(parent); | 91 | // mSummaryEdit = new QLineEdit(parent); |
92 | headerLayout->addWidget(mSummaryEdit,1,1); | 92 | headerLayout->addWidget(mSummaryEdit,1,1); |
93 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 93 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
94 | 94 | ||
95 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 95 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
96 | headerLayout->addWidget(locationLabel,2,0); | 96 | headerLayout->addWidget(locationLabel,2,0); |
97 | 97 | ||
98 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 98 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
99 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 99 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
100 | if ( QApplication::desktop()->width() > 320 ) | 100 | if ( QApplication::desktop()->width() > 320 ) |
101 | mLocationEdit->setMaximumHeight( hei + 6); | 101 | mLocationEdit->setMaximumHeight( hei + 6); |
102 | 102 | ||
103 | // mLocationEdit = new QLineEdit(parent); | 103 | // mLocationEdit = new QLineEdit(parent); |
104 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 104 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
105 | headerLayout->addWidget(mLocationEdit,2,1); | 105 | headerLayout->addWidget(mLocationEdit,2,1); |
106 | headerLayout->setColStretch( 1, 10); | 106 | headerLayout->setColStretch( 1, 10); |
107 | } | 107 | } |
108 | void KOEditorGeneral::setFocusOn( int i ) | 108 | void KOEditorGeneral::setFocusOn( int i ) |
109 | { | 109 | { |
110 | mNextFocus = i; | 110 | mNextFocus = i; |
111 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 111 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
112 | } | 112 | } |
113 | void KOEditorGeneral::slotSetFocusOn() | 113 | void KOEditorGeneral::slotSetFocusOn() |
114 | { | 114 | { |
115 | mNextFocus; | 115 | mNextFocus; |
116 | if ( mNextFocus == 1 ) { | 116 | if ( mNextFocus == 1 ) { |
117 | mDescriptionEdit->setFocus(); | 117 | mDescriptionEdit->setFocus(); |
118 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 118 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
119 | } | 119 | } |
120 | if ( mNextFocus == 2 ) { | 120 | if ( mNextFocus == 2 ) { |
121 | mSummaryEdit->setFocus(); | 121 | mSummaryEdit->setFocus(); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | void KOEditorGeneral::editCategories() | 124 | void KOEditorGeneral::editCategories() |
125 | { | 125 | { |
126 | // qDebug("KOEditorGeneral::editCategories() "); | 126 | // qDebug("KOEditorGeneral::editCategories() "); |
127 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 127 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
128 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 128 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
129 | //KOGlobals::fitDialogToScreen( csd ); | 129 | //KOGlobals::fitDialogToScreen( csd ); |
130 | csd->setColorEnabled(); | 130 | csd->setColorEnabled(); |
131 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 131 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
132 | csd->exec(); | 132 | csd->exec(); |
133 | delete csd; | 133 | delete csd; |
134 | } | 134 | } |
135 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 135 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
136 | { | 136 | { |
137 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 137 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
138 | 138 | ||
139 | mCategoriesButton = new QPushButton(parent); | 139 | mCategoriesButton = new QPushButton(parent); |
140 | mCategoriesButton->setText(i18n("Categories...")); | 140 | mCategoriesButton->setText(i18n("Categories...")); |
141 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 141 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
142 | categoriesLayout->addWidget(mCategoriesButton); | 142 | categoriesLayout->addWidget(mCategoriesButton); |
143 | 143 | ||
144 | mCategoriesLabel = new QLabel(parent); | 144 | mCategoriesLabel = new QLabel(parent); |
145 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 145 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
146 | categoriesLayout->addWidget(mCategoriesLabel,1); | 146 | categoriesLayout->addWidget(mCategoriesLabel,1); |
147 | } | 147 | } |
148 | 148 | ||
149 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 149 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
150 | { | 150 | { |
151 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 151 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
152 | 152 | ||
153 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 153 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
154 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 154 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
155 | secrecyLayout->addWidget(mCancelBox); | 155 | secrecyLayout->addWidget(mCancelBox); |
156 | secrecyLayout->addWidget(secrecyLabel); | 156 | secrecyLayout->addWidget(secrecyLabel); |
157 | 157 | ||
158 | mSecrecyCombo = new QComboBox(parent); | 158 | mSecrecyCombo = new QComboBox(parent); |
159 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 159 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
160 | secrecyLayout->addWidget(mSecrecyCombo); | 160 | secrecyLayout->addWidget(mSecrecyCombo); |
161 | } | 161 | } |
162 | 162 | ||
163 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 163 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
164 | { | 164 | { |
165 | mDescriptionEdit = new KTextEdit(parent); | 165 | mDescriptionEdit = new KTextEdit(parent); |
166 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 166 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
167 | mDescriptionEdit->append(""); | 167 | mDescriptionEdit->append(""); |
168 | mDescriptionEdit->setReadOnly(false); | 168 | mDescriptionEdit->setReadOnly(false); |
169 | mDescriptionEdit->setOverwriteMode(false); | 169 | mDescriptionEdit->setOverwriteMode(false); |
170 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 170 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
171 | topLayout->addWidget(mDescriptionEdit); | 171 | topLayout->addWidget(mDescriptionEdit); |
172 | #ifndef DESKTOP_VERSION | 172 | #ifndef DESKTOP_VERSION |
173 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 173 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 178 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
179 | { | 179 | { |
180 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 180 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
181 | 181 | ||
182 | //mAlarmBell = new QLabel(parent); | 182 | //mAlarmBell = new QLabel(parent); |
183 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 183 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
184 | //alarmLayout->addWidget(mAlarmBell); | 184 | //alarmLayout->addWidget(mAlarmBell); |
185 | if ( QApplication::desktop()->width() < 320 ) | 185 | if ( QApplication::desktop()->width() < 320 ) |
186 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 186 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
187 | else | 187 | else |
188 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 188 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
189 | 189 | ||
190 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 190 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
191 | alarmLayout->addWidget(mAlarmButton); | 191 | alarmLayout->addWidget(mAlarmButton); |
192 | 192 | ||
193 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 193 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
194 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 194 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
195 | alarmLayout->addWidget(mAlarmTimeEdit); | 195 | alarmLayout->addWidget(mAlarmTimeEdit); |
196 | mAlarmIncrCombo = new QComboBox(false, parent); | 196 | mAlarmIncrCombo = new QComboBox(false, parent); |
197 | if ( QApplication::desktop()->width() < 320 ) { | 197 | if ( QApplication::desktop()->width() < 320 ) { |
198 | mAlarmIncrCombo->insertItem(i18n("min")); | 198 | mAlarmIncrCombo->insertItem(i18n("min")); |
199 | mAlarmIncrCombo->insertItem(i18n("hou")); | 199 | mAlarmIncrCombo->insertItem(i18n("hou")); |
200 | mAlarmIncrCombo->insertItem(i18n("day")); | 200 | mAlarmIncrCombo->insertItem(i18n("day")); |
201 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 201 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
202 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 202 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
203 | } else { | 203 | } else { |
204 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 204 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
205 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 205 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
206 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 206 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
207 | } | 207 | } |
208 | 208 | ||
209 | // mAlarmIncrCombo->setMinimumHeight(20); | 209 | // mAlarmIncrCombo->setMinimumHeight(20); |
210 | alarmLayout->addWidget(mAlarmIncrCombo); | 210 | alarmLayout->addWidget(mAlarmIncrCombo); |
211 | mAlarmSoundButton = new QPushButton(parent); | 211 | mAlarmSoundButton = new QPushButton(parent); |
212 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 212 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
213 | mAlarmSoundButton->setToggleButton(true); | 213 | mAlarmSoundButton->setToggleButton(true); |
214 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 214 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
215 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 215 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
216 | alarmLayout->addWidget(mAlarmSoundButton); | 216 | alarmLayout->addWidget(mAlarmSoundButton); |
217 | 217 | ||
218 | mAlarmProgramButton = new QPushButton(parent); | 218 | mAlarmProgramButton = new QPushButton(parent); |
219 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 219 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
220 | mAlarmProgramButton->setToggleButton(true); | 220 | mAlarmProgramButton->setToggleButton(true); |
221 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 221 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
222 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 222 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
223 | alarmLayout->addWidget(mAlarmProgramButton); | 223 | alarmLayout->addWidget(mAlarmProgramButton); |
224 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 224 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
225 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 225 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
226 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 226 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
227 | // mAlarmSoundButton->hide(); | 227 | // mAlarmSoundButton->hide(); |
228 | // mAlarmProgramButton->hide(); | 228 | // mAlarmProgramButton->hide(); |
229 | // } | 229 | // } |
230 | } | 230 | } |
231 | 231 | ||
232 | void KOEditorGeneral::pickAlarmSound() | 232 | void KOEditorGeneral::pickAlarmSound() |
233 | { | 233 | { |
234 | 234 | ||
235 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 235 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
236 | 236 | ||
237 | bool oldState = mAlarmSoundButton->isOn(); | 237 | bool oldState = mAlarmSoundButton->isOn(); |
238 | 238 | ||
239 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 239 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
240 | i18n("*.wav|Wav Files"), 0)); | 240 | i18n("*.wav|Wav Files"), 0)); |
241 | if (!fileName.isEmpty()) { | 241 | if (!fileName.isEmpty()) { |
242 | mAlarmSound = fileName; | 242 | mAlarmSound = fileName; |
243 | QToolTip::remove(mAlarmSoundButton); | 243 | QToolTip::remove(mAlarmSoundButton); |
244 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 244 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
245 | QToolTip::add(mAlarmSoundButton, dispStr); | 245 | QToolTip::add(mAlarmSoundButton, dispStr); |
246 | mAlarmProgramButton->setOn(false); | 246 | mAlarmProgramButton->setOn(false); |
247 | mAlarmSoundButton->setOn(true); | 247 | mAlarmSoundButton->setOn(true); |
248 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 248 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
249 | } else { | 249 | } else { |
250 | mAlarmProgramButton->setOn(oldState); | 250 | mAlarmProgramButton->setOn(oldState); |
251 | mAlarmSoundButton->setOn(!oldState); | 251 | mAlarmSoundButton->setOn(!oldState); |
252 | 252 | ||
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | if (mAlarmProgramButton->isOn()) | 256 | if (mAlarmProgramButton->isOn()) |
257 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 257 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
258 | if ( mAlarmSoundButton->isOn()) | 258 | if ( mAlarmSoundButton->isOn()) |
259 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 259 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
260 | 260 | ||
261 | } | 261 | } |
262 | 262 | ||
263 | void KOEditorGeneral::pickAlarmProgram() | 263 | void KOEditorGeneral::pickAlarmProgram() |
264 | { | 264 | { |
265 | bool oldState = mAlarmProgramButton->isOn(); | 265 | bool oldState = mAlarmProgramButton->isOn(); |
266 | 266 | ||
267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
268 | if (!fileName.isEmpty()) { | 268 | if (!fileName.isEmpty()) { |
269 | mAlarmProgram = fileName; | 269 | mAlarmProgram = fileName; |
270 | QToolTip::remove(mAlarmProgramButton); | 270 | QToolTip::remove(mAlarmProgramButton); |
271 | QString dispStr = i18n("Running '%1'").arg(fileName); | 271 | QString dispStr = i18n("Running '%1'").arg(fileName); |
272 | QToolTip::add(mAlarmProgramButton, dispStr); | 272 | QToolTip::add(mAlarmProgramButton, dispStr); |
273 | mAlarmSoundButton->setOn(false); | 273 | mAlarmSoundButton->setOn(false); |
274 | mAlarmProgramButton->setOn(true); | 274 | mAlarmProgramButton->setOn(true); |
275 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 275 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
276 | } else { | 276 | } else { |
277 | mAlarmProgramButton->setOn(!oldState); | 277 | mAlarmProgramButton->setOn(!oldState); |
278 | mAlarmSoundButton->setOn(oldState); | 278 | mAlarmSoundButton->setOn(oldState); |
279 | } | 279 | } |
280 | 280 | ||
281 | if (mAlarmProgramButton->isOn()) | 281 | if (mAlarmProgramButton->isOn()) |
282 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 282 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
283 | if ( mAlarmSoundButton->isOn()) | 283 | if ( mAlarmSoundButton->isOn()) |
284 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 284 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | QString KOEditorGeneral::getFittingPath( const QString s ) | 289 | QString KOEditorGeneral::getFittingPath( const QString s ) |
290 | { | 290 | { |
291 | int maxlen = 50; | 291 | int maxlen = 50; |
292 | if ( QApplication::desktop()->width() < 640 ) { | 292 | if ( QApplication::desktop()->width() < 640 ) { |
293 | if ( QApplication::desktop()->width() < 320 ) | 293 | if ( QApplication::desktop()->width() < 320 ) |
294 | maxlen = 22; | 294 | maxlen = 22; |
295 | else | 295 | else |
296 | maxlen = 35; | 296 | maxlen = 35; |
297 | } | 297 | } |
298 | if ( s.length() > maxlen ) { | 298 | if ( s.length() > maxlen ) { |
299 | return "..."+s.right(maxlen -3); | 299 | return "..."+s.right(maxlen -3); |
300 | } | 300 | } |
301 | return s; | 301 | return s; |
302 | } | 302 | } |
303 | 303 | ||
304 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 304 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
305 | { | 305 | { |
306 | if ( enable ) { | 306 | if ( enable ) { |
307 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 307 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
308 | mAlarmSoundButton->setOn( true ); | 308 | mAlarmSoundButton->setOn( true ); |
309 | if ( mAlarmSound.isEmpty() ) | 309 | if ( mAlarmSound.isEmpty() ) |
310 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 310 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
311 | else { | 311 | else { |
312 | if ( ! QFile::exists( mAlarmSound ) ) | 312 | if ( ! QFile::exists( mAlarmSound ) ) |
313 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 313 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } | 316 | } |
317 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 317 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
318 | mAlarmTimeEdit->setEnabled(enable); | 318 | mAlarmTimeEdit->setEnabled(enable); |
319 | mAlarmSoundButton->setEnabled(enable); | 319 | mAlarmSoundButton->setEnabled(enable); |
320 | mAlarmProgramButton->setEnabled(enable); | 320 | mAlarmProgramButton->setEnabled(enable); |
321 | mAlarmIncrCombo->setEnabled(enable); | 321 | mAlarmIncrCombo->setEnabled(enable); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 324 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
325 | { | 325 | { |
326 | enableAlarmEdit( !disable ); | 326 | enableAlarmEdit( !disable ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOEditorGeneral::enableAlarm( bool enable ) | 329 | void KOEditorGeneral::enableAlarm( bool enable ) |
330 | { | 330 | { |
331 | enableAlarmEdit( enable ); | 331 | enableAlarmEdit( enable ); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOEditorGeneral::alarmDisable(bool disable) | 334 | void KOEditorGeneral::alarmDisable(bool disable) |
335 | { | 335 | { |
336 | if (!disable) { | 336 | if (!disable) { |
337 | //mAlarmBell->setEnabled(true); | 337 | //mAlarmBell->setEnabled(true); |
338 | mAlarmButton->setEnabled(true); | 338 | mAlarmButton->setEnabled(true); |
339 | } else { | 339 | } else { |
340 | //mAlarmBell->setEnabled(false); | 340 | //mAlarmBell->setEnabled(false); |
341 | mAlarmButton->setEnabled(false); | 341 | mAlarmButton->setEnabled(false); |
342 | mAlarmButton->setChecked(false); | 342 | mAlarmButton->setChecked(false); |
343 | mAlarmTimeEdit->setEnabled(false); | 343 | mAlarmTimeEdit->setEnabled(false); |
344 | mAlarmSoundButton->setEnabled(false); | 344 | mAlarmSoundButton->setEnabled(false); |
345 | mAlarmProgramButton->setEnabled(false); | 345 | mAlarmProgramButton->setEnabled(false); |
346 | mAlarmIncrCombo->setEnabled(false); | 346 | mAlarmIncrCombo->setEnabled(false); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void KOEditorGeneral::setCategories(const QString &str) | 350 | void KOEditorGeneral::setCategories(const QString &str) |
351 | { | 351 | { |
352 | mCategoriesLabel->setText(str); | 352 | mCategoriesLabel->setText(str); |
353 | } | 353 | } |
354 | 354 | ||
355 | void KOEditorGeneral::setDefaults(bool allDay) | 355 | void KOEditorGeneral::setDefaults(bool allDay) |
356 | { | 356 | { |
357 | #if 0 | 357 | #if 0 |
358 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 358 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | mAlarmMessage = i18n("Edit new item"); | 361 | mAlarmMessage = i18n("Edit new item"); |
362 | enableAlarmEdit( !allDay ); | 362 | enableAlarmEdit( !allDay ); |
363 | 363 | ||
364 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 364 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
365 | int alarmTime; | 365 | int alarmTime; |
366 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 366 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
367 | int index = KOPrefs::instance()->mAlarmTime; | 367 | int index = KOPrefs::instance()->mAlarmTime; |
368 | if (index < 0 || index > 7) { | 368 | if (index < 0 || index > 7) { |
369 | alarmTime = 15; | 369 | alarmTime = 15; |
370 | } else { | 370 | } else { |
371 | alarmTime = a[index]; | 371 | alarmTime = a[index]; |
372 | } | 372 | } |
373 | mAlarmButton ->setChecked( false ); | 373 | mAlarmButton ->setChecked( false ); |
374 | mAlarmTimeEdit->setValue(alarmTime); | 374 | mAlarmTimeEdit->setValue(alarmTime); |
375 | mAlarmIncrCombo->setCurrentItem(0); | 375 | mAlarmIncrCombo->setCurrentItem(0); |
376 | enableAlarmEdit( false ); | 376 | enableAlarmEdit( false ); |
377 | //alarmDisable (false); | 377 | //alarmDisable (false); |
378 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 378 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
379 | mCancelBox->setChecked( false ); | 379 | mCancelBox->setChecked( false ); |
380 | mSummaryEdit->setEditText(""); | 380 | mSummaryEdit->setEditText(""); |
381 | mLocationEdit->setEditText(""); | 381 | mLocationEdit->setEditText(""); |
382 | mDescriptionEdit->setText(""); | 382 | mDescriptionEdit->setText(""); |
383 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 383 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
384 | setCategories(""); | 384 | setCategories(""); |
385 | } | 385 | } |
386 | void KOEditorGeneral::setSecrecy( int num ) | 386 | void KOEditorGeneral::setSecrecy( int num ) |
387 | { | 387 | { |
388 | mSecrecyCombo->setCurrentItem(num); | 388 | mSecrecyCombo->setCurrentItem(num); |
389 | } | 389 | } |
390 | void KOEditorGeneral::readIncidence(Incidence *event) | 390 | void KOEditorGeneral::readIncidence(Incidence *event) |
391 | { | 391 | { |
392 | 392 | ||
393 | mAlarmMessage = event->summary(); | 393 | mAlarmMessage = event->summary(); |
394 | if ( ! event->location().isEmpty() ) | 394 | if ( ! event->location().isEmpty() ) |
395 | mAlarmMessage += " ("+event->location()+")"; | 395 | mAlarmMessage += " ("+event->location()+")"; |
396 | mAlarmIncrCombo->setCurrentItem(0); | 396 | mAlarmIncrCombo->setCurrentItem(0); |
397 | mSummaryEdit->setEditText(event->summary()); | 397 | mSummaryEdit->setEditText(event->summary()); |
398 | mLocationEdit->setEditText(event->location()); | 398 | mLocationEdit->setEditText(event->location()); |
399 | mDescriptionEdit->setText(event->description()); | 399 | mDescriptionEdit->setText(event->description()); |
400 | 400 | ||
401 | #if 0 | 401 | #if 0 |
402 | // organizer information | 402 | // organizer information |
403 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 403 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | enableAlarmEdit( event->isAlarmEnabled() ); | 406 | enableAlarmEdit( event->isAlarmEnabled() ); |
407 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 407 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
408 | if(!event->isAlarmEnabled()) { | 408 | if(!event->isAlarmEnabled()) { |
409 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 409 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
410 | int alarmTime; | 410 | int alarmTime; |
411 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 411 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
412 | int index = KOPrefs::instance()->mAlarmTime; | 412 | int index = KOPrefs::instance()->mAlarmTime; |
413 | if (index < 0 || index > 7) { | 413 | if (index < 0 || index > 7) { |
414 | alarmTime = 15; | 414 | alarmTime = 15; |
415 | } else { | 415 | } else { |
416 | alarmTime = a[index]; | 416 | alarmTime = a[index]; |
417 | } | 417 | } |
418 | mAlarmTimeEdit->setValue(alarmTime); | 418 | mAlarmTimeEdit->setValue(alarmTime); |
419 | } | 419 | } |
420 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 420 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
421 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 421 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
422 | mCancelBox->setChecked( event->cancelled() ); | 422 | mCancelBox->setChecked( event->cancelled() ); |
423 | mAlarmProgramButton->setOn(false); | 423 | mAlarmProgramButton->setOn(false); |
424 | mAlarmSoundButton->setOn(false); | 424 | mAlarmSoundButton->setOn(false); |
425 | 425 | ||
426 | // set up alarm stuff | 426 | // set up alarm stuff |
427 | QPtrList<Alarm> alarms = event->alarms(); | 427 | QPtrList<Alarm> alarms = event->alarms(); |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 01c5773..47e73dd 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -750,359 +750,359 @@ KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | |||
750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
753 | SLOT( showCurrentRule( int ) ) ); | 753 | SLOT( showCurrentRule( int ) ) ); |
754 | 754 | ||
755 | 755 | ||
756 | mRuleStack = new QWidgetStack( mRuleBox ); | 756 | mRuleStack = new QWidgetStack( mRuleBox ); |
757 | 757 | ||
758 | mDaily = new RecurDaily( mRuleStack ); | 758 | mDaily = new RecurDaily( mRuleStack ); |
759 | mRuleStack->addWidget( mDaily, 0 ); | 759 | mRuleStack->addWidget( mDaily, 0 ); |
760 | 760 | ||
761 | mWeekly = new RecurWeekly( mRuleStack ); | 761 | mWeekly = new RecurWeekly( mRuleStack ); |
762 | mRuleStack->addWidget( mWeekly, 0 ); | 762 | mRuleStack->addWidget( mWeekly, 0 ); |
763 | 763 | ||
764 | mMonthly = new RecurMonthly( mRuleStack ); | 764 | mMonthly = new RecurMonthly( mRuleStack ); |
765 | mRuleStack->addWidget( mMonthly, 0 ); | 765 | mRuleStack->addWidget( mMonthly, 0 ); |
766 | 766 | ||
767 | mYearly = new RecurYearly( mRuleStack ); | 767 | mYearly = new RecurYearly( mRuleStack ); |
768 | mRuleStack->addWidget( mYearly, 0 ); | 768 | mRuleStack->addWidget( mYearly, 0 ); |
769 | 769 | ||
770 | showCurrentRule( mRecurrenceChooser->type() ); | 770 | showCurrentRule( mRecurrenceChooser->type() ); |
771 | mRecurrenceRangeWidget = 0; | 771 | mRecurrenceRangeWidget = 0; |
772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
773 | mRecurrenceRange = mRecurrenceRangeDialog; | 773 | mRecurrenceRange = mRecurrenceRangeDialog; |
774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
775 | this ); | 775 | this ); |
776 | 776 | ||
777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
778 | SLOT( showRecurrenceRangeDialog() ) ); | 778 | SLOT( showRecurrenceRangeDialog() ) ); |
779 | 779 | ||
780 | mExceptionsWidget = 0; | 780 | mExceptionsWidget = 0; |
781 | mExceptionsDialog = new ExceptionsDialog( this ); | 781 | mExceptionsDialog = new ExceptionsDialog( this ); |
782 | mExceptions = mExceptionsDialog; | 782 | mExceptions = mExceptionsDialog; |
783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
784 | if ( QApplication::desktop()->width() < 320 ) { | 784 | if ( QApplication::desktop()->width() < 320 ) { |
785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
787 | } else { | 787 | } else { |
788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
790 | } | 790 | } |
791 | connect( mExceptionsButton, SIGNAL( clicked() ), | 791 | connect( mExceptionsButton, SIGNAL( clicked() ), |
792 | SLOT( showExceptionsDialog() ) ); | 792 | SLOT( showExceptionsDialog() ) ); |
793 | } | 793 | } |
794 | 794 | ||
795 | KOEditorRecurrence::~KOEditorRecurrence() | 795 | KOEditorRecurrence::~KOEditorRecurrence() |
796 | { | 796 | { |
797 | } | 797 | } |
798 | 798 | ||
799 | void KOEditorRecurrence::setEnabled( bool enabled ) | 799 | void KOEditorRecurrence::setEnabled( bool enabled ) |
800 | { | 800 | { |
801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
802 | 802 | ||
803 | mTimeGroupBox->setEnabled( enabled ); | 803 | mTimeGroupBox->setEnabled( enabled ); |
804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
808 | mRuleBox->setEnabled( enabled ); | 808 | mRuleBox->setEnabled( enabled ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KOEditorRecurrence::showCurrentRule( int current ) | 811 | void KOEditorRecurrence::showCurrentRule( int current ) |
812 | { | 812 | { |
813 | switch ( current ) { | 813 | switch ( current ) { |
814 | case Daily: | 814 | case Daily: |
815 | mRuleStack->raiseWidget( mDaily ); | 815 | mRuleStack->raiseWidget( mDaily ); |
816 | break; | 816 | break; |
817 | case Weekly: | 817 | case Weekly: |
818 | mRuleStack->raiseWidget( mWeekly ); | 818 | mRuleStack->raiseWidget( mWeekly ); |
819 | break; | 819 | break; |
820 | case Monthly: | 820 | case Monthly: |
821 | mRuleStack->raiseWidget( mMonthly ); | 821 | mRuleStack->raiseWidget( mMonthly ); |
822 | break; | 822 | break; |
823 | default: | 823 | default: |
824 | case Yearly: | 824 | case Yearly: |
825 | mRuleStack->raiseWidget( mYearly ); | 825 | mRuleStack->raiseWidget( mYearly ); |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | 838 | ||
839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
840 | { | 840 | { |
841 | 841 | ||
842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
843 | setDateTimes( from, to ); | 843 | setDateTimes( from, to ); |
844 | 844 | ||
845 | bool enabled = false; | 845 | bool enabled = false; |
846 | mEnabledCheck->setChecked( enabled ); | 846 | mEnabledCheck->setChecked( enabled ); |
847 | setEnabled( enabled ); | 847 | setEnabled( enabled ); |
848 | 848 | ||
849 | mExceptions->setDefaults( to ); | 849 | mExceptions->setDefaults( to ); |
850 | mRecurrenceRange->setDefaults( to ); | 850 | mRecurrenceRange->setDefaults( to ); |
851 | 851 | ||
852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
853 | showCurrentRule( mRecurrenceChooser->type() ); | 853 | showCurrentRule( mRecurrenceChooser->type() ); |
854 | 854 | ||
855 | mDaily->setFrequency( 1 ); | 855 | mDaily->setFrequency( 1 ); |
856 | 856 | ||
857 | mWeekly->setFrequency( 1 ); | 857 | mWeekly->setFrequency( 1 ); |
858 | QBitArray days( 7 ); | 858 | QBitArray days( 7 ); |
859 | days.fill( 0 ); | 859 | days.fill( 0 ); |
860 | days.setBit( from.date().dayOfWeek()- 1); | 860 | days.setBit( from.date().dayOfWeek()- 1); |
861 | mWeekly->setDays( days ); | 861 | mWeekly->setDays( days ); |
862 | mMonthly->setFrequency( 1 ); | 862 | mMonthly->setFrequency( 1 ); |
863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
864 | mMonthly->setByDay( from.date().day()-1 ); | 864 | mMonthly->setByDay( from.date().day()-1 ); |
865 | mYearly->setFrequency( 1 ); | 865 | mYearly->setFrequency( 1 ); |
866 | mYearly->setByDay( from.date().dayOfYear() ); | 866 | mYearly->setByDay( from.date().dayOfYear() ); |
867 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 867 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
868 | } | 868 | } |
869 | 869 | ||
870 | void KOEditorRecurrence::readEvent(Incidence *event) | 870 | void KOEditorRecurrence::readEvent(Incidence *event) |
871 | { | 871 | { |
872 | 872 | ||
873 | QDateTime dtEnd; | 873 | QDateTime dtEnd; |
874 | if ( event->type() == "Event" ) | 874 | if ( event->type() == "Event" ) |
875 | dtEnd = ((Event*)event)->dtEnd(); | 875 | dtEnd = ((Event*)event)->dtEnd(); |
876 | else | 876 | else |
877 | dtEnd = ((Todo*)event)->dtDue(); | 877 | dtEnd = ((Todo*)event)->dtDue(); |
878 | 878 | ||
879 | setDefaults( event->dtStart(), dtEnd, true ); | 879 | setDefaults( event->dtStart(), dtEnd, true ); |
880 | QBitArray rDays( 7 ); | 880 | QBitArray rDays( 7 ); |
881 | QPtrList<Recurrence::rMonthPos> rmp; | 881 | QPtrList<Recurrence::rMonthPos> rmp; |
882 | QPtrList<int> rmd; | 882 | QPtrList<int> rmd; |
883 | int day = 0; | 883 | int day = 0; |
884 | int count = 0; | 884 | int count = 0; |
885 | int month = 0; | 885 | int month = 0; |
886 | setDateTimes( event->dtStart(), dtEnd ); | 886 | setDateTimes( event->dtStart(), dtEnd ); |
887 | 887 | ||
888 | Recurrence *r = event->recurrence(); | 888 | Recurrence *r = event->recurrence(); |
889 | int f = r->frequency(); | 889 | int f = r->frequency(); |
890 | 890 | ||
891 | int recurs = r->doesRecur(); | 891 | int recurs = r->doesRecur(); |
892 | 892 | ||
893 | mEnabledCheck->setChecked( recurs ); | 893 | mEnabledCheck->setChecked( recurs ); |
894 | setEnabled( recurs ); | 894 | setEnabled( recurs ); |
895 | 895 | ||
896 | int recurrenceType = RecurrenceChooser::Weekly; | 896 | int recurrenceType = RecurrenceChooser::Weekly; |
897 | 897 | ||
898 | switch ( recurs ) { | 898 | switch ( recurs ) { |
899 | case Recurrence::rNone: | 899 | case Recurrence::rNone: |
900 | setDefaults( event->dtStart(), dtEnd, true ); | 900 | setDefaults( event->dtStart(), dtEnd, true ); |
901 | break; | 901 | break; |
902 | case Recurrence::rDaily: | 902 | case Recurrence::rDaily: |
903 | recurrenceType = RecurrenceChooser::Daily; | 903 | recurrenceType = RecurrenceChooser::Daily; |
904 | mDaily->setFrequency( f ); | 904 | mDaily->setFrequency( f ); |
905 | break; | 905 | break; |
906 | case Recurrence::rWeekly: | 906 | case Recurrence::rWeekly: |
907 | recurrenceType = RecurrenceChooser::Weekly; | 907 | recurrenceType = RecurrenceChooser::Weekly; |
908 | mWeekly->setFrequency( f ); | 908 | mWeekly->setFrequency( f ); |
909 | mWeekly->setDays( r->days() ); | 909 | mWeekly->setDays( r->days() ); |
910 | break; | 910 | break; |
911 | case Recurrence::rMonthlyPos: | 911 | case Recurrence::rMonthlyPos: |
912 | // we only handle one possibility in the list right now, | 912 | // we only handle one possibility in the list right now, |
913 | // so I have hardcoded calls with first(). If we make the GUI | 913 | // so I have hardcoded calls with first(). If we make the GUI |
914 | // more extended, this can be changed. | 914 | // more extended, this can be changed. |
915 | recurrenceType = RecurrenceChooser::Monthly; | 915 | recurrenceType = RecurrenceChooser::Monthly; |
916 | 916 | ||
917 | rmp = r->monthPositions(); | 917 | rmp = r->monthPositions(); |
918 | if ( rmp.first()->negative ) | 918 | if ( rmp.first()->negative ) |
919 | count = 5 - rmp.first()->rPos - 1; | 919 | count = 5 - rmp.first()->rPos - 1; |
920 | else | 920 | else |
921 | count = rmp.first()->rPos - 1; | 921 | count = rmp.first()->rPos - 1; |
922 | day = 0; | 922 | day = 0; |
923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
924 | mMonthly->setByPos( count, day ); | 924 | mMonthly->setByPos( count, day ); |
925 | 925 | ||
926 | mMonthly->setFrequency( f ); | 926 | mMonthly->setFrequency( f ); |
927 | 927 | ||
928 | break; | 928 | break; |
929 | case Recurrence::rMonthlyDay: | 929 | case Recurrence::rMonthlyDay: |
930 | recurrenceType = RecurrenceChooser::Monthly; | 930 | recurrenceType = RecurrenceChooser::Monthly; |
931 | 931 | ||
932 | rmd = r->monthDays(); | 932 | rmd = r->monthDays(); |
933 | day = *rmd.first() - 1; | 933 | day = *rmd.first() - 1; |
934 | mMonthly->setByDay( day ); | 934 | mMonthly->setByDay( day ); |
935 | 935 | ||
936 | mMonthly->setFrequency( f ); | 936 | mMonthly->setFrequency( f ); |
937 | 937 | ||
938 | break; | 938 | break; |
939 | case Recurrence::rYearlyMonth: | 939 | case Recurrence::rYearlyMonth: |
940 | { | 940 | { |
941 | recurrenceType = RecurrenceChooser::Yearly; | 941 | recurrenceType = RecurrenceChooser::Yearly; |
942 | qDebug("Recurrence::rYearlyMonth: "); | 942 | //qDebug("Recurrence::rYearlyMonth: "); |
943 | day = event->dtStart().date().day(); | 943 | day = event->dtStart().date().day(); |
944 | rmd = r->yearNums(); | 944 | rmd = r->yearNums(); |
945 | if ( rmd.count() > 0 ) | 945 | if ( rmd.count() > 0 ) |
946 | month = *rmd.first(); | 946 | month = *rmd.first(); |
947 | else | 947 | else |
948 | month = event->dtStart().date().month() ; | 948 | month = event->dtStart().date().month() ; |
949 | mYearly->setByMonth( month, day ); | 949 | mYearly->setByMonth( month, day ); |
950 | #if 0 | 950 | #if 0 |
951 | qDebug("2day = %d ",day ); | 951 | //qDebug("2day = %d ",day ); |
952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
953 | int month; | 953 | int month; |
954 | if ( !monthlist.isEmpty() ) { | 954 | if ( !monthlist.isEmpty() ) { |
955 | month = monthlist.first()->rPos ; | 955 | month = monthlist.first()->rPos ; |
956 | } else { | 956 | } else { |
957 | month = event->dtStart().date().month() ; | 957 | month = event->dtStart().date().month() ; |
958 | } | 958 | } |
959 | mYearly->setByMonth( day, month ); | 959 | mYearly->setByMonth( day, month ); |
960 | #endif | 960 | #endif |
961 | mYearly->setFrequency( f ); | 961 | mYearly->setFrequency( f ); |
962 | } | 962 | } |
963 | 963 | ||
964 | break; | 964 | break; |
965 | case Recurrence::rYearlyDay: | 965 | case Recurrence::rYearlyDay: |
966 | qDebug("Recurrence::rYearlyDay: "); | 966 | //qDebug("Recurrence::rYearlyDay: "); |
967 | recurrenceType = RecurrenceChooser::Yearly; | 967 | recurrenceType = RecurrenceChooser::Yearly; |
968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
969 | mYearly->setFrequency( f ); | 969 | mYearly->setFrequency( f ); |
970 | break; | 970 | break; |
971 | default: | 971 | default: |
972 | setDefaults( event->dtStart(), dtEnd, true ); | 972 | setDefaults( event->dtStart(), dtEnd, true ); |
973 | break; | 973 | break; |
974 | } | 974 | } |
975 | 975 | ||
976 | mRecurrenceChooser->setType( recurrenceType ); | 976 | mRecurrenceChooser->setType( recurrenceType ); |
977 | showCurrentRule( recurrenceType ); | 977 | showCurrentRule( recurrenceType ); |
978 | 978 | ||
979 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 979 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
980 | 980 | ||
981 | if ( r->doesRecur() ) { | 981 | if ( r->doesRecur() ) { |
982 | mRecurrenceRange->setDuration( r->duration() ); | 982 | mRecurrenceRange->setDuration( r->duration() ); |
983 | if ( r->duration() == 0 ) | 983 | if ( r->duration() == 0 ) |
984 | { | 984 | { |
985 | if ( r->endDate() < event->dtStart().date() ) | 985 | if ( r->endDate() < event->dtStart().date() ) |
986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
987 | else | 987 | else |
988 | mRecurrenceRange->setEndDate( r->endDate() ); | 988 | mRecurrenceRange->setEndDate( r->endDate() ); |
989 | } else | 989 | } else |
990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
991 | } | 991 | } |
992 | 992 | ||
993 | mExceptions->setDates( event->exDates() ); | 993 | mExceptions->setDates( event->exDates() ); |
994 | } | 994 | } |
995 | 995 | ||
996 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 996 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
997 | { | 997 | { |
998 | Recurrence *r = event->recurrence(); | 998 | Recurrence *r = event->recurrence(); |
999 | 999 | ||
1000 | // clear out any old settings; | 1000 | // clear out any old settings; |
1001 | r->unsetRecurs(); | 1001 | r->unsetRecurs(); |
1002 | 1002 | ||
1003 | if ( mEnabledCheck->isChecked() ) { | 1003 | if ( mEnabledCheck->isChecked() ) { |
1004 | int duration = mRecurrenceRange->duration(); | 1004 | int duration = mRecurrenceRange->duration(); |
1005 | QDate endDate; | 1005 | QDate endDate; |
1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1007 | 1007 | ||
1008 | int recurrenceType = mRecurrenceChooser->type(); | 1008 | int recurrenceType = mRecurrenceChooser->type(); |
1009 | 1009 | ||
1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1011 | int freq = mDaily->frequency(); | 1011 | int freq = mDaily->frequency(); |
1012 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1012 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1013 | else r->setDaily( freq, endDate ); | 1013 | else r->setDaily( freq, endDate ); |
1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1015 | int freq = mWeekly->frequency(); | 1015 | int freq = mWeekly->frequency(); |
1016 | QBitArray days = mWeekly->days(); | 1016 | QBitArray days = mWeekly->days(); |
1017 | int j; | 1017 | int j; |
1018 | bool found = false; | 1018 | bool found = false; |
1019 | for (j = 0; j < 7 ; ++j ) { | 1019 | for (j = 0; j < 7 ; ++j ) { |
1020 | found |=days.at(j); | 1020 | found |=days.at(j); |
1021 | } | 1021 | } |
1022 | if ( !found ) { | 1022 | if ( !found ) { |
1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1024 | qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1025 | } | 1025 | } |
1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1027 | else r->setWeekly( freq, days, endDate ); | 1027 | else r->setWeekly( freq, days, endDate ); |
1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1029 | int freq = mMonthly->frequency(); | 1029 | int freq = mMonthly->frequency(); |
1030 | if ( mMonthly->byPos() ) { | 1030 | if ( mMonthly->byPos() ) { |
1031 | int pos = mMonthly->count(); | 1031 | int pos = mMonthly->count(); |
1032 | 1032 | ||
1033 | QBitArray days( 7 ); | 1033 | QBitArray days( 7 ); |
1034 | days.fill( false ); | 1034 | days.fill( false ); |
1035 | 1035 | ||
1036 | days.setBit( mMonthly->weekday() ); | 1036 | days.setBit( mMonthly->weekday() ); |
1037 | if ( duration != 0 ) | 1037 | if ( duration != 0 ) |
1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1039 | else | 1039 | else |
1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1041 | r->addMonthlyPos( pos, days ); | 1041 | r->addMonthlyPos( pos, days ); |
1042 | } else { | 1042 | } else { |
1043 | // it's by day | 1043 | // it's by day |
1044 | int day = mMonthly->day(); | 1044 | int day = mMonthly->day(); |
1045 | 1045 | ||
1046 | if ( duration != 0 ) { | 1046 | if ( duration != 0 ) { |
1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1048 | } else { | 1048 | } else { |
1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1050 | } | 1050 | } |
1051 | r->addMonthlyDay( day ); | 1051 | r->addMonthlyDay( day ); |
1052 | } | 1052 | } |
1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1054 | qDebug("RecurrenceChooser::Yearly "); | 1054 | //qDebug("RecurrenceChooser::Yearly "); |
1055 | int freq = mYearly->frequency(); | 1055 | int freq = mYearly->frequency(); |
1056 | if ( mYearly->byDay() ) { | 1056 | if ( mYearly->byDay() ) { |
1057 | if ( duration != 0 ) { | 1057 | if ( duration != 0 ) { |
1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1059 | } else { | 1059 | } else { |
1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1061 | } | 1061 | } |
1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1063 | } else { | 1063 | } else { |
1064 | if ( duration != 0 ) { | 1064 | if ( duration != 0 ) { |
1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1066 | } else { | 1066 | } else { |
1067 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1067 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1068 | } | 1068 | } |
1069 | r->addYearlyNum( mYearly->month() ); | 1069 | r->addYearlyNum( mYearly->month() ); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | event->setExDates( mExceptions->dates() ); | 1074 | event->setExDates( mExceptions->dates() ); |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1078 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1079 | { | 1079 | { |
1080 | mDateTimeLabel->setText( str ); | 1080 | mDateTimeLabel->setText( str ); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | bool KOEditorRecurrence::validateInput() | 1083 | bool KOEditorRecurrence::validateInput() |
1084 | { | 1084 | { |
1085 | // Check input here | 1085 | // Check input here |
1086 | 1086 | ||
1087 | return true; | 1087 | return true; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | void KOEditorRecurrence::showExceptionsDialog() | 1090 | void KOEditorRecurrence::showExceptionsDialog() |
1091 | { | 1091 | { |
1092 | DateList dates = mExceptions->dates(); | 1092 | DateList dates = mExceptions->dates(); |
1093 | int result = mExceptionsDialog->exec(); | 1093 | int result = mExceptionsDialog->exec(); |
1094 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1094 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1097 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1098 | { | 1098 | { |
1099 | int duration = mRecurrenceRange->duration(); | 1099 | int duration = mRecurrenceRange->duration(); |
1100 | QDate endDate = mRecurrenceRange->endDate(); | 1100 | QDate endDate = mRecurrenceRange->endDate(); |
1101 | 1101 | ||
1102 | int result = mRecurrenceRangeDialog->exec(); | 1102 | int result = mRecurrenceRangeDialog->exec(); |
1103 | if ( result == QDialog::Rejected ) { | 1103 | if ( result == QDialog::Rejected ) { |
1104 | mRecurrenceRange->setDuration( duration ); | 1104 | mRecurrenceRange->setDuration( duration ); |
1105 | mRecurrenceRange->setEndDate( endDate ); | 1105 | mRecurrenceRange->setEndDate( endDate ); |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | } | 1108 | } |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index fefc778..f39b5e1 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,366 +1,362 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | 56 | #include <qprinter.h> |
57 | #include <qpainter.h> | 57 | #include <qpainter.h> |
58 | #include <qpaintdevicemetrics.h> | 58 | #include <qpaintdevicemetrics.h> |
59 | #else //DESKTOP_VERSION | 59 | #else //DESKTOP_VERSION |
60 | #include <externalapphandler.h> | 60 | #include <externalapphandler.h> |
61 | #include <qtopia/qcopenvelope_qws.h> | 61 | #include <qtopia/qcopenvelope_qws.h> |
62 | #endif //DESKTOP_VERSION | 62 | #endif //DESKTOP_VERSION |
63 | 63 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
65 | : QTextBrowser(parent,name) | 65 | : QTextBrowser(parent,name) |
66 | { | 66 | { |
67 | mSyncMode = false; | 67 | mSyncMode = false; |
68 | mColorMode = 0; | 68 | mColorMode = 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KOEventViewer::printMe() | 75 | void KOEventViewer::printMe() |
76 | { | 76 | { |
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | 78 | ||
79 | KOPrintPrefs pp ( this ); | 79 | KOPrintPrefs pp ( this ); |
80 | if (!pp.exec() ) | 80 | if (!pp.exec() ) |
81 | return; | 81 | return; |
82 | int scaleval = pp.printMode() ; | 82 | int scaleval = pp.printMode() ; |
83 | 83 | ||
84 | QPrinter printer; | 84 | QPrinter printer; |
85 | if (!printer.setup() ) | 85 | if (!printer.setup() ) |
86 | return; | 86 | return; |
87 | QPainter p; | 87 | QPainter p; |
88 | p.begin ( &printer ); | 88 | p.begin ( &printer ); |
89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
90 | float dx, dy; | 90 | float dx, dy; |
91 | int wid = (m.width() * 9)/10; | 91 | int wid = (m.width() * 9)/10; |
92 | dx = (float) wid/(float)contentsWidth (); | 92 | dx = (float) wid/(float)contentsWidth (); |
93 | dy = (float)(m.height()) / (float)contentsHeight (); | 93 | dy = (float)(m.height()) / (float)contentsHeight (); |
94 | float scale; | 94 | float scale; |
95 | // scale to fit the width or height of the paper | 95 | // scale to fit the width or height of the paper |
96 | if ( dx < dy ) | 96 | if ( dx < dy ) |
97 | scale = dx; | 97 | scale = dx; |
98 | else | 98 | else |
99 | scale = dy; | 99 | scale = dy; |
100 | 100 | ||
101 | p.translate( m.width()/10,0 ); | 101 | p.translate( m.width()/10,0 ); |
102 | qDebug("Scale: %f ", scale ); | ||
103 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
104 | qDebug("SCALE "); | ||
105 | p.scale( scale, scale ); | 103 | p.scale( scale, scale ); |
106 | } | 104 | } |
107 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
108 | p.end(); | 106 | p.end(); |
109 | #endif | 107 | #endif |
110 | 108 | ||
111 | } | 109 | } |
112 | void KOEventViewer::setSource(const QString& n) | 110 | void KOEventViewer::setSource(const QString& n) |
113 | { | 111 | { |
114 | 112 | ||
115 | if ( n.left(3) == "uid" ) | 113 | if ( n.left(3) == "uid" ) |
116 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
117 | { | 115 | { |
118 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 116 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
119 | KABC::AddressBook::Iterator it; | 117 | KABC::AddressBook::Iterator it; |
120 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 118 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
121 | // LR I do not understand, why the uid string is different on zaurus and desktop | 119 | // LR I do not understand, why the uid string is different on zaurus and desktop |
122 | QString uid = "uid://"+(*it).uid(); | 120 | QString uid = "uid://"+(*it).uid(); |
123 | 121 | ||
124 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 122 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
125 | if (n == uid ) { | 123 | if (n == uid ) { |
126 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 124 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
127 | QDialog dia( this,"dia123", true ); | 125 | QDialog dia( this,"dia123", true ); |
128 | dia.setCaption( i18n("Details of attendee") ); | 126 | dia.setCaption( i18n("Details of attendee") ); |
129 | QVBoxLayout lay ( &dia ); | 127 | QVBoxLayout lay ( &dia ); |
130 | KABC::AddresseeView av ( &dia ); | 128 | KABC::AddresseeView av ( &dia ); |
131 | av.setAddressee( (*it) ); | 129 | av.setAddressee( (*it) ); |
132 | lay.addWidget( &av ); | 130 | lay.addWidget( &av ); |
133 | if ( QApplication::desktop()->width() < 480 ) | 131 | if ( QApplication::desktop()->width() < 480 ) |
134 | dia.resize( 220, 240); | 132 | dia.resize( 220, 240); |
135 | else { | 133 | else { |
136 | dia.resize( 400,400); | 134 | dia.resize( 400,400); |
137 | } | 135 | } |
138 | dia.exec(); | 136 | dia.exec(); |
139 | break; | 137 | break; |
140 | } | 138 | } |
141 | } | 139 | } |
142 | return; | 140 | return; |
143 | } | 141 | } |
144 | #else | 142 | #else |
145 | { | 143 | { |
146 | if ( "uid:organizer" == n ) { | 144 | if ( "uid:organizer" == n ) { |
147 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 145 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
148 | return; | 146 | return; |
149 | } | 147 | } |
150 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 148 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
151 | if (attendees.count()) { | 149 | if (attendees.count()) { |
152 | Attendee *a; | 150 | Attendee *a; |
153 | for(a=attendees.first();a;a=attendees.next()) { | 151 | for(a=attendees.first();a;a=attendees.next()) { |
154 | if ( "uid:"+a->uid() == n ) { | 152 | if ( "uid:"+a->uid() == n ) { |
155 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 153 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
156 | return; | 154 | return; |
157 | } | 155 | } |
158 | } | 156 | } |
159 | } | 157 | } |
160 | return; | 158 | return; |
161 | } | 159 | } |
162 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 160 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
163 | // the result should now arrive through method insertAttendees | 161 | // the result should now arrive through method insertAttendees |
164 | //QString uid = "uid:"+(*it).uid(); | 162 | //QString uid = "uid:"+(*it).uid(); |
165 | #endif | 163 | #endif |
166 | if ( n.left(6) == "mailto" ) { | 164 | if ( n.left(6) == "mailto" ) { |
167 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 165 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
168 | #ifndef DESKTOP_VERSION | 166 | #ifndef DESKTOP_VERSION |
169 | if ( n.mid(7,3) == "ALL" ) { | 167 | if ( n.mid(7,3) == "ALL" ) { |
170 | qDebug("all "); | ||
171 | mailToAttendees( true ); | 168 | mailToAttendees( true ); |
172 | } else if ( n.mid(7,4) == "RSVP" ) { | 169 | } else if ( n.mid(7,4) == "RSVP" ) { |
173 | mailToAttendees( false ); | 170 | mailToAttendees( false ); |
174 | qDebug("rsvp "); | ||
175 | } else { | 171 | } else { |
176 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 172 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
177 | e << n.mid(7); | 173 | e << n.mid(7); |
178 | } | 174 | } |
179 | #endif | 175 | #endif |
180 | 176 | ||
181 | } | 177 | } |
182 | 178 | ||
183 | 179 | ||
184 | #ifndef KORG_NODCOP | 180 | #ifndef KORG_NODCOP |
185 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 181 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
186 | QString tmpStr; | 182 | QString tmpStr; |
187 | if (n.startsWith("mailto:")) { | 183 | if (n.startsWith("mailto:")) { |
188 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 184 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
189 | //emit showIncidence(n); | 185 | //emit showIncidence(n); |
190 | return; | 186 | return; |
191 | } else if (n.startsWith("uid:")) { | 187 | } else if (n.startsWith("uid:")) { |
192 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 188 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
193 | const QByteArray noParamData; | 189 | const QByteArray noParamData; |
194 | const QByteArray paramData; | 190 | const QByteArray paramData; |
195 | QByteArray replyData; | 191 | QByteArray replyData; |
196 | QCString replyTypeStr; | 192 | QCString replyTypeStr; |
197 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 193 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
198 | bool foundAbbrowser = PING_ABBROWSER; | 194 | bool foundAbbrowser = PING_ABBROWSER; |
199 | 195 | ||
200 | if (foundAbbrowser) { | 196 | if (foundAbbrowser) { |
201 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 197 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
202 | //client->send("kaddressbook","KAddressBookIface", | 198 | //client->send("kaddressbook","KAddressBookIface", |
203 | QDataStream arg(paramData, IO_WriteOnly); | 199 | QDataStream arg(paramData, IO_WriteOnly); |
204 | arg << n.mid(6); | 200 | arg << n.mid(6); |
205 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 201 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
206 | return; | 202 | return; |
207 | } else { | 203 | } else { |
208 | /* | 204 | /* |
209 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 205 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
210 | We start it without its main interface | 206 | We start it without its main interface |
211 | */ | 207 | */ |
212 | KIconLoader* iconLoader = new KIconLoader(); | 208 | KIconLoader* iconLoader = new KIconLoader(); |
213 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 209 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
214 | ActionManager::setStartedKAddressBook(true); | 210 | ActionManager::setStartedKAddressBook(true); |
215 | tmpStr = "kaddressbook --editor-only --uid "; | 211 | tmpStr = "kaddressbook --editor-only --uid "; |
216 | tmpStr += KProcess::quote(n.mid(6)); | 212 | tmpStr += KProcess::quote(n.mid(6)); |
217 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 213 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
218 | return; | 214 | return; |
219 | } | 215 | } |
220 | } else { | 216 | } else { |
221 | //QTextBrowser::setSource(n); | 217 | //QTextBrowser::setSource(n); |
222 | } | 218 | } |
223 | #endif | 219 | #endif |
224 | } | 220 | } |
225 | void KOEventViewer::mailToAttendees( bool all ) | 221 | void KOEventViewer::mailToAttendees( bool all ) |
226 | { | 222 | { |
227 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 223 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
228 | if (attendees.count() == 0) return; | 224 | if (attendees.count() == 0) return; |
229 | QStringList nameList; | 225 | QStringList nameList; |
230 | QStringList emailList; | 226 | QStringList emailList; |
231 | QStringList uidList; | 227 | QStringList uidList; |
232 | Attendee* a; | 228 | Attendee* a; |
233 | for(a=attendees.first();a;a=attendees.next()) { | 229 | for(a=attendees.first();a;a=attendees.next()) { |
234 | if ( !all && !a->RSVP() ) continue; | 230 | if ( !all && !a->RSVP() ) continue; |
235 | if (!a->email().isEmpty()) { | 231 | if (!a->email().isEmpty()) { |
236 | nameList.append (a->name() ); | 232 | nameList.append (a->name() ); |
237 | emailList.append (a->email() ); | 233 | emailList.append (a->email() ); |
238 | uidList.append (a->uid() ); | 234 | uidList.append (a->uid() ); |
239 | } | 235 | } |
240 | } | 236 | } |
241 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 237 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
242 | #ifndef DESKTOP_VERSION | 238 | #ifndef DESKTOP_VERSION |
243 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 239 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
244 | #endif | 240 | #endif |
245 | 241 | ||
246 | } | 242 | } |
247 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 243 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
248 | { | 244 | { |
249 | int number=text.contains("\n"); | 245 | int number=text.contains("\n"); |
250 | QString str = "<" + tag + ">"; | 246 | QString str = "<" + tag + ">"; |
251 | QString tmpText=text; | 247 | QString tmpText=text; |
252 | QString tmpStr=str; | 248 | QString tmpStr=str; |
253 | if(number !=-1) | 249 | if(number !=-1) |
254 | { | 250 | { |
255 | if (number > 0) { | 251 | if (number > 0) { |
256 | int pos=0; | 252 | int pos=0; |
257 | QString tmp; | 253 | QString tmp; |
258 | for(int i=0;i<=number;i++) { | 254 | for(int i=0;i<=number;i++) { |
259 | pos=tmpText.find("\n"); | 255 | pos=tmpText.find("\n"); |
260 | tmp=tmpText.left(pos); | 256 | tmp=tmpText.left(pos); |
261 | tmpText=tmpText.right(tmpText.length()-pos-1); | 257 | tmpText=tmpText.right(tmpText.length()-pos-1); |
262 | tmpStr+=tmp+"<br>"; | 258 | tmpStr+=tmp+"<br>"; |
263 | } | 259 | } |
264 | } | 260 | } |
265 | else tmpStr += tmpText; | 261 | else tmpStr += tmpText; |
266 | tmpStr+="</" + tag + ">"; | 262 | tmpStr+="</" + tag + ">"; |
267 | mText.append(tmpStr); | 263 | mText.append(tmpStr); |
268 | } | 264 | } |
269 | else | 265 | else |
270 | { | 266 | { |
271 | str += text + "</" + tag + ">"; | 267 | str += text + "</" + tag + ">"; |
272 | mText.append(str); | 268 | mText.append(str); |
273 | } | 269 | } |
274 | } | 270 | } |
275 | 271 | ||
276 | void KOEventViewer::setColorMode( int m ) | 272 | void KOEventViewer::setColorMode( int m ) |
277 | { | 273 | { |
278 | mColorMode = m; | 274 | mColorMode = m; |
279 | } | 275 | } |
280 | void KOEventViewer::appendEvent(Event *event, int mode ) | 276 | void KOEventViewer::appendEvent(Event *event, int mode ) |
281 | { | 277 | { |
282 | mMailSubject = ""; | 278 | mMailSubject = ""; |
283 | mCurrentIncidence = event; | 279 | mCurrentIncidence = event; |
284 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 280 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
285 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 281 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
286 | if ( mode == 0 ) { | 282 | if ( mode == 0 ) { |
287 | addTag("h2",deTag(event->summary())); | 283 | addTag("h2",deTag(event->summary())); |
288 | } | 284 | } |
289 | else { | 285 | else { |
290 | if ( mColorMode == 1 ) { | 286 | if ( mColorMode == 1 ) { |
291 | mText +="<font color=\"#00A000\">"; | 287 | mText +="<font color=\"#00A000\">"; |
292 | } | 288 | } |
293 | if ( mColorMode == 2 ) { | 289 | if ( mColorMode == 2 ) { |
294 | mText +="<font color=\"#C00000\">"; | 290 | mText +="<font color=\"#C00000\">"; |
295 | } | 291 | } |
296 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 292 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
297 | if ( mode == 1 ) { | 293 | if ( mode == 1 ) { |
298 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 294 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
299 | } else { | 295 | } else { |
300 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 296 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
301 | } | 297 | } |
302 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 298 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
303 | if ( mColorMode ) | 299 | if ( mColorMode ) |
304 | mText += "</font>"; | 300 | mText += "</font>"; |
305 | } | 301 | } |
306 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 302 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
307 | if (event->cancelled ()) { | 303 | if (event->cancelled ()) { |
308 | mText +="<font color=\"#B00000\">"; | 304 | mText +="<font color=\"#B00000\">"; |
309 | addTag("i",i18n("This event has been cancelled!")); | 305 | addTag("i",i18n("This event has been cancelled!")); |
310 | mText.append("<br>"); | 306 | mText.append("<br>"); |
311 | mText += "</font>"; | 307 | mText += "</font>"; |
312 | mMailSubject += i18n("(cancelled)"); | 308 | mMailSubject += i18n("(cancelled)"); |
313 | } | 309 | } |
314 | 310 | ||
315 | if (event->doesFloat()) { | 311 | if (event->doesFloat()) { |
316 | if (event->isMultiDay()) { | 312 | if (event->isMultiDay()) { |
317 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 313 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
318 | .arg(event->dtStartDateStr(shortDate)) | 314 | .arg(event->dtStartDateStr(shortDate)) |
319 | .arg(event->dtEndDateStr(shortDate))); | 315 | .arg(event->dtEndDateStr(shortDate))); |
320 | } else { | 316 | } else { |
321 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 317 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
322 | } | 318 | } |
323 | } else { | 319 | } else { |
324 | if (event->isMultiDay()) { | 320 | if (event->isMultiDay()) { |
325 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 321 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
326 | .arg(event->dtStartStr( shortDate))); | 322 | .arg(event->dtStartStr( shortDate))); |
327 | mText.append(i18n("<p><b>To:</b> %1</p>") | 323 | mText.append(i18n("<p><b>To:</b> %1</p>") |
328 | .arg(event->dtEndStr(shortDate))); | 324 | .arg(event->dtEndStr(shortDate))); |
329 | } else { | 325 | } else { |
330 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 326 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
331 | .arg(event->dtStartTimeStr()) | 327 | .arg(event->dtStartTimeStr()) |
332 | .arg(event->dtEndTimeStr())); | 328 | .arg(event->dtEndTimeStr())); |
333 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 329 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
334 | .arg(event->dtStartDateStr( shortDate ))); | 330 | .arg(event->dtStartDateStr( shortDate ))); |
335 | } | 331 | } |
336 | } | 332 | } |
337 | if (!event->location().isEmpty()) { | 333 | if (!event->location().isEmpty()) { |
338 | addTag("b",i18n("Location: ")); | 334 | addTag("b",i18n("Location: ")); |
339 | mText.append(deTag(event->location())+"<br>"); | 335 | mText.append(deTag(event->location())+"<br>"); |
340 | mMailSubject += i18n(" at ") + event->location(); | 336 | mMailSubject += i18n(" at ") + event->location(); |
341 | } | 337 | } |
342 | if (event->recurrence()->doesRecur()) { | 338 | if (event->recurrence()->doesRecur()) { |
343 | 339 | ||
344 | QString recurText = event->recurrence()->recurrenceText(); | 340 | QString recurText = event->recurrence()->recurrenceText(); |
345 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 341 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
346 | bool ok; | 342 | bool ok; |
347 | QDate start = QDate::currentDate(); | 343 | QDate start = QDate::currentDate(); |
348 | QDateTime next; | 344 | QDateTime next; |
349 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 345 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
350 | if ( ok ) { | 346 | if ( ok ) { |
351 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 347 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
352 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 348 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
353 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 349 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
354 | 350 | ||
355 | } else { | 351 | } else { |
356 | bool last; | 352 | bool last; |
357 | QDate nextd; | 353 | QDate nextd; |
358 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 354 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
359 | if ( last ) { | 355 | if ( last ) { |
360 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 356 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
361 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 357 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
362 | } | 358 | } |
363 | } | 359 | } |
364 | } else { | 360 | } else { |
365 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 361 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
366 | 362 | ||
diff --git a/korganizer/koglobals.cpp b/korganizer/koglobals.cpp index 8016034..9ece77f 100644 --- a/korganizer/koglobals.cpp +++ b/korganizer/koglobals.cpp | |||
@@ -1,143 +1,114 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <kglobal.h> | 27 | #include <kglobal.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | #include <kglobalsettings.h> | 30 | #include <kglobalsettings.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #ifndef KORG_NOKALARMD | ||
36 | #include "kalarmdclient.h" | ||
37 | #endif | ||
38 | #include "simplealarmclient.h" | ||
39 | 35 | ||
40 | #include "koglobals.h" | 36 | #include "koglobals.h" |
41 | #include "koprefs.h" | 37 | #include "koprefs.h" |
42 | 38 | ||
43 | class NopAlarmClient : public AlarmClient | ||
44 | { | ||
45 | public: | ||
46 | void startDaemon() {} | ||
47 | bool setCalendars( const QStringList & ) { return false; } | ||
48 | bool addCalendar( const QString & ) { return false; } | ||
49 | bool removeCalendar( const QString & ) { return false; } | ||
50 | bool reloadCalendar( const QString & ) { return false; } | ||
51 | }; | ||
52 | 39 | ||
53 | KOGlobals *KOGlobals::mSelf = 0; | 40 | KOGlobals *KOGlobals::mSelf = 0; |
54 | 41 | ||
55 | KOGlobals *KOGlobals::self() | 42 | KOGlobals *KOGlobals::self() |
56 | { | 43 | { |
57 | if (!mSelf) { | 44 | if (!mSelf) { |
58 | mSelf = new KOGlobals; | 45 | mSelf = new KOGlobals; |
59 | } | 46 | } |
60 | 47 | ||
61 | return mSelf; | 48 | return mSelf; |
62 | } | 49 | } |
63 | 50 | ||
64 | KOGlobals::KOGlobals() | 51 | KOGlobals::KOGlobals() |
65 | { | 52 | { |
66 | KConfig *cfg = KOGlobals::config(); | 53 | KConfig *cfg = KOGlobals::config(); |
67 | 54 | ||
68 | cfg->setGroup("General"); | 55 | cfg->setGroup("General"); |
69 | mCalendarSystem = KGlobal::locale()->calendar(); | 56 | mCalendarSystem = KGlobal::locale()->calendar(); |
70 | 57 | ||
71 | cfg->setGroup("AlarmDaemon"); | ||
72 | QString alarmClient = cfg->readEntry( "Daemon", "kalarmd" ); | ||
73 | if ( alarmClient == "simple" ) { | ||
74 | mAlarmClient = new SimpleAlarmClient; | ||
75 | #ifndef KORG_NOKALARMD | ||
76 | } else if ( alarmClient == "kalarmd" ) { | ||
77 | mAlarmClient = new KalarmdClient; | ||
78 | #endif | ||
79 | } else { | ||
80 | mAlarmClient = new NopAlarmClient; | ||
81 | } | ||
82 | } | 58 | } |
83 | 59 | ||
84 | KConfig* KOGlobals::config() | 60 | KConfig* KOGlobals::config() |
85 | { | 61 | { |
86 | static KConfig *mConfig = 0; | 62 | static KConfig *mConfig = 0; |
87 | if (!mConfig) { | 63 | if (!mConfig) { |
88 | KOPrefs *p = KOPrefs::instance(); | 64 | KOPrefs *p = KOPrefs::instance(); |
89 | mConfig = p->getConfig(); | 65 | mConfig = p->getConfig(); |
90 | //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) ); | 66 | //mConfig = new KConfig( locateLocal( "config", "korganizerrc" ) ); |
91 | } | 67 | } |
92 | return mConfig; | 68 | return mConfig; |
93 | } | 69 | } |
94 | 70 | ||
95 | KOGlobals::~KOGlobals() | 71 | KOGlobals::~KOGlobals() |
96 | { | 72 | { |
97 | delete mAlarmClient; | 73 | |
98 | } | 74 | } |
99 | 75 | ||
100 | const KCalendarSystem *KOGlobals::calendarSystem() const | 76 | const KCalendarSystem *KOGlobals::calendarSystem() const |
101 | { | 77 | { |
102 | return mCalendarSystem; | 78 | return mCalendarSystem; |
103 | } | 79 | } |
104 | 80 | ||
105 | AlarmClient *KOGlobals::alarmClient() const | ||
106 | { | ||
107 | return mAlarmClient; | ||
108 | } | ||
109 | |||
110 | void KOGlobals::fitDialogToScreen( QWidget *wid, bool force ) | 81 | void KOGlobals::fitDialogToScreen( QWidget *wid, bool force ) |
111 | { | 82 | { |
112 | bool resized = false; | 83 | bool resized = false; |
113 | 84 | ||
114 | int w = wid->frameSize().width(); | 85 | int w = wid->frameSize().width(); |
115 | int h = wid->frameSize().height(); | 86 | int h = wid->frameSize().height(); |
116 | 87 | ||
117 | QRect desk = KGlobalSettings::desktopGeometry(wid); | 88 | QRect desk = KGlobalSettings::desktopGeometry(wid); |
118 | if ( w > desk.width() ) { | 89 | if ( w > desk.width() ) { |
119 | w = desk.width(); | 90 | w = desk.width(); |
120 | resized = true; | 91 | resized = true; |
121 | } | 92 | } |
122 | // Yuck this hack is ugly. Is the -30 really to circumvent the size of | 93 | // Yuck this hack is ugly. Is the -30 really to circumvent the size of |
123 | // kicker?! | 94 | // kicker?! |
124 | if ( h > desk.height() - 30 ) { | 95 | if ( h > desk.height() - 30 ) { |
125 | h = desk.height() - 30; | 96 | h = desk.height() - 30; |
126 | resized = true; | 97 | resized = true; |
127 | } | 98 | } |
128 | 99 | ||
129 | if ( resized || force ) { | 100 | if ( resized || force ) { |
130 | wid->resize( w, h ); | 101 | wid->resize( w, h ); |
131 | wid->move( desk.x(), desk.y()+15 ); | 102 | wid->move( desk.x(), desk.y()+15 ); |
132 | if ( force ) wid->setFixedSize( w, h ); | 103 | if ( force ) wid->setFixedSize( w, h ); |
133 | } | 104 | } |
134 | } | 105 | } |
135 | 106 | ||
136 | bool KOGlobals::reverseLayout() | 107 | bool KOGlobals::reverseLayout() |
137 | { | 108 | { |
138 | #if QT_VERSION >= 0x030000 | 109 | #if QT_VERSION >= 0x030000 |
139 | return QApplication::reverseLayout(); | 110 | return QApplication::reverseLayout(); |
140 | #else | 111 | #else |
141 | return false; | 112 | return false; |
142 | #endif | 113 | #endif |
143 | } | 114 | } |
diff --git a/korganizer/koglobals.h b/korganizer/koglobals.h index 357ff5f..b3ff67b 100644 --- a/korganizer/koglobals.h +++ b/korganizer/koglobals.h | |||
@@ -1,59 +1,56 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KORG_GLOBALS_H | 23 | #ifndef KORG_GLOBALS_H |
24 | #define KORG_GLOBALS_H | 24 | #define KORG_GLOBALS_H |
25 | 25 | ||
26 | class KCalendarSystem; | 26 | class KCalendarSystem; |
27 | class AlarmClient; | 27 | class AlarmClient; |
28 | 28 | ||
29 | class KConfig; | 29 | class KConfig; |
30 | 30 | ||
31 | class KOGlobals | 31 | class KOGlobals |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | static KOGlobals *self(); | 34 | static KOGlobals *self(); |
35 | 35 | ||
36 | enum { EVENTADDED, EVENTEDITED, EVENTDELETED }; | 36 | enum { EVENTADDED, EVENTEDITED, EVENTDELETED }; |
37 | enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED }; | 37 | enum { PRIORITY_MODIFIED, COMPLETION_MODIFIED, CATEGORY_MODIFIED, UNKNOWN_MODIFIED }; |
38 | 38 | ||
39 | static void fitDialogToScreen( QWidget *widget, bool force=false ); | 39 | static void fitDialogToScreen( QWidget *widget, bool force=false ); |
40 | static KConfig *config(); | 40 | static KConfig *config(); |
41 | 41 | ||
42 | static bool reverseLayout(); | 42 | static bool reverseLayout(); |
43 | 43 | ||
44 | const KCalendarSystem *calendarSystem() const; | 44 | const KCalendarSystem *calendarSystem() const; |
45 | 45 | ||
46 | AlarmClient *alarmClient() const; | ||
47 | |||
48 | protected: | 46 | protected: |
49 | KOGlobals(); | 47 | KOGlobals(); |
50 | ~KOGlobals(); | 48 | ~KOGlobals(); |
51 | 49 | ||
52 | private: | 50 | private: |
53 | static KOGlobals *mSelf; | 51 | static KOGlobals *mSelf; |
54 | 52 | ||
55 | const KCalendarSystem *mCalendarSystem; | 53 | const KCalendarSystem *mCalendarSystem; |
56 | AlarmClient *mAlarmClient; | ||
57 | }; | 54 | }; |
58 | 55 | ||
59 | #endif | 56 | #endif |
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp index 51df123..9813a80 100644 --- a/korganizer/koincidenceeditor.cpp +++ b/korganizer/koincidenceeditor.cpp | |||
@@ -1,186 +1,185 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | 37 | ||
38 | #include <libkdepim/categoryselectdialog.h> | 38 | #include <libkdepim/categoryselectdialog.h> |
39 | #include <libkdepim/kinputdialog.h> | 39 | #include <libkdepim/kinputdialog.h> |
40 | 40 | ||
41 | #include <libkcal/calendarlocal.h> | 41 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/icalformat.h> | 42 | #include <libkcal/icalformat.h> |
43 | 43 | ||
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include "koglobals.h" | ||
46 | 45 | ||
47 | #include "koincidenceeditor.h" | 46 | #include "koincidenceeditor.h" |
48 | 47 | ||
49 | KOIncidenceEditor::KOIncidenceEditor( const QString &caption, | 48 | KOIncidenceEditor::KOIncidenceEditor( const QString &caption, |
50 | Calendar *calendar, QWidget *parent ) : | 49 | Calendar *calendar, QWidget *parent ) : |
51 | KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, | 50 | KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, |
52 | parent, caption, true, false ), | 51 | parent, caption, true, false ), |
53 | mSaveTemplateDialog( 0 ) | 52 | mSaveTemplateDialog( 0 ) |
54 | { | 53 | { |
55 | mCalendar = calendar; | 54 | mCalendar = calendar; |
56 | 55 | ||
57 | setButtonText( Default, i18n("Template...") ); | 56 | setButtonText( Default, i18n("Template...") ); |
58 | 57 | ||
59 | QString saveTemplateText; | 58 | QString saveTemplateText; |
60 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 59 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
61 | // showButton( User1, false ); | 60 | // showButton( User1, false ); |
62 | // showButton( Apply, false ); | 61 | // showButton( Apply, false ); |
63 | // } else { | 62 | // } else { |
64 | showButton( Apply, false ); | 63 | showButton( Apply, false ); |
65 | saveTemplateText = i18n("Ok+Agenda"); | 64 | saveTemplateText = i18n("Ok+Agenda"); |
66 | // } | 65 | // } |
67 | setButtonText( User1, saveTemplateText ); | 66 | setButtonText( User1, saveTemplateText ); |
68 | 67 | ||
69 | //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); | 68 | //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); |
70 | // KOGlobals::fitDialogToScreen( mCategoryDialog ); | 69 | // KOGlobals::fitDialogToScreen( mCategoryDialog ); |
71 | 70 | ||
72 | //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); | 71 | //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); |
73 | 72 | ||
74 | //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); | 73 | //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); |
75 | // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); | 74 | // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); |
76 | connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); | 75 | connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); |
77 | } | 76 | } |
78 | 77 | ||
79 | KOIncidenceEditor::~KOIncidenceEditor() | 78 | KOIncidenceEditor::~KOIncidenceEditor() |
80 | { | 79 | { |
81 | //delete mCategoryDialog; | 80 | //delete mCategoryDialog; |
82 | } | 81 | } |
83 | 82 | ||
84 | void KOIncidenceEditor::setupAttendeesTab() | 83 | void KOIncidenceEditor::setupAttendeesTab() |
85 | { | 84 | { |
86 | QFrame *topFrame = addPage(i18n("Attendees")); | 85 | QFrame *topFrame = addPage(i18n("Attendees")); |
87 | 86 | ||
88 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 87 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
89 | 88 | ||
90 | mDetails = new KOEditorDetails(spacingHint(),topFrame); | 89 | mDetails = new KOEditorDetails(spacingHint(),topFrame); |
91 | topLayout->addWidget(mDetails); | 90 | topLayout->addWidget(mDetails); |
92 | } | 91 | } |
93 | 92 | ||
94 | 93 | ||
95 | void KOIncidenceEditor::slotApply() | 94 | void KOIncidenceEditor::slotApply() |
96 | { | 95 | { |
97 | processInput( false ); | 96 | processInput( false ); |
98 | } | 97 | } |
99 | void KOIncidenceEditor::accept() | 98 | void KOIncidenceEditor::accept() |
100 | { | 99 | { |
101 | slotOk(); | 100 | slotOk(); |
102 | } | 101 | } |
103 | void KOIncidenceEditor::slotOk() | 102 | void KOIncidenceEditor::slotOk() |
104 | { | 103 | { |
105 | if ( processInput( false ) ) QDialog::accept(); | 104 | if ( processInput( false ) ) QDialog::accept(); |
106 | } | 105 | } |
107 | 106 | ||
108 | void KOIncidenceEditor::updateCategoryConfig() | 107 | void KOIncidenceEditor::updateCategoryConfig() |
109 | { | 108 | { |
110 | qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); | 109 | qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); |
111 | //mCategoryDialog->updateCategoryConfig(); | 110 | //mCategoryDialog->updateCategoryConfig(); |
112 | } | 111 | } |
113 | 112 | ||
114 | void KOIncidenceEditor::slotCancel() | 113 | void KOIncidenceEditor::slotCancel() |
115 | { | 114 | { |
116 | reject(); | 115 | reject(); |
117 | } | 116 | } |
118 | 117 | ||
119 | void KOIncidenceEditor::slotLoadTemplate() | 118 | void KOIncidenceEditor::slotLoadTemplate() |
120 | { | 119 | { |
121 | kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; | 120 | kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; |
122 | } | 121 | } |
123 | void KOIncidenceEditor::slotShowIncidence() | 122 | void KOIncidenceEditor::slotShowIncidence() |
124 | { | 123 | { |
125 | 124 | ||
126 | if ( processInput(true ) ) { | 125 | if ( processInput(true ) ) { |
127 | accept(); | 126 | accept(); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | 129 | ||
131 | void KOIncidenceEditor::slotSaveTemplate() | 130 | void KOIncidenceEditor::slotSaveTemplate() |
132 | { | 131 | { |
133 | kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; | 132 | kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; |
134 | } | 133 | } |
135 | 134 | ||
136 | void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) | 135 | void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) |
137 | { | 136 | { |
138 | if ( !mSaveTemplateDialog ) { | 137 | if ( !mSaveTemplateDialog ) { |
139 | mSaveTemplateDialog = new SaveTemplateDialog( type, this ); | 138 | mSaveTemplateDialog = new SaveTemplateDialog( type, this ); |
140 | connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), | 139 | connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), |
141 | SLOT( saveTemplate( const QString & ) ) ); | 140 | SLOT( saveTemplate( const QString & ) ) ); |
142 | } | 141 | } |
143 | mSaveTemplateDialog->show(); | 142 | mSaveTemplateDialog->show(); |
144 | mSaveTemplateDialog->raise(); | 143 | mSaveTemplateDialog->raise(); |
145 | } | 144 | } |
146 | 145 | ||
147 | void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, | 146 | void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, |
148 | const QString &templateName ) | 147 | const QString &templateName ) |
149 | { | 148 | { |
150 | CalendarLocal cal; | 149 | CalendarLocal cal; |
151 | cal.addIncidence( incidence ); | 150 | cal.addIncidence( incidence ); |
152 | ICalFormat format; | 151 | ICalFormat format; |
153 | format.save( &cal, templateName ); | 152 | format.save( &cal, templateName ); |
154 | } | 153 | } |
155 | 154 | ||
156 | QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, | 155 | QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, |
157 | const QStringList &templates ) | 156 | const QStringList &templates ) |
158 | { | 157 | { |
159 | // bool ok = false; | 158 | // bool ok = false; |
160 | // QString templateName = KInputDialog::getItem( i18n("Load Template"), | 159 | // QString templateName = KInputDialog::getItem( i18n("Load Template"), |
161 | // i18n("Select a template to load:"), templates, 0, &ok ); | 160 | // i18n("Select a template to load:"), templates, 0, &ok ); |
162 | // if ( !ok || templateName.isEmpty() ) return QString::null; | 161 | // if ( !ok || templateName.isEmpty() ) return QString::null; |
163 | 162 | ||
164 | // QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + | 163 | // QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + |
165 | // templateName ); | 164 | // templateName ); |
166 | // fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); | 165 | // fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); |
167 | 166 | ||
168 | // QString fileName;// =locateLocal( "templates", incidence->type() ); | 167 | // QString fileName;// =locateLocal( "templates", incidence->type() ); |
169 | // fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); | 168 | // fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); |
170 | // if ( fileNamelength() == 0) | 169 | // if ( fileNamelength() == 0) |
171 | // return QString::null; | 170 | // return QString::null; |
172 | // if ( fileName.isEmpty() ) { | 171 | // if ( fileName.isEmpty() ) { |
173 | // KMessageBox::error( this, i18n("Unable to find template '%1'.") | 172 | // KMessageBox::error( this, i18n("Unable to find template '%1'.") |
174 | // .arg( fileName ) ); | 173 | // .arg( fileName ) ); |
175 | // return QString::null; | 174 | // return QString::null; |
176 | // } else { | 175 | // } else { |
177 | // ICalFormat format; | 176 | // ICalFormat format; |
178 | // if ( !format.load( cal, fileName ) ) { | 177 | // if ( !format.load( cal, fileName ) ) { |
179 | // KMessageBox::error( this, i18n("Error loading template file '%1'.") | 178 | // KMessageBox::error( this, i18n("Error loading template file '%1'.") |
180 | // .arg( fileName ) ); | 179 | // .arg( fileName ) ); |
181 | // return QString::null; | 180 | // return QString::null; |
182 | // } | 181 | // } |
183 | // } | 182 | // } |
184 | 183 | ||
185 | return ""; | 184 | return ""; |
186 | } | 185 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 341f473..e1b393d 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -142,884 +142,891 @@ bool ListItemVisitor::visit(Event *e) | |||
142 | 142 | ||
143 | return true; | 143 | return true; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool ListItemVisitor::visit(Todo *t) | 146 | bool ListItemVisitor::visit(Todo *t) |
147 | { | 147 | { |
148 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); | 148 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); |
149 | if (t->hasStartDate()) { | 149 | if (t->hasStartDate()) { |
150 | mItem->setText(1,t->dtStartDateStr()); | 150 | mItem->setText(1,t->dtStartDateStr()); |
151 | if (t->doesFloat()) { | 151 | if (t->doesFloat()) { |
152 | mItem->setText(2,"---"); | 152 | mItem->setText(2,"---"); |
153 | } else { | 153 | } else { |
154 | mItem->setText(2,t->dtStartTimeStr()); | 154 | mItem->setText(2,t->dtStartTimeStr()); |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | mItem->setText(1,"---"); | 157 | mItem->setText(1,"---"); |
158 | mItem->setText(2,"---"); | 158 | mItem->setText(2,"---"); |
159 | } | 159 | } |
160 | mItem->setText(3,"---"); | 160 | mItem->setText(3,"---"); |
161 | mItem->setText(4,"---"); | 161 | mItem->setText(4,"---"); |
162 | if ( t->isAlarmEnabled() ) { | 162 | if ( t->isAlarmEnabled() ) { |
163 | mItem->setText(5,t->alarms().first()->offsetText() ); | 163 | mItem->setText(5,t->alarms().first()->offsetText() ); |
164 | } else { | 164 | } else { |
165 | mItem->setText(5, i18n("No")); | 165 | mItem->setText(5, i18n("No")); |
166 | } | 166 | } |
167 | mItem->setText(6, t->recurrence()->recurrenceText()); | 167 | mItem->setText(6, t->recurrence()->recurrenceText()); |
168 | if (t->hasDueDate()) { | 168 | if (t->hasDueDate()) { |
169 | mItem->setText(7,t->dtDueDateStr()); | 169 | mItem->setText(7,t->dtDueDateStr()); |
170 | if (t->doesFloat()) { | 170 | if (t->doesFloat()) { |
171 | mItem->setText(8,"---"); | 171 | mItem->setText(8,"---"); |
172 | } else { | 172 | } else { |
173 | mItem->setText(8,t->dtDueTimeStr()); | 173 | mItem->setText(8,t->dtDueTimeStr()); |
174 | } | 174 | } |
175 | } else { | 175 | } else { |
176 | mItem->setText(7,"---"); | 176 | mItem->setText(7,"---"); |
177 | mItem->setText(8,"---"); | 177 | mItem->setText(8,"---"); |
178 | } | 178 | } |
179 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 179 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
180 | mItem->setText(10,t->categoriesStr()); | 180 | mItem->setText(10,t->categoriesStr()); |
181 | 181 | ||
182 | QString key; | 182 | QString key; |
183 | QDate d; | 183 | QDate d; |
184 | if (t->hasDueDate()) { | 184 | if (t->hasDueDate()) { |
185 | d = t->dtDue().date(); | 185 | d = t->dtDue().date(); |
186 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 186 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
187 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 187 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
188 | mItem->setSortKey(7,key); | 188 | mItem->setSortKey(7,key); |
189 | } | 189 | } |
190 | if ( t->hasStartDate() ) { | 190 | if ( t->hasStartDate() ) { |
191 | d = t->dtStart().date(); | 191 | d = t->dtStart().date(); |
192 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 192 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
193 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 193 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
194 | mItem->setSortKey(1,key); | 194 | mItem->setSortKey(1,key); |
195 | } | 195 | } |
196 | return true; | 196 | return true; |
197 | } | 197 | } |
198 | 198 | ||
199 | bool ListItemVisitor::visit(Journal * j) | 199 | bool ListItemVisitor::visit(Journal * j) |
200 | { | 200 | { |
201 | QString des = j->description().left(30); | 201 | QString des = j->description().left(30); |
202 | des = des.simplifyWhiteSpace (); | 202 | des = des.simplifyWhiteSpace (); |
203 | des.replace (QRegExp ("\\n"),"" ); | 203 | des.replace (QRegExp ("\\n"),"" ); |
204 | des.replace (QRegExp ("\\r"),"" ); | 204 | des.replace (QRegExp ("\\r"),"" ); |
205 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 205 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
206 | mItem->setText(1,j->dtStartDateStr()); | 206 | mItem->setText(1,j->dtStartDateStr()); |
207 | mItem->setText(2,"---"); | 207 | mItem->setText(2,"---"); |
208 | mItem->setText(3,"---"); | 208 | mItem->setText(3,"---"); |
209 | mItem->setText(4,"---"); | 209 | mItem->setText(4,"---"); |
210 | mItem->setText(5,"---"); | 210 | mItem->setText(5,"---"); |
211 | mItem->setText(6,"---"); | 211 | mItem->setText(6,"---"); |
212 | mItem->setText(7,j->dtStartDateStr()); | 212 | mItem->setText(7,j->dtStartDateStr()); |
213 | mItem->setText(8,"---"); | 213 | mItem->setText(8,"---"); |
214 | mItem->setText(9,"---"); | 214 | mItem->setText(9,"---"); |
215 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 215 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
216 | 216 | ||
217 | QString key; | 217 | QString key; |
218 | QDate d = j->dtStart().date(); | 218 | QDate d = j->dtStart().date(); |
219 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 219 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
220 | mItem->setSortKey(1,key); | 220 | mItem->setSortKey(1,key); |
221 | mItem->setSortKey(7,key); | 221 | mItem->setSortKey(7,key); |
222 | 222 | ||
223 | return true; | 223 | return true; |
224 | } | 224 | } |
225 | 225 | ||
226 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 226 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
227 | const char *name) | 227 | const char *name) |
228 | : KOEventView(calendar, parent, name) | 228 | : KOEventView(calendar, parent, name) |
229 | { | 229 | { |
230 | mActiveItem = 0; | 230 | mActiveItem = 0; |
231 | mListView = new KOListViewListView(this); | 231 | mListView = new KOListViewListView(this); |
232 | mListView->addColumn(i18n("Summary")); | 232 | mListView->addColumn(i18n("Summary")); |
233 | mListView->addColumn(i18n("Start Date")); | 233 | mListView->addColumn(i18n("Start Date")); |
234 | mListView->addColumn(i18n("Start Time")); | 234 | mListView->addColumn(i18n("Start Time")); |
235 | mListView->addColumn(i18n("End Date")); | 235 | mListView->addColumn(i18n("End Date")); |
236 | mListView->addColumn(i18n("End Time")); | 236 | mListView->addColumn(i18n("End Time")); |
237 | mListView->addColumn(i18n("Alarm")); // alarm set? | 237 | mListView->addColumn(i18n("Alarm")); // alarm set? |
238 | mListView->addColumn(i18n("Recurs")); // recurs? | 238 | mListView->addColumn(i18n("Recurs")); // recurs? |
239 | mListView->addColumn(i18n("Due Date")); | 239 | mListView->addColumn(i18n("Due Date")); |
240 | mListView->addColumn(i18n("Due Time")); | 240 | mListView->addColumn(i18n("Due Time")); |
241 | mListView->addColumn(i18n("Cancelled")); | 241 | mListView->addColumn(i18n("Cancelled")); |
242 | mListView->addColumn(i18n("Categories")); | 242 | mListView->addColumn(i18n("Categories")); |
243 | 243 | ||
244 | mListView->setColumnAlignment(0,AlignLeft); | 244 | mListView->setColumnAlignment(0,AlignLeft); |
245 | mListView->setColumnAlignment(1,AlignLeft); | 245 | mListView->setColumnAlignment(1,AlignLeft); |
246 | mListView->setColumnAlignment(2,AlignHCenter); | 246 | mListView->setColumnAlignment(2,AlignHCenter); |
247 | mListView->setColumnAlignment(3,AlignLeft); | 247 | mListView->setColumnAlignment(3,AlignLeft); |
248 | mListView->setColumnAlignment(4,AlignHCenter); | 248 | mListView->setColumnAlignment(4,AlignHCenter); |
249 | mListView->setColumnAlignment(5,AlignLeft); | 249 | mListView->setColumnAlignment(5,AlignLeft); |
250 | mListView->setColumnAlignment(6,AlignLeft); | 250 | mListView->setColumnAlignment(6,AlignLeft); |
251 | mListView->setColumnAlignment(7,AlignLeft); | 251 | mListView->setColumnAlignment(7,AlignLeft); |
252 | mListView->setColumnAlignment(8,AlignLeft); | 252 | mListView->setColumnAlignment(8,AlignLeft); |
253 | mListView->setColumnAlignment(9,AlignLeft); | 253 | mListView->setColumnAlignment(9,AlignLeft); |
254 | mListView->setColumnAlignment(10,AlignLeft); | 254 | mListView->setColumnAlignment(10,AlignLeft); |
255 | mListView->setColumnWidthMode(10, QListView::Manual); | 255 | mListView->setColumnWidthMode(10, QListView::Manual); |
256 | new KOListViewWhatsThis(mListView->viewport(),this); | 256 | new KOListViewWhatsThis(mListView->viewport(),this); |
257 | 257 | ||
258 | int iii = 0; | 258 | int iii = 0; |
259 | for ( iii = 0; iii< 10 ; ++iii ) | 259 | for ( iii = 0; iii< 10 ; ++iii ) |
260 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 260 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
261 | 261 | ||
262 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 262 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
263 | layoutTop->addWidget(mListView); | 263 | layoutTop->addWidget(mListView); |
264 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 264 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
265 | mPopupMenu = eventPopup(); | 265 | mPopupMenu = eventPopup(); |
266 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 266 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
267 | i18n("Select all"),this, | 267 | i18n("Select all"),this, |
268 | SLOT(allSelection()),true); | 268 | SLOT(allSelection()),true); |
269 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 269 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
270 | i18n("Deselect all"),this, | 270 | i18n("Deselect all"),this, |
271 | SLOT(clearSelection()),true); | 271 | SLOT(clearSelection()),true); |
272 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 272 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
273 | i18n("Delete all selected"),this, | 273 | i18n("Delete all selected"),this, |
274 | SLOT(deleteAll()),true); | 274 | SLOT(deleteAll()),true); |
275 | mPopupMenu->insertSeparator(); | 275 | mPopupMenu->insertSeparator(); |
276 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 276 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
277 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 277 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
278 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 278 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
279 | SLOT(saveToFile())); | 279 | SLOT(saveToFile())); |
280 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 280 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
281 | SLOT(saveToFileVCS())); | 281 | SLOT(saveToFileVCS())); |
282 | exportPO->insertItem( i18n("Journal/Details..."),this, | 282 | exportPO->insertItem( i18n("Journal/Details..."),this, |
283 | SLOT(saveDescriptionToFile())); | 283 | SLOT(saveDescriptionToFile())); |
284 | // mPopupMenu->insertSeparator(); | 284 | // mPopupMenu->insertSeparator(); |
285 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 285 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
286 | i18n("Add Categ. to selected..."),this, | 286 | i18n("Add Categ. to selected..."),this, |
287 | SLOT(addCat()),true); | 287 | SLOT(addCat()),true); |
288 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 288 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
289 | i18n("Set Categ. for selected..."),this, | 289 | i18n("Set Categ. for selected..."),this, |
290 | SLOT(setCat()),true); | 290 | SLOT(setCat()),true); |
291 | //mPopupMenu->insertSeparator(); | 291 | //mPopupMenu->insertSeparator(); |
292 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 292 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
293 | i18n("Set alarm for selected..."),this, | 293 | i18n("Set alarm for selected..."),this, |
294 | SLOT(setAlarm()),true); | 294 | SLOT(setAlarm()),true); |
295 | 295 | ||
296 | 296 | ||
297 | #ifndef DESKTOP_VERSION | 297 | #ifndef DESKTOP_VERSION |
298 | mPopupMenu->insertSeparator(); | 298 | mPopupMenu->insertSeparator(); |
299 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 299 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
300 | i18n("Beam selected via IR"),this, | 300 | i18n("Beam selected via IR"),this, |
301 | SLOT(beamSelected()),true); | 301 | SLOT(beamSelected()),true); |
302 | #endif | 302 | #endif |
303 | /* | 303 | /* |
304 | mPopupMenu = new QPopupMenu; | 304 | mPopupMenu = new QPopupMenu; |
305 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 305 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
306 | SLOT (editEvent())); | 306 | SLOT (editEvent())); |
307 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 307 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
308 | SLOT (deleteEvent())); | 308 | SLOT (deleteEvent())); |
309 | mPopupMenu->insertSeparator(); | 309 | mPopupMenu->insertSeparator(); |
310 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 310 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
311 | SLOT(showDates())); | 311 | SLOT(showDates())); |
312 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 312 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
313 | SLOT(hideDates())); | 313 | SLOT(hideDates())); |
314 | */ | 314 | */ |
315 | QObject::connect(mListView,SIGNAL( newEvent()), | 315 | QObject::connect(mListView,SIGNAL( newEvent()), |
316 | this,SIGNAL(signalNewEvent())); | 316 | this,SIGNAL(signalNewEvent())); |
317 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 317 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
318 | this,SLOT(defaultItemAction(QListViewItem *))); | 318 | this,SLOT(defaultItemAction(QListViewItem *))); |
319 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 319 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
320 | const QPoint &, int )), | 320 | const QPoint &, int )), |
321 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 321 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
322 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 322 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
323 | SLOT(processSelectionChange(QListViewItem *))); | 323 | SLOT(processSelectionChange(QListViewItem *))); |
324 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 324 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
325 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 325 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
326 | 326 | ||
327 | readSettings(KOGlobals::config(),"KOListView Layout"); | 327 | readSettings(KOGlobals::config(),"KOListView Layout"); |
328 | } | 328 | } |
329 | 329 | ||
330 | KOListView::~KOListView() | 330 | KOListView::~KOListView() |
331 | { | 331 | { |
332 | delete mPopupMenu; | 332 | delete mPopupMenu; |
333 | } | 333 | } |
334 | |||
334 | QString KOListView::getWhatsThisText(QPoint p) | 335 | QString KOListView::getWhatsThisText(QPoint p) |
335 | { | 336 | { |
336 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 337 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
337 | if ( item ) | 338 | if ( item ) |
338 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 339 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
339 | KOPrefs::instance()->mWTshowDetails, | 340 | KOPrefs::instance()->mWTshowDetails, |
340 | KOPrefs::instance()->mWTshowCreated, | 341 | KOPrefs::instance()->mWTshowCreated, |
341 | KOPrefs::instance()->mWTshowChanged); | 342 | KOPrefs::instance()->mWTshowChanged); |
342 | return i18n("That is the list view" ); | 343 | return i18n("That is the list view" ); |
343 | 344 | ||
344 | } | 345 | } |
345 | 346 | ||
346 | void KOListView::updateList() | 347 | void KOListView::updateList() |
347 | { | 348 | { |
348 | // qDebug(" KOListView::updateList() "); | 349 | // qDebug(" KOListView::updateList() "); |
349 | 350 | ||
350 | } | 351 | } |
351 | 352 | ||
352 | void KOListView::addCat( ) | 353 | void KOListView::addCat( ) |
353 | { | 354 | { |
354 | setCategories( false ); | 355 | setCategories( false ); |
355 | } | 356 | } |
356 | void KOListView::setCat() | 357 | void KOListView::setCat() |
357 | { | 358 | { |
358 | setCategories( true ); | 359 | setCategories( true ); |
359 | } | 360 | } |
360 | void KOListView::setAlarm() | 361 | void KOListView::setAlarm() |
361 | { | 362 | { |
362 | KOAlarmPrefs kap( this); | 363 | KOAlarmPrefs kap( this); |
363 | if ( !kap.exec() ) | 364 | if ( !kap.exec() ) |
364 | return; | 365 | return; |
365 | 366 | ||
366 | 367 | ||
367 | QStringList itemList; | 368 | QStringList itemList; |
368 | QPtrList<KOListViewItem> sel ; | 369 | QPtrList<KOListViewItem> sel ; |
369 | QListViewItem *qitem = mListView->firstChild (); | 370 | QListViewItem *qitem = mListView->firstChild (); |
370 | while ( qitem ) { | 371 | while ( qitem ) { |
371 | if ( qitem->isSelected() ) { | 372 | if ( qitem->isSelected() ) { |
372 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 373 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
373 | if ( inc->type() != "Journal" ) { | 374 | if ( inc->type() != "Journal" ) { |
374 | if ( inc->type() == "Todo" ) { | 375 | if ( inc->type() == "Todo" ) { |
375 | if ( ((Todo*)inc)->hasDueDate() ) | 376 | if ( ((Todo*)inc)->hasDueDate() ) |
376 | sel.append(((KOListViewItem *)qitem)); | 377 | sel.append(((KOListViewItem *)qitem)); |
377 | } else | 378 | } else |
378 | sel.append(((KOListViewItem *)qitem)); | 379 | sel.append(((KOListViewItem *)qitem)); |
379 | } | 380 | } |
380 | } | 381 | } |
381 | qitem = qitem->nextSibling(); | 382 | qitem = qitem->nextSibling(); |
382 | } | 383 | } |
383 | int count = 0; | 384 | int count = 0; |
384 | KOListViewItem * item, *temp; | 385 | KOListViewItem * item, *temp; |
385 | item = sel.first(); | 386 | item = sel.first(); |
386 | Incidence* inc; | 387 | Incidence* inc; |
387 | while ( item ) { | 388 | while ( item ) { |
388 | inc = item->data(); | 389 | inc = item->data(); |
389 | ++count; | 390 | ++count; |
390 | if (kap.mAlarmButton->isChecked()) { | 391 | if (kap.mAlarmButton->isChecked()) { |
391 | if (inc->alarms().count() == 0) | 392 | if (inc->alarms().count() == 0) |
392 | inc->newAlarm(); | 393 | inc->newAlarm(); |
393 | QPtrList<Alarm> alarms = inc->alarms(); | 394 | QPtrList<Alarm> alarms = inc->alarms(); |
394 | Alarm *alarm; | 395 | Alarm *alarm; |
395 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 396 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
396 | alarm->setEnabled(true); | 397 | alarm->setEnabled(true); |
397 | int j = kap.mAlarmTimeEdit->value()* -60; | 398 | int j = kap.mAlarmTimeEdit->value()* -60; |
398 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 399 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
399 | j = j * 60; | 400 | j = j * 60; |
400 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 401 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
401 | j = j * (60 * 24); | 402 | j = j * (60 * 24); |
402 | alarm->setStartOffset( j ); | 403 | alarm->setStartOffset( j ); |
403 | 404 | ||
404 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 405 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
405 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 406 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
406 | } | 407 | } |
407 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 408 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
408 | alarm->setAudioAlarm(kap.mAlarmSound); | 409 | alarm->setAudioAlarm(kap.mAlarmSound); |
409 | else | 410 | else |
410 | alarm->setType(Alarm::Invalid); | 411 | alarm->setType(Alarm::Invalid); |
411 | //alarm->setAudioAlarm("default"); | 412 | //alarm->setAudioAlarm("default"); |
412 | // TODO: Deal with multiple alarms | 413 | // TODO: Deal with multiple alarms |
413 | break; // For now, stop after the first alarm | 414 | break; // For now, stop after the first alarm |
414 | } | 415 | } |
415 | } else { | 416 | } else { |
416 | Alarm* alarm = inc->alarms().first(); | 417 | Alarm* alarm = inc->alarms().first(); |
417 | if ( alarm ) { | 418 | if ( alarm ) { |
418 | alarm->setEnabled(false); | 419 | alarm->setEnabled(false); |
419 | alarm->setType(Alarm::Invalid); | 420 | alarm->setType(Alarm::Invalid); |
420 | } | 421 | } |
421 | } | 422 | } |
422 | temp = item; | 423 | temp = item; |
423 | item = sel.next(); | 424 | item = sel.next(); |
424 | mUidDict.remove( inc->uid() ); | 425 | mUidDict.remove( inc->uid() ); |
425 | delete temp;; | 426 | delete temp;; |
426 | addIncidence( inc ); | 427 | addIncidence( inc ); |
427 | } | 428 | } |
428 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | 429 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); |
429 | qDebug("KO: Set alarm for %d items", count); | 430 | qDebug("KO: Set alarm for %d items", count); |
430 | calendar()->reInitAlarmSettings(); | 431 | calendar()->reInitAlarmSettings(); |
432 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | ||
431 | } | 433 | } |
432 | void KOListView::setCategories( bool removeOld ) | 434 | void KOListView::setCategories( bool removeOld ) |
433 | { | 435 | { |
434 | 436 | ||
435 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 437 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
436 | if (! csd->exec()) { | 438 | if (! csd->exec()) { |
437 | delete csd; | 439 | delete csd; |
438 | return; | 440 | return; |
439 | } | 441 | } |
440 | QStringList catList = csd->selectedCategories(); | 442 | QStringList catList = csd->selectedCategories(); |
441 | delete csd; | 443 | delete csd; |
442 | // if ( catList.count() == 0 ) | 444 | // if ( catList.count() == 0 ) |
443 | // return; | 445 | // return; |
444 | catList.sort(); | 446 | catList.sort(); |
445 | QString categoriesStr = catList.join(","); | 447 | QString categoriesStr = catList.join(","); |
446 | int i; | 448 | int i; |
447 | QStringList itemList; | 449 | QStringList itemList; |
448 | QPtrList<KOListViewItem> sel ; | 450 | QPtrList<KOListViewItem> sel ; |
449 | QListViewItem *qitem = mListView->firstChild (); | 451 | QListViewItem *qitem = mListView->firstChild (); |
450 | while ( qitem ) { | 452 | while ( qitem ) { |
451 | if ( qitem->isSelected() ) { | 453 | if ( qitem->isSelected() ) { |
452 | sel.append(((KOListViewItem *)qitem)); | 454 | sel.append(((KOListViewItem *)qitem)); |
453 | } | 455 | } |
454 | qitem = qitem->nextSibling(); | 456 | qitem = qitem->nextSibling(); |
455 | } | 457 | } |
456 | KOListViewItem * item, *temp; | 458 | KOListViewItem * item, *temp; |
457 | item = sel.first(); | 459 | item = sel.first(); |
458 | Incidence* inc; | 460 | Incidence* inc; |
459 | while ( item ) { | 461 | while ( item ) { |
460 | inc = item->data(); | 462 | inc = item->data(); |
461 | if ( removeOld ) { | 463 | if ( removeOld ) { |
462 | inc->setCategories( categoriesStr ); | 464 | inc->setCategories( categoriesStr ); |
463 | } else { | 465 | } else { |
464 | itemList = QStringList::split (",", inc->categoriesStr() ); | 466 | itemList = QStringList::split (",", inc->categoriesStr() ); |
465 | for( i = 0; i< catList.count(); ++i ) { | 467 | for( i = 0; i< catList.count(); ++i ) { |
466 | if ( !itemList.contains (catList[i])) | 468 | if ( !itemList.contains (catList[i])) |
467 | itemList.append( catList[i] ); | 469 | itemList.append( catList[i] ); |
468 | } | 470 | } |
469 | itemList.sort(); | 471 | itemList.sort(); |
470 | inc->setCategories( itemList.join(",") ); | 472 | inc->setCategories( itemList.join(",") ); |
471 | } | 473 | } |
472 | temp = item; | 474 | temp = item; |
473 | item = sel.next(); | 475 | item = sel.next(); |
474 | mUidDict.remove( inc->uid() ); | 476 | mUidDict.remove( inc->uid() ); |
475 | delete temp;; | 477 | delete temp;; |
476 | addIncidence( inc ); | 478 | addIncidence( inc ); |
477 | } | 479 | } |
480 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | ||
478 | } | 481 | } |
479 | 482 | ||
480 | void KOListView::beamSelected() | 483 | void KOListView::beamSelected() |
481 | { | 484 | { |
482 | int icount = 0; | 485 | int icount = 0; |
483 | QPtrList<Incidence> delSel ; | 486 | QPtrList<Incidence> delSel ; |
484 | QListViewItem *item = mListView->firstChild (); | 487 | QListViewItem *item = mListView->firstChild (); |
485 | while ( item ) { | 488 | while ( item ) { |
486 | if ( item->isSelected() ) { | 489 | if ( item->isSelected() ) { |
487 | delSel.append(((KOListViewItem *)item)->data()); | 490 | delSel.append(((KOListViewItem *)item)->data()); |
488 | ++icount; | 491 | ++icount; |
489 | } | 492 | } |
490 | 493 | ||
491 | item = item->nextSibling(); | 494 | item = item->nextSibling(); |
492 | } | 495 | } |
493 | if ( icount ) { | 496 | if ( icount ) { |
494 | emit beamIncidenceList( delSel ); | 497 | emit beamIncidenceList( delSel ); |
495 | return; | 498 | return; |
496 | QString fn ; | 499 | QString fn ; |
497 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 500 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
498 | QString mes; | 501 | QString mes; |
499 | bool createbup = true; | 502 | bool createbup = true; |
500 | if ( createbup ) { | 503 | if ( createbup ) { |
501 | QString description = "\n"; | 504 | QString description = "\n"; |
502 | CalendarLocal* cal = new CalendarLocal(); | 505 | CalendarLocal* cal = new CalendarLocal(); |
503 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 506 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
504 | Incidence *incidence = delSel.first(); | 507 | Incidence *incidence = delSel.first(); |
505 | while ( incidence ) { | 508 | while ( incidence ) { |
506 | Incidence *in = incidence->clone(); | 509 | Incidence *in = incidence->clone(); |
507 | description += in->summary() + "\n"; | 510 | description += in->summary() + "\n"; |
508 | cal->addIncidence( in ); | 511 | cal->addIncidence( in ); |
509 | incidence = delSel.next(); | 512 | incidence = delSel.next(); |
510 | } | 513 | } |
511 | FileStorage storage( cal, fn, new VCalFormat ); | 514 | FileStorage storage( cal, fn, new VCalFormat ); |
512 | storage.save(); | 515 | storage.save(); |
513 | delete cal; | 516 | delete cal; |
514 | mes = i18n("KO/Pi: Ready for beaming"); | 517 | mes = i18n("KO/Pi: Ready for beaming"); |
515 | topLevelWidget()->setCaption(mes); | 518 | topLevelWidget()->setCaption(mes); |
516 | 519 | ||
517 | #ifndef DESKTOP_VERSION | 520 | #ifndef DESKTOP_VERSION |
518 | Ir *ir = new Ir( this ); | 521 | Ir *ir = new Ir( this ); |
519 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 522 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
520 | ir->send( fn, description, "text/x-vCalendar" ); | 523 | ir->send( fn, description, "text/x-vCalendar" ); |
521 | #endif | 524 | #endif |
522 | } | 525 | } |
523 | } | 526 | } |
524 | } | 527 | } |
525 | void KOListView::beamDone( Ir *ir ) | 528 | void KOListView::beamDone( Ir *ir ) |
526 | { | 529 | { |
527 | #ifndef DESKTOP_VERSION | 530 | #ifndef DESKTOP_VERSION |
528 | delete ir; | 531 | delete ir; |
529 | #endif | 532 | #endif |
530 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 533 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
531 | } | 534 | } |
532 | 535 | ||
533 | void KOListView::saveDescriptionToFile() | 536 | void KOListView::saveDescriptionToFile() |
534 | { | 537 | { |
535 | 538 | ||
536 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 539 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
537 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 540 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
538 | i18n("Continue"), i18n("Cancel"), 0, | 541 | i18n("Continue"), i18n("Cancel"), 0, |
539 | 0, 1 ); | 542 | 0, 1 ); |
540 | if ( result != 0 ) { | 543 | if ( result != 0 ) { |
541 | return; | 544 | return; |
542 | } | 545 | } |
543 | int icount = 0; | 546 | int icount = 0; |
544 | QPtrList<Incidence> delSel ; | 547 | QPtrList<Incidence> delSel ; |
545 | QListViewItem *item = mListView->firstChild (); | 548 | QListViewItem *item = mListView->firstChild (); |
546 | while ( item ) { | 549 | while ( item ) { |
547 | if ( item->isSelected() ) { | 550 | if ( item->isSelected() ) { |
548 | delSel.append(((KOListViewItem *)item)->data()); | 551 | delSel.append(((KOListViewItem *)item)->data()); |
549 | ++icount; | 552 | ++icount; |
550 | } | 553 | } |
551 | 554 | ||
552 | item = item->nextSibling(); | 555 | item = item->nextSibling(); |
553 | } | 556 | } |
554 | if ( icount ) { | 557 | if ( icount ) { |
555 | QString fn = KOPrefs::instance()->mLastSaveFile; | 558 | QString fn = KOPrefs::instance()->mLastSaveFile; |
556 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 559 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
557 | 560 | ||
558 | if ( fn == "" ) | 561 | if ( fn == "" ) |
559 | return; | 562 | return; |
560 | QFileInfo info; | 563 | QFileInfo info; |
561 | info.setFile( fn ); | 564 | info.setFile( fn ); |
562 | QString mes; | 565 | QString mes; |
563 | bool createbup = true; | 566 | bool createbup = true; |
564 | if ( info. exists() ) { | 567 | if ( info. exists() ) { |
565 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 568 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
566 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 569 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
567 | i18n("Overwrite!"), i18n("Cancel"), 0, | 570 | i18n("Overwrite!"), i18n("Cancel"), 0, |
568 | 0, 1 ); | 571 | 0, 1 ); |
569 | if ( result != 0 ) { | 572 | if ( result != 0 ) { |
570 | createbup = false; | 573 | createbup = false; |
571 | } | 574 | } |
572 | } | 575 | } |
573 | if ( createbup ) { | 576 | if ( createbup ) { |
574 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 577 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
575 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 578 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
576 | Incidence *incidence = delSel.first(); | 579 | Incidence *incidence = delSel.first(); |
577 | icount = 0; | 580 | icount = 0; |
578 | while ( incidence ) { | 581 | while ( incidence ) { |
579 | if ( incidence->type() == "Journal" ) { | 582 | if ( incidence->type() == "Journal" ) { |
580 | text += "\n************************************\n"; | 583 | text += "\n************************************\n"; |
581 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 584 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
582 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 585 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
583 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 586 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
584 | ++icount; | 587 | ++icount; |
585 | 588 | ||
586 | } else { | 589 | } else { |
587 | if ( !incidence->description().isEmpty() ) { | 590 | if ( !incidence->description().isEmpty() ) { |
588 | text += "\n************************************\n"; | 591 | text += "\n************************************\n"; |
589 | if ( incidence->type() == "Todo" ) | 592 | if ( incidence->type() == "Todo" ) |
590 | text += i18n("To-Do: "); | 593 | text += i18n("To-Do: "); |
591 | text += incidence->summary(); | 594 | text += incidence->summary(); |
592 | if ( incidence->hasStartDate() ) | 595 | if ( incidence->hasStartDate() ) |
593 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 596 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
594 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 597 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
595 | if ( !incidence->location().isEmpty() ) | 598 | if ( !incidence->location().isEmpty() ) |
596 | text += "\n" +i18n("Location: ") + incidence->location(); | 599 | text += "\n" +i18n("Location: ") + incidence->location(); |
597 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 600 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
598 | ++icount; | 601 | ++icount; |
599 | 602 | ||
600 | } | 603 | } |
601 | } | 604 | } |
602 | incidence = delSel.next(); | 605 | incidence = delSel.next(); |
603 | } | 606 | } |
604 | QFile file( fn ); | 607 | QFile file( fn ); |
605 | if (!file.open( IO_WriteOnly ) ) { | 608 | if (!file.open( IO_WriteOnly ) ) { |
606 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 609 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
607 | return; | 610 | return; |
608 | } | 611 | } |
609 | QTextStream ts( &file ); | 612 | QTextStream ts( &file ); |
610 | ts << text; | 613 | ts << text; |
611 | file.close(); | 614 | file.close(); |
612 | //qDebug("%s ", text.latin1()); | 615 | //qDebug("%s ", text.latin1()); |
613 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 616 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
614 | KOPrefs::instance()->mLastSaveFile = fn; | 617 | KOPrefs::instance()->mLastSaveFile = fn; |
615 | topLevelWidget()->setCaption(mes); | 618 | topLevelWidget()->setCaption(mes); |
616 | } | 619 | } |
617 | } | 620 | } |
618 | } | 621 | } |
619 | void KOListView::saveToFileVCS() | 622 | void KOListView::saveToFileVCS() |
620 | { | 623 | { |
621 | writeToFile( false ); | 624 | writeToFile( false ); |
622 | } | 625 | } |
623 | void KOListView::saveToFile() | 626 | void KOListView::saveToFile() |
624 | { | 627 | { |
625 | writeToFile( true ); | 628 | writeToFile( true ); |
626 | } | 629 | } |
627 | void KOListView::writeToFile( bool iCal ) | 630 | void KOListView::writeToFile( bool iCal ) |
628 | { | 631 | { |
629 | 632 | ||
630 | int icount = 0; | 633 | int icount = 0; |
631 | QPtrList<Incidence> delSel ; | 634 | QPtrList<Incidence> delSel ; |
632 | QListViewItem *item = mListView->firstChild (); | 635 | QListViewItem *item = mListView->firstChild (); |
633 | bool journal = iCal; // warn only for vCal | 636 | bool journal = iCal; // warn only for vCal |
634 | while ( item ) { | 637 | while ( item ) { |
635 | if ( item->isSelected() ) { | 638 | if ( item->isSelected() ) { |
636 | if ( !journal ) | 639 | if ( !journal ) |
637 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") | 640 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") |
638 | journal = true; | 641 | journal = true; |
639 | delSel.append(((KOListViewItem *)item)->data()); | 642 | delSel.append(((KOListViewItem *)item)->data()); |
640 | ++icount; | 643 | ++icount; |
641 | } | 644 | } |
642 | 645 | ||
643 | item = item->nextSibling(); | 646 | item = item->nextSibling(); |
644 | } | 647 | } |
645 | if ( !iCal && journal ) { | 648 | if ( !iCal && journal ) { |
646 | int result = KMessageBox::warningContinueCancel(this, | 649 | int result = KMessageBox::warningContinueCancel(this, |
647 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 650 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
648 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 651 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
649 | true); | 652 | true); |
650 | if (result != KMessageBox::Continue) return; | 653 | if (result != KMessageBox::Continue) return; |
651 | } | 654 | } |
652 | if ( icount ) { | 655 | if ( icount ) { |
653 | QString fn = KOPrefs::instance()->mLastSaveFile; | 656 | QString fn = KOPrefs::instance()->mLastSaveFile; |
654 | QString extension; | 657 | QString extension; |
655 | if ( iCal ) { | 658 | if ( iCal ) { |
656 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 659 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
657 | fn = fn.left( fn.length() -3) + "ics"; | 660 | fn = fn.left( fn.length() -3) + "ics"; |
658 | } | 661 | } |
659 | } else { | 662 | } else { |
660 | if ( fn.right( 4 ).lower() == ".ics" ) { | 663 | if ( fn.right( 4 ).lower() == ".ics" ) { |
661 | fn = fn.left( fn.length() -3) + "vcs"; | 664 | fn = fn.left( fn.length() -3) + "vcs"; |
662 | } | 665 | } |
663 | } | 666 | } |
664 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 667 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
665 | 668 | ||
666 | if ( fn == "" ) | 669 | if ( fn == "" ) |
667 | return; | 670 | return; |
668 | QFileInfo info; | 671 | QFileInfo info; |
669 | info.setFile( fn ); | 672 | info.setFile( fn ); |
670 | QString mes; | 673 | QString mes; |
671 | bool createbup = true; | 674 | bool createbup = true; |
672 | if ( info. exists() ) { | 675 | if ( info. exists() ) { |
673 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 676 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
674 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 677 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
675 | i18n("Overwrite!"), i18n("Cancel"), 0, | 678 | i18n("Overwrite!"), i18n("Cancel"), 0, |
676 | 0, 1 ); | 679 | 0, 1 ); |
677 | if ( result != 0 ) { | 680 | if ( result != 0 ) { |
678 | createbup = false; | 681 | createbup = false; |
679 | } | 682 | } |
680 | } | 683 | } |
681 | if ( createbup ) { | 684 | if ( createbup ) { |
682 | CalendarLocal cal; | 685 | CalendarLocal cal; |
683 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 686 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
684 | Incidence *incidence = delSel.first(); | 687 | Incidence *incidence = delSel.first(); |
685 | while ( incidence ) { | 688 | while ( incidence ) { |
686 | cal.addIncidence( incidence->clone() ); | 689 | cal.addIncidence( incidence->clone() ); |
687 | incidence = delSel.next(); | 690 | incidence = delSel.next(); |
688 | } | 691 | } |
689 | if ( iCal ) { | 692 | if ( iCal ) { |
690 | ICalFormat format; | 693 | ICalFormat format; |
691 | format.save( &cal, fn ); | 694 | format.save( &cal, fn ); |
692 | } else { | 695 | } else { |
693 | 696 | ||
694 | VCalFormat format; | 697 | VCalFormat format; |
695 | format.save( &cal, fn ); | 698 | format.save( &cal, fn ); |
696 | } | 699 | } |
697 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 700 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
698 | KOPrefs::instance()->mLastSaveFile = fn; | 701 | KOPrefs::instance()->mLastSaveFile = fn; |
699 | topLevelWidget()->setCaption(mes); | 702 | topLevelWidget()->setCaption(mes); |
700 | } | 703 | } |
701 | } | 704 | } |
705 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | ||
702 | } | 706 | } |
703 | void KOListView::deleteAll() | 707 | void KOListView::deleteAll() |
704 | { | 708 | { |
705 | int icount = 0; | 709 | int icount = 0; |
706 | QPtrList<Incidence> delSel ; | 710 | QPtrList<Incidence> delSel ; |
707 | QListViewItem *item = mListView->firstChild (); | 711 | QListViewItem *item = mListView->firstChild (); |
708 | while ( item ) { | 712 | while ( item ) { |
709 | if ( item->isSelected() ) { | 713 | if ( item->isSelected() ) { |
710 | delSel.append(((KOListViewItem *)item)->data()); | 714 | delSel.append(((KOListViewItem *)item)->data()); |
711 | ++icount; | 715 | ++icount; |
712 | } | 716 | } |
713 | 717 | ||
714 | item = item->nextSibling(); | 718 | item = item->nextSibling(); |
715 | } | 719 | } |
716 | if ( icount ) { | 720 | if ( icount ) { |
717 | Incidence *incidence = delSel.first(); | 721 | Incidence *incidence = delSel.first(); |
718 | Incidence *toDelete; | 722 | Incidence *toDelete; |
719 | KOPrefs *p = KOPrefs::instance(); | 723 | KOPrefs *p = KOPrefs::instance(); |
720 | bool confirm = p->mConfirm; | 724 | bool confirm = p->mConfirm; |
721 | QString mess; | 725 | QString mess; |
722 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 726 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
723 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 727 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
724 | p->mConfirm = false; | 728 | p->mConfirm = false; |
725 | int delCounter = 0; | 729 | int delCounter = 0; |
726 | QDialog dia ( this, "p-dialog", true ); | 730 | QDialog dia ( this, "p-dialog", true ); |
727 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 731 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
728 | QVBoxLayout lay( &dia ); | 732 | QVBoxLayout lay( &dia ); |
729 | lay.setMargin(7); | 733 | lay.setMargin(7); |
730 | lay.setSpacing(7); | 734 | lay.setSpacing(7); |
731 | lay.addWidget( &lab); | 735 | lay.addWidget( &lab); |
732 | QProgressBar bar( icount, &dia ); | 736 | QProgressBar bar( icount, &dia ); |
733 | lay.addWidget( &bar); | 737 | lay.addWidget( &bar); |
734 | int w = 220; | 738 | int w = 220; |
735 | int h = 50; | 739 | int h = 50; |
736 | int dw = QApplication::desktop()->width(); | 740 | int dw = QApplication::desktop()->width(); |
737 | int dh = QApplication::desktop()->height(); | 741 | int dh = QApplication::desktop()->height(); |
738 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 742 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
739 | //dia.resize( 240,50 ); | 743 | //dia.resize( 240,50 ); |
740 | dia.show(); | 744 | dia.show(); |
741 | 745 | ||
742 | while ( incidence ) { | 746 | while ( incidence ) { |
743 | bar.setProgress( delCounter ); | 747 | bar.setProgress( delCounter ); |
744 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 748 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
745 | dia.setCaption( mess ); | 749 | dia.setCaption( mess ); |
746 | qApp->processEvents(); | 750 | qApp->processEvents(); |
747 | toDelete = (incidence); | 751 | toDelete = (incidence); |
748 | incidence = delSel.next(); | 752 | incidence = delSel.next(); |
749 | emit deleteIncidenceSignal(toDelete ); | 753 | emit deleteIncidenceSignal(toDelete ); |
750 | if ( dia.result() != 0 ) | 754 | if ( dia.result() != 0 ) |
751 | break; | 755 | break; |
752 | 756 | ||
753 | } | 757 | } |
754 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 758 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
755 | topLevelWidget ()->setCaption( mess ); | 759 | topLevelWidget ()->setCaption( mess ); |
756 | p->mConfirm = confirm; | 760 | p->mConfirm = confirm; |
757 | } | 761 | } |
758 | } | 762 | } |
759 | 763 | ||
760 | 764 | ||
761 | } | 765 | } |
762 | int KOListView::maxDatesHint() | 766 | int KOListView::maxDatesHint() |
763 | { | 767 | { |
764 | return 0; | 768 | return 0; |
765 | } | 769 | } |
766 | 770 | ||
767 | int KOListView::currentDateCount() | 771 | int KOListView::currentDateCount() |
768 | { | 772 | { |
769 | return 0; | 773 | return 0; |
770 | } | 774 | } |
771 | 775 | ||
772 | QPtrList<Incidence> KOListView::selectedIncidences() | 776 | QPtrList<Incidence> KOListView::selectedIncidences() |
773 | { | 777 | { |
774 | QPtrList<Incidence> eventList; | 778 | QPtrList<Incidence> eventList; |
775 | QListViewItem *item = mListView->firstChild (); | 779 | QListViewItem *item = mListView->firstChild (); |
776 | while ( item ) { | 780 | while ( item ) { |
777 | if ( item->isSelected() ) { | 781 | if ( item->isSelected() ) { |
778 | eventList.append(((KOListViewItem *)item)->data()); | 782 | eventList.append(((KOListViewItem *)item)->data()); |
779 | } | 783 | } |
780 | 784 | ||
781 | item = item->nextSibling(); | 785 | item = item->nextSibling(); |
782 | } | 786 | } |
783 | 787 | ||
784 | // // QListViewItem *item = mListView->selectedItem(); | 788 | // // QListViewItem *item = mListView->selectedItem(); |
785 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 789 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
786 | 790 | ||
787 | return eventList; | 791 | return eventList; |
788 | } | 792 | } |
789 | 793 | ||
790 | DateList KOListView::selectedDates() | 794 | DateList KOListView::selectedDates() |
791 | { | 795 | { |
792 | DateList eventList; | 796 | DateList eventList; |
793 | return eventList; | 797 | return eventList; |
794 | } | 798 | } |
795 | 799 | ||
796 | void KOListView::showDates(bool show) | 800 | void KOListView::showDates(bool show) |
797 | { | 801 | { |
798 | // Shouldn't we set it to a value greater 0? When showDates is called with | 802 | // Shouldn't we set it to a value greater 0? When showDates is called with |
799 | // show == true at first, then the columnwidths are set to zero. | 803 | // show == true at first, then the columnwidths are set to zero. |
800 | static int oldColWidth1 = 0; | 804 | static int oldColWidth1 = 0; |
801 | static int oldColWidth3 = 0; | 805 | static int oldColWidth3 = 0; |
802 | 806 | ||
803 | if (!show) { | 807 | if (!show) { |
804 | oldColWidth1 = mListView->columnWidth(1); | 808 | oldColWidth1 = mListView->columnWidth(1); |
805 | oldColWidth3 = mListView->columnWidth(3); | 809 | oldColWidth3 = mListView->columnWidth(3); |
806 | mListView->setColumnWidth(1, 0); | 810 | mListView->setColumnWidth(1, 0); |
807 | mListView->setColumnWidth(3, 0); | 811 | mListView->setColumnWidth(3, 0); |
808 | } else { | 812 | } else { |
809 | mListView->setColumnWidth(1, oldColWidth1); | 813 | mListView->setColumnWidth(1, oldColWidth1); |
810 | mListView->setColumnWidth(3, oldColWidth3); | 814 | mListView->setColumnWidth(3, oldColWidth3); |
811 | } | 815 | } |
812 | mListView->repaint(); | 816 | mListView->repaint(); |
813 | } | 817 | } |
814 | 818 | ||
815 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 819 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
816 | const QDate &td) | 820 | const QDate &td) |
817 | { | 821 | { |
818 | #ifndef KORG_NOPRINTER | 822 | #ifndef KORG_NOPRINTER |
819 | calPrinter->preview(CalPrinter::Day, fd, td); | 823 | calPrinter->preview(CalPrinter::Day, fd, td); |
820 | #endif | 824 | #endif |
821 | } | 825 | } |
822 | 826 | ||
823 | void KOListView::showDates() | 827 | void KOListView::showDates() |
824 | { | 828 | { |
825 | showDates(true); | 829 | showDates(true); |
826 | } | 830 | } |
827 | 831 | ||
828 | void KOListView::hideDates() | 832 | void KOListView::hideDates() |
829 | { | 833 | { |
830 | showDates(false); | 834 | showDates(false); |
831 | } | 835 | } |
836 | |||
832 | void KOListView::resetFocus() | 837 | void KOListView::resetFocus() |
833 | { | 838 | { |
839 | topLevelWidget()->setActiveWindow(); | ||
840 | topLevelWidget()->raise(); | ||
834 | mListView->setFocus(); | 841 | mListView->setFocus(); |
835 | } | 842 | } |
836 | void KOListView::updateView() | 843 | void KOListView::updateView() |
837 | { | 844 | { |
838 | mListView->setFocus(); | 845 | mListView->setFocus(); |
839 | if ( mListView->firstChild () ) | 846 | if ( mListView->firstChild () ) |
840 | mListView->setCurrentItem( mListView->firstChild () ); | 847 | mListView->setCurrentItem( mListView->firstChild () ); |
841 | } | 848 | } |
842 | void KOListView::updateConfig() | 849 | void KOListView::updateConfig() |
843 | { | 850 | { |
844 | 851 | ||
845 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 852 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
846 | updateView(); | 853 | updateView(); |
847 | 854 | ||
848 | } | 855 | } |
849 | void KOListView::setStartDate(const QDate &start) | 856 | void KOListView::setStartDate(const QDate &start) |
850 | { | 857 | { |
851 | mStartDate = start; | 858 | mStartDate = start; |
852 | } | 859 | } |
853 | 860 | ||
854 | void KOListView::showDates(const QDate &start, const QDate &end) | 861 | void KOListView::showDates(const QDate &start, const QDate &end) |
855 | { | 862 | { |
856 | clear(); | 863 | clear(); |
857 | mStartDate = start; | 864 | mStartDate = start; |
858 | QDate date = start; | 865 | QDate date = start; |
859 | QPtrList<Journal> j_list; | 866 | QPtrList<Journal> j_list; |
860 | while( date <= end ) { | 867 | while( date <= end ) { |
861 | addEvents(calendar()->events(date)); | 868 | addEvents(calendar()->events(date)); |
862 | addTodos(calendar()->todos(date)); | 869 | addTodos(calendar()->todos(date)); |
863 | Journal* jo = calendar()->journal(date); | 870 | Journal* jo = calendar()->journal(date); |
864 | if ( jo ) | 871 | if ( jo ) |
865 | j_list.append( jo ); | 872 | j_list.append( jo ); |
866 | date = date.addDays( 1 ); | 873 | date = date.addDays( 1 ); |
867 | } | 874 | } |
868 | addJournals(j_list); | 875 | addJournals(j_list); |
869 | emit incidenceSelected( 0 ); | 876 | emit incidenceSelected( 0 ); |
870 | updateView(); | 877 | updateView(); |
871 | 878 | ||
872 | } | 879 | } |
873 | 880 | ||
874 | void KOListView::addEvents(QPtrList<Event> eventList) | 881 | void KOListView::addEvents(QPtrList<Event> eventList) |
875 | { | 882 | { |
876 | Event *ev; | 883 | Event *ev; |
877 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 884 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
878 | addIncidence(ev); | 885 | addIncidence(ev); |
879 | } | 886 | } |
880 | if ( !mListView->currentItem() ){ | 887 | if ( !mListView->currentItem() ){ |
881 | updateView(); | 888 | updateView(); |
882 | } | 889 | } |
883 | } | 890 | } |
884 | 891 | ||
885 | void KOListView::addTodos(QPtrList<Todo> eventList) | 892 | void KOListView::addTodos(QPtrList<Todo> eventList) |
886 | { | 893 | { |
887 | Todo *ev; | 894 | Todo *ev; |
888 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 895 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
889 | addIncidence(ev); | 896 | addIncidence(ev); |
890 | } | 897 | } |
891 | if ( !mListView->currentItem() ){ | 898 | if ( !mListView->currentItem() ){ |
892 | updateView(); | 899 | updateView(); |
893 | } | 900 | } |
894 | } | 901 | } |
895 | void KOListView::addJournals(QPtrList<Journal> eventList) | 902 | void KOListView::addJournals(QPtrList<Journal> eventList) |
896 | { | 903 | { |
897 | Journal *ev; | 904 | Journal *ev; |
898 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 905 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
899 | addIncidence(ev); | 906 | addIncidence(ev); |
900 | } | 907 | } |
901 | if ( !mListView->currentItem() ){ | 908 | if ( !mListView->currentItem() ){ |
902 | updateView(); | 909 | updateView(); |
903 | } | 910 | } |
904 | } | 911 | } |
905 | 912 | ||
906 | void KOListView::addIncidence(Incidence *incidence) | 913 | void KOListView::addIncidence(Incidence *incidence) |
907 | { | 914 | { |
908 | if ( mUidDict.find( incidence->uid() ) ) return; | 915 | if ( mUidDict.find( incidence->uid() ) ) return; |
909 | 916 | ||
910 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 917 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
911 | mUidDict.insert( incidence->uid(), incidence ); | 918 | mUidDict.insert( incidence->uid(), incidence ); |
912 | 919 | ||
913 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 920 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
914 | ListItemVisitor v(item, mStartDate ); | 921 | ListItemVisitor v(item, mStartDate ); |
915 | if (incidence->accept(v)) return; | 922 | if (incidence->accept(v)) return; |
916 | else delete item; | 923 | else delete item; |
917 | //qDebug("delete item "); | 924 | //qDebug("delete item "); |
918 | } | 925 | } |
919 | 926 | ||
920 | void KOListView::showEvents(QPtrList<Event> eventList) | 927 | void KOListView::showEvents(QPtrList<Event> eventList) |
921 | { | 928 | { |
922 | clear(); | 929 | clear(); |
923 | 930 | ||
924 | addEvents(eventList); | 931 | addEvents(eventList); |
925 | 932 | ||
926 | // After new creation of list view no events are selected. | 933 | // After new creation of list view no events are selected. |
927 | emit incidenceSelected( 0 ); | 934 | emit incidenceSelected( 0 ); |
928 | } | 935 | } |
929 | int KOListView::count() | 936 | int KOListView::count() |
930 | { | 937 | { |
931 | return mListView->childCount(); | 938 | return mListView->childCount(); |
932 | } | 939 | } |
933 | 940 | ||
934 | void KOListView::changeEventDisplay(Event *event, int action) | 941 | void KOListView::changeEventDisplay(Event *event, int action) |
935 | { | 942 | { |
936 | KOListViewItem *item; | 943 | KOListViewItem *item; |
937 | 944 | ||
938 | switch(action) { | 945 | switch(action) { |
939 | case KOGlobals::EVENTADDED: | 946 | case KOGlobals::EVENTADDED: |
940 | addIncidence( event ); | 947 | addIncidence( event ); |
941 | break; | 948 | break; |
942 | case KOGlobals::EVENTEDITED: | 949 | case KOGlobals::EVENTEDITED: |
943 | item = getItemForEvent(event); | 950 | item = getItemForEvent(event); |
944 | if (item) { | 951 | if (item) { |
945 | mUidDict.remove( event->uid() ); | 952 | mUidDict.remove( event->uid() ); |
946 | delete item; | 953 | delete item; |
947 | addIncidence( event ); | 954 | addIncidence( event ); |
948 | } | 955 | } |
949 | break; | 956 | break; |
950 | case KOGlobals::EVENTDELETED: | 957 | case KOGlobals::EVENTDELETED: |
951 | item = getItemForEvent(event); | 958 | item = getItemForEvent(event); |
952 | if (item) { | 959 | if (item) { |
953 | mUidDict.remove( event->uid() ); | 960 | mUidDict.remove( event->uid() ); |
954 | delete item; | 961 | delete item; |
955 | } | 962 | } |
956 | break; | 963 | break; |
957 | default: | 964 | default: |
958 | ; | 965 | ; |
959 | } | 966 | } |
960 | } | 967 | } |
961 | 968 | ||
962 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 969 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
963 | { | 970 | { |
964 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 971 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
965 | while (item) { | 972 | while (item) { |
966 | if (item->data() == event) return item; | 973 | if (item->data() == event) return item; |
967 | item = (KOListViewItem *)item->nextSibling(); | 974 | item = (KOListViewItem *)item->nextSibling(); |
968 | } | 975 | } |
969 | return 0; | 976 | return 0; |
970 | } | 977 | } |
971 | 978 | ||
972 | void KOListView::defaultItemAction(QListViewItem *i) | 979 | void KOListView::defaultItemAction(QListViewItem *i) |
973 | { | 980 | { |
974 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 981 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
975 | if ( item ) defaultAction( item->data() ); | 982 | if ( item ) defaultAction( item->data() ); |
976 | 983 | ||
977 | } | 984 | } |
978 | 985 | ||
979 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 986 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
980 | { | 987 | { |
981 | mActiveItem = (KOListViewItem *)item; | 988 | mActiveItem = (KOListViewItem *)item; |
982 | if (mActiveItem) { | 989 | if (mActiveItem) { |
983 | Incidence *incidence = mActiveItem->data(); | 990 | Incidence *incidence = mActiveItem->data(); |
984 | mPopupMenu->showIncidencePopup(incidence); | 991 | mPopupMenu->showIncidencePopup(incidence); |
985 | 992 | ||
986 | /* | 993 | /* |
987 | if ( incidence && incidence->type() == "Event" ) { | 994 | if ( incidence && incidence->type() == "Event" ) { |
988 | Event *event = static_cast<Event *>( incidence ); | 995 | Event *event = static_cast<Event *>( incidence ); |
989 | mPopupMenu->showEventPopup(event); | 996 | mPopupMenu->showEventPopup(event); |
990 | } | 997 | } |
991 | */ | 998 | */ |
992 | } | 999 | } |
993 | } | 1000 | } |
994 | 1001 | ||
995 | void KOListView::readSettings(KConfig *config, QString setting) | 1002 | void KOListView::readSettings(KConfig *config, QString setting) |
996 | { | 1003 | { |
997 | // qDebug("KOListView::readSettings "); | 1004 | // qDebug("KOListView::readSettings "); |
998 | mListView->restoreLayout(config,setting); | 1005 | mListView->restoreLayout(config,setting); |
999 | } | 1006 | } |
1000 | 1007 | ||
1001 | void KOListView::writeSettings(KConfig *config, QString setting) | 1008 | void KOListView::writeSettings(KConfig *config, QString setting) |
1002 | { | 1009 | { |
1003 | // qDebug("KOListView::writeSettings "); | 1010 | // qDebug("KOListView::writeSettings "); |
1004 | mListView->saveLayout(config, setting); | 1011 | mListView->saveLayout(config, setting); |
1005 | } | 1012 | } |
1006 | 1013 | ||
1007 | void KOListView::processSelectionChange(QListViewItem *) | 1014 | void KOListView::processSelectionChange(QListViewItem *) |
1008 | { | 1015 | { |
1009 | 1016 | ||
1010 | KOListViewItem *item = | 1017 | KOListViewItem *item = |
1011 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1018 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1012 | 1019 | ||
1013 | if ( !item ) { | 1020 | if ( !item ) { |
1014 | emit incidenceSelected( 0 ); | 1021 | emit incidenceSelected( 0 ); |
1015 | } else { | 1022 | } else { |
1016 | emit incidenceSelected( item->data() ); | 1023 | emit incidenceSelected( item->data() ); |
1017 | } | 1024 | } |
1018 | } | 1025 | } |
1019 | 1026 | ||
1020 | void KOListView::clearSelection() | 1027 | void KOListView::clearSelection() |
1021 | { | 1028 | { |
1022 | mListView->selectAll( false ); | 1029 | mListView->selectAll( false ); |
1023 | } | 1030 | } |
1024 | void KOListView::allSelection() | 1031 | void KOListView::allSelection() |
1025 | { | 1032 | { |
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index bb0e23e..eb5bb6e 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h | |||
@@ -70,242 +70,242 @@ class KOAlarmPrefs : public QDialog | |||
70 | alarmLayout->setMargin( 3 ); | 70 | alarmLayout->setMargin( 3 ); |
71 | QWidget *parent = this; | 71 | QWidget *parent = this; |
72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); | 72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); |
73 | alarmLayout->addWidget(mAlarmButton); | 73 | alarmLayout->addWidget(mAlarmButton); |
74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
75 | mAlarmTimeEdit->setValue( 15 ); | 75 | mAlarmTimeEdit->setValue( 15 ); |
76 | alarmLayout->addWidget(mAlarmTimeEdit); | 76 | alarmLayout->addWidget(mAlarmTimeEdit); |
77 | mAlarmIncrCombo = new QComboBox(false, parent); | 77 | mAlarmIncrCombo = new QComboBox(false, parent); |
78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
81 | alarmLayout->addWidget(mAlarmIncrCombo); | 81 | alarmLayout->addWidget(mAlarmIncrCombo); |
82 | QHBox * hb = new QHBox ( parent ); | 82 | QHBox * hb = new QHBox ( parent ); |
83 | alarmLayout->addWidget(hb); | 83 | alarmLayout->addWidget(hb); |
84 | mAlarmSoundButton = new QPushButton(hb); | 84 | mAlarmSoundButton = new QPushButton(hb); |
85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
86 | mAlarmSoundButton->setToggleButton(true); | 86 | mAlarmSoundButton->setToggleButton(true); |
87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
88 | mAlarmProgramButton = new QPushButton(hb); | 88 | mAlarmProgramButton = new QPushButton(hb); |
89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
90 | mAlarmProgramButton->setToggleButton(true); | 90 | mAlarmProgramButton->setToggleButton(true); |
91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
94 | mAlarmLabel = new QLabel( this ); | 94 | mAlarmLabel = new QLabel( this ); |
95 | alarmLayout->addWidget( mAlarmLabel ); | 95 | alarmLayout->addWidget( mAlarmLabel ); |
96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); | 96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); |
97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
98 | mAlarmSoundButton->setOn( true ); | 98 | mAlarmSoundButton->setOn( true ); |
99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); | 99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); |
100 | alarmLayout->addWidget( ok ); | 100 | alarmLayout->addWidget( ok ); |
101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
102 | alarmLayout->addWidget( cancel ); | 102 | alarmLayout->addWidget( cancel ); |
103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
105 | resize( 200, 200 ); | 105 | resize( 200, 200 ); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | QString mAlarmSound, mAlarmProgram ; | 111 | QString mAlarmSound, mAlarmProgram ; |
112 | QCheckBox* mAlarmButton; | 112 | QCheckBox* mAlarmButton; |
113 | QSpinBox* mAlarmTimeEdit; | 113 | QSpinBox* mAlarmTimeEdit; |
114 | QLabel* mAlarmLabel; | 114 | QLabel* mAlarmLabel; |
115 | QComboBox* mAlarmIncrCombo ; | 115 | QComboBox* mAlarmIncrCombo ; |
116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; | 116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; |
117 | private slots: | 117 | private slots: |
118 | 118 | ||
119 | void pickAlarmSound() | 119 | void pickAlarmSound() |
120 | { | 120 | { |
121 | //QString prefix = mAlarmSound; | 121 | //QString prefix = mAlarmSound; |
122 | if (!mAlarmSoundButton->isOn()) { | 122 | if (!mAlarmSoundButton->isOn()) { |
123 | //mAlarmSound = ""; | 123 | //mAlarmSound = ""; |
124 | QToolTip::remove(mAlarmSoundButton); | 124 | QToolTip::remove(mAlarmSoundButton); |
125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
126 | mAlarmProgramButton->setOn(true); | 126 | mAlarmProgramButton->setOn(true); |
127 | mAlarmSoundButton->setOn(false); | 127 | mAlarmSoundButton->setOn(false); |
128 | } else { | 128 | } else { |
129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
130 | i18n("*.wav|Wav Files"), 0)); | 130 | i18n("*.wav|Wav Files"), 0)); |
131 | if (!fileName.isEmpty()) { | 131 | if (!fileName.isEmpty()) { |
132 | mAlarmSound = fileName; | 132 | mAlarmSound = fileName; |
133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
134 | QToolTip::remove(mAlarmSoundButton); | 134 | QToolTip::remove(mAlarmSoundButton); |
135 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 135 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
136 | QToolTip::add(mAlarmSoundButton, dispStr); | 136 | QToolTip::add(mAlarmSoundButton, dispStr); |
137 | mAlarmProgramButton->setOn(false); | 137 | mAlarmProgramButton->setOn(false); |
138 | mAlarmSoundButton->setOn(true); | 138 | mAlarmSoundButton->setOn(true); |
139 | } else { | 139 | } else { |
140 | mAlarmProgramButton->setOn(true); | 140 | mAlarmProgramButton->setOn(true); |
141 | mAlarmSoundButton->setOn(false); | 141 | mAlarmSoundButton->setOn(false); |
142 | 142 | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | }; | 145 | }; |
146 | 146 | ||
147 | void pickAlarmProgram() | 147 | void pickAlarmProgram() |
148 | { | 148 | { |
149 | if (!mAlarmProgramButton->isOn()) { | 149 | if (!mAlarmProgramButton->isOn()) { |
150 | //mAlarmProgram = ""; | 150 | //mAlarmProgram = ""; |
151 | QToolTip::remove(mAlarmProgramButton); | 151 | QToolTip::remove(mAlarmProgramButton); |
152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
153 | mAlarmProgramButton->setOn(false); | 153 | mAlarmProgramButton->setOn(false); |
154 | mAlarmSoundButton->setOn(true); | 154 | mAlarmSoundButton->setOn(true); |
155 | } else { | 155 | } else { |
156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); | 156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); |
157 | if (!fileName.isEmpty()) { | 157 | if (!fileName.isEmpty()) { |
158 | mAlarmProgram = fileName; | 158 | mAlarmProgram = fileName; |
159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
160 | QToolTip::remove(mAlarmProgramButton); | 160 | QToolTip::remove(mAlarmProgramButton); |
161 | QString dispStr = i18n("Running '%1'").arg(fileName); | 161 | QString dispStr = i18n("Running '%1'").arg(fileName); |
162 | QToolTip::add(mAlarmProgramButton, dispStr); | 162 | QToolTip::add(mAlarmProgramButton, dispStr); |
163 | mAlarmSoundButton->setOn(false); | 163 | mAlarmSoundButton->setOn(false); |
164 | mAlarmProgramButton->setOn(true); | 164 | mAlarmProgramButton->setOn(true); |
165 | } else { | 165 | } else { |
166 | mAlarmProgramButton->setOn(false); | 166 | mAlarmProgramButton->setOn(false); |
167 | mAlarmSoundButton->setOn(true); | 167 | mAlarmSoundButton->setOn(true); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | }; | 170 | }; |
171 | 171 | ||
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | typedef CustomListViewItem<Incidence *> KOListViewItem; | 180 | typedef CustomListViewItem<Incidence *> KOListViewItem; |
181 | 181 | ||
182 | /** | 182 | /** |
183 | This class provides the initialisation of a KOListViewItem for calendar | 183 | This class provides the initialisation of a KOListViewItem for calendar |
184 | components using the Incidence::Visitor. | 184 | components using the Incidence::Visitor. |
185 | */ | 185 | */ |
186 | class ListItemVisitor : public Incidence::Visitor | 186 | class ListItemVisitor : public Incidence::Visitor |
187 | { | 187 | { |
188 | public: | 188 | public: |
189 | ListItemVisitor(KOListViewItem *, QDate d); | 189 | ListItemVisitor(KOListViewItem *, QDate d); |
190 | ~ListItemVisitor(); | 190 | ~ListItemVisitor(); |
191 | 191 | ||
192 | bool visit(Event *); | 192 | bool visit(Event *); |
193 | bool visit(Todo *); | 193 | bool visit(Todo *); |
194 | bool visit(Journal *); | 194 | bool visit(Journal *); |
195 | 195 | ||
196 | private: | 196 | private: |
197 | KOListViewItem *mItem; | 197 | KOListViewItem *mItem; |
198 | QDate mDate; | 198 | QDate mDate; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | This class provides a multi-column list view of events. It can | 202 | This class provides a multi-column list view of events. It can |
203 | display events from one particular day or several days, it doesn't | 203 | display events from one particular day or several days, it doesn't |
204 | matter. To use a view that only handles one day at a time, use | 204 | matter. To use a view that only handles one day at a time, use |
205 | KODayListView. | 205 | KODayListView. |
206 | 206 | ||
207 | @short multi-column list view of various events. | 207 | @short multi-column list view of various events. |
208 | @author Preston Brown <pbrown@kde.org> | 208 | @author Preston Brown <pbrown@kde.org> |
209 | @see KOBaseView, KODayListView | 209 | @see KOBaseView, KODayListView |
210 | */ | 210 | */ |
211 | class KOListView; | 211 | class KOListView; |
212 | 212 | ||
213 | class KOListViewListView : public KListView | 213 | class KOListViewListView : public KListView |
214 | { | 214 | { |
215 | Q_OBJECT | 215 | Q_OBJECT |
216 | public: | 216 | public: |
217 | KOListViewListView(KOListView * lv ); | 217 | KOListViewListView(KOListView * lv ); |
218 | signals: | 218 | signals: |
219 | void newEvent(); | 219 | void newEvent(); |
220 | void showIncidence( Incidence* ); | 220 | void showIncidence( Incidence* ); |
221 | public slots: | 221 | public slots: |
222 | void popupMenu(); | 222 | void popupMenu(); |
223 | private: | 223 | private: |
224 | QPoint mEventPos; | 224 | QPoint mEventPos; |
225 | QPoint mEventGlobalPos; | 225 | QPoint mEventGlobalPos; |
226 | QTimer* mPopupTimer; | 226 | QTimer* mPopupTimer; |
227 | int mYMousePos; | 227 | int mYMousePos; |
228 | void keyPressEvent ( QKeyEvent * ) ; | 228 | void keyPressEvent ( QKeyEvent * ) ; |
229 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | 229 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
230 | void contentsMousePressEvent(QMouseEvent *e); | 230 | void contentsMousePressEvent(QMouseEvent *e); |
231 | void contentsMouseReleaseEvent(QMouseEvent *e); | 231 | void contentsMouseReleaseEvent(QMouseEvent *e); |
232 | void contentsMouseMoveEvent(QMouseEvent *e); | 232 | void contentsMouseMoveEvent(QMouseEvent *e); |
233 | bool mMouseDown; | 233 | bool mMouseDown; |
234 | }; | 234 | }; |
235 | 235 | ||
236 | class KOListView : public KOEventView | 236 | class KOListView : public KOEventView |
237 | { | 237 | { |
238 | Q_OBJECT | 238 | Q_OBJECT |
239 | public: | 239 | public: |
240 | KOListView(Calendar *calendar, QWidget *parent = 0, | 240 | KOListView(Calendar *calendar, QWidget *parent = 0, |
241 | const char *name = 0); | 241 | const char *name = 0); |
242 | ~KOListView(); | 242 | ~KOListView(); |
243 | 243 | ||
244 | virtual int maxDatesHint(); | 244 | virtual int maxDatesHint(); |
245 | virtual int currentDateCount(); | 245 | virtual int currentDateCount(); |
246 | virtual QPtrList<Incidence> selectedIncidences(); | 246 | virtual QPtrList<Incidence> selectedIncidences(); |
247 | virtual DateList selectedDates(); | 247 | virtual DateList selectedDates(); |
248 | 248 | ||
249 | void showDates(bool show); | 249 | void showDates(bool show); |
250 | Incidence* currentItem(); | 250 | Incidence* currentItem(); |
251 | void addTodos(QPtrList<Todo> eventList); | 251 | void addTodos(QPtrList<Todo> eventList); |
252 | void addJournals(QPtrList<Journal> eventList); | 252 | void addJournals(QPtrList<Journal> eventList); |
253 | virtual void printPreview(CalPrinter *calPrinter, | 253 | virtual void printPreview(CalPrinter *calPrinter, |
254 | const QDate &, const QDate &); | 254 | const QDate &, const QDate &); |
255 | 255 | ||
256 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); | 256 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); |
257 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); | 257 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); |
258 | void updateList(); | 258 | void updateList(); |
259 | void setStartDate(const QDate &start); | 259 | void setStartDate(const QDate &start); |
260 | int count(); | 260 | int count(); |
261 | QString getWhatsThisText(QPoint p); | 261 | QString getWhatsThisText(QPoint p); |
262 | void resetFocus(); | ||
263 | signals: | 262 | signals: |
264 | void signalNewEvent(); | 263 | void signalNewEvent(); |
265 | void beamIncidenceList(QPtrList<Incidence>); | 264 | void beamIncidenceList(QPtrList<Incidence>); |
266 | 265 | ||
267 | public slots: | 266 | public slots: |
267 | void resetFocus(); | ||
268 | virtual void updateView(); | 268 | virtual void updateView(); |
269 | virtual void showDates(const QDate &start, const QDate &end); | 269 | virtual void showDates(const QDate &start, const QDate &end); |
270 | virtual void showEvents(QPtrList<Event> eventList); | 270 | virtual void showEvents(QPtrList<Event> eventList); |
271 | void clearSelection(); | 271 | void clearSelection(); |
272 | void allSelection(); | 272 | void allSelection(); |
273 | 273 | ||
274 | void clear(); | 274 | void clear(); |
275 | void beamDone( Ir *ir ); | 275 | void beamDone( Ir *ir ); |
276 | void showDates(); | 276 | void showDates(); |
277 | void hideDates(); | 277 | void hideDates(); |
278 | void deleteAll(); | 278 | void deleteAll(); |
279 | void saveToFile(); | 279 | void saveToFile(); |
280 | void saveToFileVCS(); | 280 | void saveToFileVCS(); |
281 | void saveDescriptionToFile(); | 281 | void saveDescriptionToFile(); |
282 | void beamSelected(); | 282 | void beamSelected(); |
283 | void updateConfig(); | 283 | void updateConfig(); |
284 | void addCat(); | 284 | void addCat(); |
285 | void setCat(); | 285 | void setCat(); |
286 | void setAlarm(); | 286 | void setAlarm(); |
287 | void setCategories( bool removeOld ); | 287 | void setCategories( bool removeOld ); |
288 | void changeEventDisplay(Event *, int); | 288 | void changeEventDisplay(Event *, int); |
289 | 289 | ||
290 | void defaultItemAction(QListViewItem *item); | 290 | void defaultItemAction(QListViewItem *item); |
291 | void popupMenu(QListViewItem *item,const QPoint &,int); | 291 | void popupMenu(QListViewItem *item,const QPoint &,int); |
292 | 292 | ||
293 | protected slots: | 293 | protected slots: |
294 | void processSelectionChange(QListViewItem *); | 294 | void processSelectionChange(QListViewItem *); |
295 | 295 | ||
296 | protected: | 296 | protected: |
297 | void writeToFile( bool iCal ); | 297 | void writeToFile( bool iCal ); |
298 | void addEvents(QPtrList<Event> eventList); | 298 | void addEvents(QPtrList<Event> eventList); |
299 | void addIncidence(Incidence *); | 299 | void addIncidence(Incidence *); |
300 | KOListViewItem *getItemForEvent(Event *event); | 300 | KOListViewItem *getItemForEvent(Event *event); |
301 | 301 | ||
302 | private: | 302 | private: |
303 | KOListViewListView *mListView; | 303 | KOListViewListView *mListView; |
304 | KOEventPopupMenu *mPopupMenu; | 304 | KOEventPopupMenu *mPopupMenu; |
305 | KOListViewItem *mActiveItem; | 305 | KOListViewItem *mActiveItem; |
306 | QDict<Incidence> mUidDict; | 306 | QDict<Incidence> mUidDict; |
307 | QDate mStartDate; | 307 | QDate mStartDate; |
308 | void keyPressEvent ( QKeyEvent * ) ; | 308 | void keyPressEvent ( QKeyEvent * ) ; |
309 | }; | 309 | }; |
310 | 310 | ||
311 | #endif | 311 | #endif |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 2b7e41f..843526d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -98,1151 +98,1139 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | |||
98 | QListBox::focusInEvent ( e ); | 98 | QListBox::focusInEvent ( e ); |
99 | if ( count() ){ | 99 | if ( count() ){ |
100 | int ci = currentItem(); | 100 | int ci = currentItem(); |
101 | if ( ci < 0 ) ci = 0; | 101 | if ( ci < 0 ) ci = 0; |
102 | 102 | ||
103 | setCurrentItem( ci ); | 103 | setCurrentItem( ci ); |
104 | setSelected ( ci, true ); | 104 | setSelected ( ci, true ); |
105 | emit highlighted( item ( ci ) ); | 105 | emit highlighted( item ( ci ) ); |
106 | 106 | ||
107 | resetOnFocusIn = true; | 107 | resetOnFocusIn = true; |
108 | 108 | ||
109 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 109 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
110 | QListBoxItem *fi = firstItem (); | 110 | QListBoxItem *fi = firstItem (); |
111 | if (fi ) { | 111 | if (fi ) { |
112 | int ihei = fi->height( this ); | 112 | int ihei = fi->height( this ); |
113 | int hei = numRows () * ihei; | 113 | int hei = numRows () * ihei; |
114 | if ( hei < height() - horizontalScrollBar()->height () ) { | 114 | if ( hei < height() - horizontalScrollBar()->height () ) { |
115 | setVScrollBarMode(QScrollView::AlwaysOff); | 115 | setVScrollBarMode(QScrollView::AlwaysOff); |
116 | } | 116 | } |
117 | else | 117 | else |
118 | setVScrollBarMode(QScrollView::Auto); | 118 | setVScrollBarMode(QScrollView::Auto); |
119 | if ( ihei *3 > height() ) { | 119 | if ( ihei *3 > height() ) { |
120 | setHScrollBarMode(QScrollView::AlwaysOff); | 120 | setHScrollBarMode(QScrollView::AlwaysOff); |
121 | } | 121 | } |
122 | else { | 122 | else { |
123 | setHScrollBarMode(QScrollView::Auto); | 123 | setHScrollBarMode(QScrollView::Auto); |
124 | } | 124 | } |
125 | } else { | 125 | } else { |
126 | setVScrollBarMode(QScrollView::Auto); | 126 | setVScrollBarMode(QScrollView::Auto); |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 132 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
133 | { | 133 | { |
134 | int i = currentItem (); | 134 | int i = currentItem (); |
135 | if ( i >= 0 ) { | 135 | if ( i >= 0 ) { |
136 | setSelected ( i, false ); | 136 | setSelected ( i, false ); |
137 | } | 137 | } |
138 | QListBox::focusOutEvent ( e ); | 138 | QListBox::focusOutEvent ( e ); |
139 | setVScrollBarMode(QScrollView::AlwaysOff); | 139 | setVScrollBarMode(QScrollView::AlwaysOff); |
140 | setHScrollBarMode(QScrollView::AlwaysOff); | 140 | setHScrollBarMode(QScrollView::AlwaysOff); |
141 | } | 141 | } |
142 | 142 | ||
143 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 143 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
144 | { | 144 | { |
145 | QListBoxItem* item = itemAt ( p ); | 145 | QListBoxItem* item = itemAt ( p ); |
146 | if ( ! item ) { | 146 | if ( ! item ) { |
147 | return i18n("Click in the cell\nto add an event!"); | 147 | return i18n("Click in the cell\nto add an event!"); |
148 | } | 148 | } |
149 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 149 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
150 | KOPrefs::instance()->mWTshowDetails, | 150 | KOPrefs::instance()->mWTshowDetails, |
151 | KOPrefs::instance()->mWTshowCreated, | 151 | KOPrefs::instance()->mWTshowCreated, |
152 | KOPrefs::instance()->mWTshowChanged); | 152 | KOPrefs::instance()->mWTshowChanged); |
153 | } | 153 | } |
154 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | //qDebug("KNoScrollListBox::keyPressEvent "); | 156 | //qDebug("KNoScrollListBox::keyPressEvent "); |
157 | switch(e->key()) { | 157 | switch(e->key()) { |
158 | case Key_Right: | 158 | case Key_Right: |
159 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 159 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
160 | { | 160 | { |
161 | e->ignore(); | 161 | e->ignore(); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | scrollBy(10,0); | 164 | scrollBy(10,0); |
165 | break; | 165 | break; |
166 | case Key_Left: | 166 | case Key_Left: |
167 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 167 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
168 | { | 168 | { |
169 | e->ignore(); | 169 | e->ignore(); |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | scrollBy(-10,0); | 172 | scrollBy(-10,0); |
173 | break; | 173 | break; |
174 | case Key_Up: | 174 | case Key_Up: |
175 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 175 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
176 | e->ignore(); | 176 | e->ignore(); |
177 | break; | 177 | break; |
178 | } | 178 | } |
179 | if ( count() ) { | 179 | if ( count() ) { |
180 | if ( currentItem() == 0 ) { | 180 | if ( currentItem() == 0 ) { |
181 | emit prevCell(); | 181 | emit prevCell(); |
182 | } else { | 182 | } else { |
183 | setCurrentItem((currentItem()+count()-1)%count()); | 183 | setCurrentItem((currentItem()+count()-1)%count()); |
184 | if(!itemVisible(currentItem())) { | 184 | if(!itemVisible(currentItem())) { |
185 | if((unsigned int) currentItem() == (count()-1)) { | 185 | if((unsigned int) currentItem() == (count()-1)) { |
186 | setTopItem(currentItem()-numItemsVisible()+1); | 186 | setTopItem(currentItem()-numItemsVisible()+1); |
187 | } else { | 187 | } else { |
188 | setTopItem(topItem()-1); | 188 | setTopItem(topItem()-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | break; | 193 | break; |
194 | case Key_Down: | 194 | case Key_Down: |
195 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 195 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
196 | e->ignore(); | 196 | e->ignore(); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | if ( count () ) { | 199 | if ( count () ) { |
200 | if ( currentItem()+1 == count () ) { | 200 | if ( currentItem()+1 == count () ) { |
201 | emit nextCell(); | 201 | emit nextCell(); |
202 | } else { | 202 | } else { |
203 | setCurrentItem((currentItem()+1)%count()); | 203 | setCurrentItem((currentItem()+1)%count()); |
204 | if(!itemVisible(currentItem())) { | 204 | if(!itemVisible(currentItem())) { |
205 | if(currentItem() == 0) { | 205 | if(currentItem() == 0) { |
206 | setTopItem(0); | 206 | setTopItem(0); |
207 | } else { | 207 | } else { |
208 | setTopItem(topItem()+1); | 208 | setTopItem(topItem()+1); |
209 | } | 209 | } |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | break; | 213 | break; |
214 | case Key_I: | 214 | case Key_I: |
215 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 215 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
216 | e->ignore(); | 216 | e->ignore(); |
217 | break; | 217 | break; |
218 | case Key_Return: | 218 | case Key_Return: |
219 | case Key_Enter: | 219 | case Key_Enter: |
220 | { | 220 | { |
221 | if ( currentItem() >= 0 ) { | 221 | if ( currentItem() >= 0 ) { |
222 | emit doubleClicked( item( currentItem() ) ); | 222 | emit doubleClicked( item( currentItem() ) ); |
223 | e->accept(); | 223 | e->accept(); |
224 | } else { | 224 | } else { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | break; | 228 | break; |
229 | case Key_Shift: | 229 | case Key_Shift: |
230 | emit shiftDown(); | 230 | emit shiftDown(); |
231 | break; | 231 | break; |
232 | default: | 232 | default: |
233 | e->ignore(); | 233 | e->ignore(); |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | void KNoScrollListBox::oneDown() | 238 | void KNoScrollListBox::oneDown() |
239 | { | 239 | { |
240 | if ( count () ) { | 240 | if ( count () ) { |
241 | if ( currentItem()+1 == count () ) { | 241 | if ( currentItem()+1 == count () ) { |
242 | emit nextCell(); | 242 | emit nextCell(); |
243 | } else { | 243 | } else { |
244 | resetOnFocusIn = false; | 244 | resetOnFocusIn = false; |
245 | setCurrentItem((currentItem()+1)%count()); | 245 | setCurrentItem((currentItem()+1)%count()); |
246 | if(!itemVisible(currentItem())) { | 246 | if(!itemVisible(currentItem())) { |
247 | if(currentItem() == 0) { | 247 | if(currentItem() == 0) { |
248 | setTopItem(0); | 248 | setTopItem(0); |
249 | } else { | 249 | } else { |
250 | setTopItem(topItem()+1); | 250 | setTopItem(topItem()+1); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 256 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
257 | { | 257 | { |
258 | switch(e->key()) { | 258 | switch(e->key()) { |
259 | case Key_Shift: | 259 | case Key_Shift: |
260 | emit shiftUp(); | 260 | emit shiftUp(); |
261 | break; | 261 | break; |
262 | default: | 262 | default: |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 267 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
268 | { | 268 | { |
269 | QListBox::mousePressEvent(e); | 269 | QListBox::mousePressEvent(e); |
270 | 270 | ||
271 | if(e->button() == RightButton) { | 271 | if(e->button() == RightButton) { |
272 | emit rightClick(); | 272 | emit rightClick(); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 276 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
277 | : QListBoxItem() | 277 | : QListBoxItem() |
278 | { | 278 | { |
279 | mblockRepaint = true; | 279 | mblockRepaint = true; |
280 | setText( s ); | 280 | setText( s ); |
281 | mMultiday = 0; | 281 | mMultiday = 0; |
282 | mIncidence = incidence; | 282 | mIncidence = incidence; |
283 | mDate = qd; | 283 | mDate = qd; |
284 | mRecur = false; | 284 | mRecur = false; |
285 | mAlarm = false; | 285 | mAlarm = false; |
286 | mReply = false; | 286 | mReply = false; |
287 | mInfo = false; | 287 | mInfo = false; |
288 | mdayPos = 0; | 288 | mdayPos = 0; |
289 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 289 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
290 | //qDebug("NEWWWWWWWWWWWWW "); | ||
291 | } | 290 | } |
292 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 291 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
293 | { | 292 | { |
294 | setText( s ); | 293 | setText( s ); |
295 | mMultiday = 0; | 294 | mMultiday = 0; |
296 | mIncidence = incidence; | 295 | mIncidence = incidence; |
297 | mDate = qd; | 296 | mDate = qd; |
298 | mRecur = false; | 297 | mRecur = false; |
299 | mAlarm = false; | 298 | mAlarm = false; |
300 | mReply = false; | 299 | mReply = false; |
301 | mInfo = false; | 300 | mInfo = false; |
302 | mdayPos = 0; | 301 | mdayPos = 0; |
303 | //qDebug("recucleeeeeeeeeeeeeeeee "); | ||
304 | } | 302 | } |
305 | 303 | ||
306 | void MonthViewItem::paint(QPainter *p) | 304 | void MonthViewItem::paint(QPainter *p) |
307 | { | 305 | { |
308 | if ( mblockRepaint ) { | 306 | if ( mblockRepaint ) { |
309 | //qDebug("block "); | ||
310 | return; | 307 | return; |
311 | } | 308 | } |
312 | //qDebug("NON block "); | ||
313 | #if QT_VERSION >= 0x030000 | 309 | #if QT_VERSION >= 0x030000 |
314 | bool sel = isSelected(); | 310 | bool sel = isSelected(); |
315 | #else | 311 | #else |
316 | bool sel = selected(); | 312 | bool sel = selected(); |
317 | #endif | 313 | #endif |
318 | 314 | ||
319 | 315 | ||
320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 316 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
321 | { | 317 | { |
322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 318 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 319 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 320 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
325 | } | 321 | } |
326 | int x = 1; | 322 | int x = 1; |
327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 323 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
328 | int size = PIXMAP_SIZE; | 324 | int size = PIXMAP_SIZE; |
329 | if ( QApplication::desktop()->width() < 300 ) | 325 | if ( QApplication::desktop()->width() < 300 ) |
330 | size = 3; | 326 | size = 3; |
331 | int heihei = height( listBox () ); | 327 | int heihei = height( listBox () ); |
332 | int y = (heihei - size -1 ) /2; | 328 | int y = (heihei - size -1 ) /2; |
333 | 329 | ||
334 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 330 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
335 | if ( mInfo ) { | 331 | if ( mInfo ) { |
336 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 332 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
337 | x += size + 1; | 333 | x += size + 1; |
338 | } | 334 | } |
339 | if ( mRecur ) { | 335 | if ( mRecur ) { |
340 | p->fillRect ( x, y,size,size, Qt::blue ); | 336 | p->fillRect ( x, y,size,size, Qt::blue ); |
341 | x += size + 1; | 337 | x += size + 1; |
342 | } | 338 | } |
343 | if ( mAlarm ) { | 339 | if ( mAlarm ) { |
344 | p->fillRect ( x, y,size,size, Qt::red ); | 340 | p->fillRect ( x, y,size,size, Qt::red ); |
345 | x += size + 1; | 341 | x += size + 1; |
346 | } | 342 | } |
347 | if ( mReply ) { | 343 | if ( mReply ) { |
348 | p->fillRect ( x, y,size,size, Qt::yellow ); | 344 | p->fillRect ( x, y,size,size, Qt::yellow ); |
349 | x += size + 1; | 345 | x += size + 1; |
350 | } | 346 | } |
351 | } | 347 | } |
352 | if ( mMultiday ) { | 348 | if ( mMultiday ) { |
353 | int yyy = y+(size/2); | 349 | int yyy = y+(size/2); |
354 | int sizeM = size+2; | 350 | int sizeM = size+2; |
355 | p->setBrush( QBrush::SolidPattern ); | 351 | p->setBrush( QBrush::SolidPattern ); |
356 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 352 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
357 | if ( mMultiday == 2 || mMultiday == 3 ) { | 353 | if ( mMultiday == 2 || mMultiday == 3 ) { |
358 | QPointArray pa ( 3 ); | 354 | QPointArray pa ( 3 ); |
359 | pa.setPoint (0, x, yyy ); | 355 | pa.setPoint (0, x, yyy ); |
360 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 356 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
361 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 357 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
362 | p->drawPolygon( pa ); | 358 | p->drawPolygon( pa ); |
363 | } | 359 | } |
364 | if ( mMultiday == 2 || mMultiday == 1 ) { | 360 | if ( mMultiday == 2 || mMultiday == 1 ) { |
365 | QPointArray pa ( 3 ); | 361 | QPointArray pa ( 3 ); |
366 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 362 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
367 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 363 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
368 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 364 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
369 | p->drawPolygon( pa ); | 365 | p->drawPolygon( pa ); |
370 | } | 366 | } |
371 | if ( mMultiday == 1 ) { | 367 | if ( mMultiday == 1 ) { |
372 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 368 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
373 | 369 | ||
374 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 370 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
375 | } | 371 | } |
376 | if ( mMultiday == 3 ) { | 372 | if ( mMultiday == 3 ) { |
377 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 373 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
378 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 374 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
379 | 375 | ||
380 | } | 376 | } |
381 | x += sizeM/2 + 1; | 377 | x += sizeM/2 + 1; |
382 | x += sizeM + 1; | 378 | x += sizeM + 1; |
383 | } | 379 | } |
384 | 380 | ||
385 | if ( mIncidence->type() == "Todo" ){ | 381 | if ( mIncidence->type() == "Todo" ){ |
386 | Todo* td = ( Todo* ) mIncidence; | 382 | Todo* td = ( Todo* ) mIncidence; |
387 | if ( td->isCompleted() ) { | 383 | if ( td->isCompleted() ) { |
388 | int half = size/2; | 384 | int half = size/2; |
389 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 385 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
390 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 386 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
391 | x += half+half + 4; | 387 | x += half+half + 4; |
392 | 388 | ||
393 | } else { | 389 | } else { |
394 | int val = td->percentComplete()/20; | 390 | int val = td->percentComplete()/20; |
395 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 391 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
396 | p->drawRect ( x, y-2,7,size+4); | 392 | p->drawRect ( x, y-2,7,size+4); |
397 | x += size + 3; | 393 | x += size + 3; |
398 | } | 394 | } |
399 | } | 395 | } |
400 | QFontMetrics fm = p->fontMetrics(); | 396 | QFontMetrics fm = p->fontMetrics(); |
401 | int yPos; | 397 | int yPos; |
402 | int pmheight = size; | 398 | int pmheight = size; |
403 | if( pmheight < fm.height() ) | 399 | if( pmheight < fm.height() ) |
404 | yPos = fm.ascent() + fm.leading()/2; | 400 | yPos = fm.ascent() + fm.leading()/2; |
405 | else | 401 | else |
406 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 402 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
407 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 403 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
408 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 404 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
409 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 405 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
410 | p->drawText( x, yPos, text() ); | 406 | p->drawText( x, yPos, text() ); |
411 | if ( mIncidence->cancelled() ) { | 407 | if ( mIncidence->cancelled() ) { |
412 | int wid = fm.width( text() ); | 408 | int wid = fm.width( text() ); |
413 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 409 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
414 | } | 410 | } |
415 | } else { | 411 | } else { |
416 | QString pText = text(); | 412 | QString pText = text(); |
417 | if( pText.mid(2,1) == ":" ) | 413 | if( pText.mid(2,1) == ":" ) |
418 | pText = pText.mid( 6 ); | 414 | pText = pText.mid( 6 ); |
419 | p->drawText( x, yPos, pText ); | 415 | p->drawText( x, yPos, pText ); |
420 | if ( mIncidence->cancelled() ) { | 416 | if ( mIncidence->cancelled() ) { |
421 | int wid = fm.width( pText ); | 417 | int wid = fm.width( pText ); |
422 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 418 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
423 | } | 419 | } |
424 | } | 420 | } |
425 | } | 421 | } |
426 | 422 | ||
427 | int MonthViewItem::height(const QListBox *lb) const | 423 | int MonthViewItem::height(const QListBox *lb) const |
428 | { | 424 | { |
429 | int ret = 10; | 425 | int ret = 10; |
430 | if ( lb ) | 426 | if ( lb ) |
431 | ret = lb->fontMetrics().lineSpacing()+1; | 427 | ret = lb->fontMetrics().lineSpacing()+1; |
432 | return ret; | 428 | return ret; |
433 | } | 429 | } |
434 | 430 | ||
435 | int MonthViewItem::width(const QListBox *lb) const | 431 | int MonthViewItem::width(const QListBox *lb) const |
436 | { | 432 | { |
437 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 433 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
438 | int size = PIXMAP_SIZE; | 434 | int size = PIXMAP_SIZE; |
439 | if ( QApplication::desktop()->width() < 300 ) | 435 | if ( QApplication::desktop()->width() < 300 ) |
440 | size = 3; | 436 | size = 3; |
441 | int x = 1; | 437 | int x = 1; |
442 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 438 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
443 | if ( mInfo ) { | 439 | if ( mInfo ) { |
444 | x += size + 1; | 440 | x += size + 1; |
445 | } | 441 | } |
446 | if( mRecur ) { | 442 | if( mRecur ) { |
447 | x += size+1; | 443 | x += size+1; |
448 | } | 444 | } |
449 | if( mAlarm ) { | 445 | if( mAlarm ) { |
450 | x += size+1; | 446 | x += size+1; |
451 | } | 447 | } |
452 | if( mReply ) { | 448 | if( mReply ) { |
453 | x += size+1; | 449 | x += size+1; |
454 | } | 450 | } |
455 | } | 451 | } |
456 | if( mMultiday ) { | 452 | if( mMultiday ) { |
457 | x += size+1+2+size/2; | 453 | x += size+1+2+size/2; |
458 | } | 454 | } |
459 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 455 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
460 | } | 456 | } |
461 | if ( ! lb ) | 457 | if ( ! lb ) |
462 | return 10; | 458 | return 10; |
463 | //qDebug("ret wid %d ", lb->width()); | ||
464 | return lb->width(); | 459 | return lb->width(); |
465 | } | 460 | } |
466 | 461 | ||
467 | 462 | ||
468 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 463 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
469 | : KNoScrollListBox( par ), | 464 | : KNoScrollListBox( par ), |
470 | mMonthView( parent ) | 465 | mMonthView( parent ) |
471 | { | 466 | { |
472 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 467 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
473 | currentPalette = 0; | 468 | currentPalette = 0; |
474 | // mLabel = new QLabel( this );QPushButton | 469 | // mLabel = new QLabel( this );QPushButton |
475 | mLabel = new QPushButton( this ); | 470 | mLabel = new QPushButton( this ); |
476 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 471 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
477 | //mLabel->setLineWidth( 1 ); | 472 | //mLabel->setLineWidth( 1 ); |
478 | //mLabel->setAlignment( AlignCenter ); | 473 | //mLabel->setAlignment( AlignCenter ); |
479 | mLabel->setFlat( true ); | 474 | mLabel->setFlat( true ); |
480 | mLabel->setFocusPolicy(NoFocus); | 475 | mLabel->setFocusPolicy(NoFocus); |
481 | //mItemList = new KNoScrollListBox( this ); | 476 | //mItemList = new KNoScrollListBox( this ); |
482 | setMinimumSize( 10, 10 ); | 477 | setMinimumSize( 10, 10 ); |
483 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 478 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
484 | setLineWidth( 1 ); | 479 | setLineWidth( 1 ); |
485 | //topLayout->addWidget( mItemList ); | 480 | //topLayout->addWidget( mItemList ); |
486 | mLabel->raise(); | 481 | mLabel->raise(); |
487 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 482 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
488 | mStandardPalette = palette(); | 483 | mStandardPalette = palette(); |
489 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 484 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
490 | 485 | ||
491 | enableScrollBars( false ); | 486 | enableScrollBars( false ); |
492 | updateConfig(); | 487 | updateConfig(); |
493 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 488 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
494 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 489 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
495 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 490 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
496 | SLOT( defaultAction( QListBoxItem * ) ) ); | 491 | SLOT( defaultAction( QListBoxItem * ) ) ); |
497 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 492 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
498 | const QPoint &) ), | 493 | const QPoint &) ), |
499 | SLOT( contextMenu( QListBoxItem * ) ) ); | 494 | SLOT( contextMenu( QListBoxItem * ) ) ); |
500 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 495 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
501 | SLOT( selection( QListBoxItem * ) ) ); | 496 | SLOT( selection( QListBoxItem * ) ) ); |
502 | 497 | ||
503 | /* | 498 | /* |
504 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 499 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
505 | SLOT( selection( QListBoxItem * ) ) ); | 500 | SLOT( selection( QListBoxItem * ) ) ); |
506 | */ | 501 | */ |
507 | } | 502 | } |
508 | #ifdef DESKTOP_VERSION | 503 | #ifdef DESKTOP_VERSION |
509 | QToolTipGroup *MonthViewCell::toolTipGroup() | 504 | QToolTipGroup *MonthViewCell::toolTipGroup() |
510 | { | 505 | { |
511 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 506 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
512 | return mToolTipGroup; | 507 | return mToolTipGroup; |
513 | } | 508 | } |
514 | #endif | 509 | #endif |
515 | 510 | ||
516 | void MonthViewCell::setDate( const QDate &date ) | 511 | void MonthViewCell::setDate( const QDate &date ) |
517 | { | 512 | { |
518 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 513 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
519 | mDate = date; | 514 | mDate = date; |
520 | 515 | ||
521 | 516 | ||
522 | 517 | ||
523 | //resizeEvent( 0 ); | 518 | //resizeEvent( 0 ); |
524 | } | 519 | } |
525 | 520 | ||
526 | QDate MonthViewCell::date() const | 521 | QDate MonthViewCell::date() const |
527 | { | 522 | { |
528 | return mDate; | 523 | return mDate; |
529 | } | 524 | } |
530 | 525 | ||
531 | void MonthViewCell::setPrimary( bool primary ) | 526 | void MonthViewCell::setPrimary( bool primary ) |
532 | { | 527 | { |
533 | mPrimary = primary; | 528 | mPrimary = primary; |
534 | //setMyPalette(); | 529 | //setMyPalette(); |
535 | } | 530 | } |
536 | void MonthViewCell::setMyPalette() | 531 | void MonthViewCell::setMyPalette() |
537 | { | 532 | { |
538 | 533 | ||
539 | if ( mHoliday) { | 534 | if ( mHoliday) { |
540 | if ( currentPalette == 1 ) return; | 535 | if ( currentPalette == 1 ) return; |
541 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 536 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
542 | setPalette( mHolidayPalette ); | 537 | setPalette( mHolidayPalette ); |
543 | //mLabel->setPalette( mHolidayPalette ); | 538 | //mLabel->setPalette( mHolidayPalette ); |
544 | currentPalette = 1; | 539 | currentPalette = 1; |
545 | 540 | ||
546 | } else { | 541 | } else { |
547 | if ( mPrimary ) { | 542 | if ( mPrimary ) { |
548 | if ( currentPalette == 2 ) return; | 543 | if ( currentPalette == 2 ) return; |
549 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 544 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
550 | //mLabel->setPalette( mPrimaryPalette ); | 545 | //mLabel->setPalette( mPrimaryPalette ); |
551 | setPalette( mPrimaryPalette ); | 546 | setPalette( mPrimaryPalette ); |
552 | currentPalette = 2; | 547 | currentPalette = 2; |
553 | 548 | ||
554 | } else { | 549 | } else { |
555 | if ( currentPalette == 3 ) return; | 550 | if ( currentPalette == 3 ) return; |
556 | setPalette( mNonPrimaryPalette ); | 551 | setPalette( mNonPrimaryPalette ); |
557 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 552 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
558 | //mLabel->setPalette( mNonPrimaryPalette );; | 553 | //mLabel->setPalette( mNonPrimaryPalette );; |
559 | currentPalette = 3; | 554 | currentPalette = 3; |
560 | } | 555 | } |
561 | } | 556 | } |
562 | //QPalette pal = palette(); | 557 | //QPalette pal = palette(); |
563 | 558 | ||
564 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 559 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
565 | } | 560 | } |
566 | QPalette MonthViewCell::getPalette () | 561 | QPalette MonthViewCell::getPalette () |
567 | { | 562 | { |
568 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 563 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
569 | return mStandardPalette; | 564 | return mStandardPalette; |
570 | if ( mHoliday) { | 565 | if ( mHoliday) { |
571 | return mHolidayPalette ; | 566 | return mHolidayPalette ; |
572 | } else { | 567 | } else { |
573 | if ( mPrimary ) { | 568 | if ( mPrimary ) { |
574 | return mPrimaryPalette ; | 569 | return mPrimaryPalette ; |
575 | } | 570 | } |
576 | } | 571 | } |
577 | return mNonPrimaryPalette; | 572 | return mNonPrimaryPalette; |
578 | } | 573 | } |
579 | bool MonthViewCell::isPrimary() const | 574 | bool MonthViewCell::isPrimary() const |
580 | { | 575 | { |
581 | return mPrimary; | 576 | return mPrimary; |
582 | } | 577 | } |
583 | 578 | ||
584 | void MonthViewCell::setHoliday( bool holiday ) | 579 | void MonthViewCell::setHoliday( bool holiday ) |
585 | { | 580 | { |
586 | mHoliday = holiday; | 581 | mHoliday = holiday; |
587 | //setMyPalette(); | 582 | //setMyPalette(); |
588 | } | 583 | } |
589 | 584 | ||
590 | void MonthViewCell::setHoliday( const QString &holiday ) | 585 | void MonthViewCell::setHoliday( const QString &holiday ) |
591 | { | 586 | { |
592 | mHolidayString = holiday; | 587 | mHolidayString = holiday; |
593 | 588 | ||
594 | if ( !holiday.isEmpty() ) { | 589 | if ( !holiday.isEmpty() ) { |
595 | setHoliday( true ); | 590 | setHoliday( true ); |
596 | } | 591 | } |
597 | } | 592 | } |
598 | 593 | ||
599 | void MonthViewCell::startUpdateCell() | 594 | void MonthViewCell::startUpdateCell() |
600 | { | 595 | { |
601 | mdayCount = 0; | 596 | mdayCount = 0; |
602 | setFocusPolicy(NoFocus); | 597 | setFocusPolicy(NoFocus); |
603 | if ( !mMonthView->isUpdatePossible() ) | 598 | if ( !mMonthView->isUpdatePossible() ) |
604 | return; | 599 | return; |
605 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 600 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
606 | while ( mitem ) { | 601 | while ( mitem ) { |
607 | mitem->setBlockRepaint( true ); | 602 | mitem->setBlockRepaint( true ); |
608 | mitem = (MonthViewItem *)mitem->next(); | 603 | mitem = (MonthViewItem *)mitem->next(); |
609 | } | 604 | } |
610 | if ( mAvailItemList.count() > 20 ) { | 605 | if ( mAvailItemList.count() > 20 ) { |
611 | mAvailItemList.setAutoDelete( true ); | 606 | mAvailItemList.setAutoDelete( true ); |
612 | mAvailItemList.clear(); | 607 | mAvailItemList.clear(); |
613 | mAvailItemList.setAutoDelete( false ); | 608 | mAvailItemList.setAutoDelete( false ); |
614 | } | 609 | } |
615 | /* | 610 | |
616 | if ( !isVisible() ){ | ||
617 | return; | ||
618 | } | ||
619 | */ | ||
620 | // qDebug("MonthViewCell::updateCell() "); | ||
621 | setPrimary( mDate.month()%2 ); | 611 | setPrimary( mDate.month()%2 ); |
622 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 612 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
623 | if ( mDate == QDate::currentDate() ) { | 613 | if ( mDate == QDate::currentDate() ) { |
624 | setLineWidth( 3 ); | 614 | setLineWidth( 3 ); |
625 | } else { | 615 | } else { |
626 | setLineWidth( 1 ); | 616 | setLineWidth( 1 ); |
627 | } | 617 | } |
628 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 618 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
629 | //clear(); | 619 | //clear(); |
630 | while ( CurrentAvailItem ) { | 620 | while ( CurrentAvailItem ) { |
631 | MonthViewItem *item = CurrentAvailItem; | 621 | MonthViewItem *item = CurrentAvailItem; |
632 | CurrentAvailItem = (MonthViewItem *)item->next(); | 622 | CurrentAvailItem = (MonthViewItem *)item->next(); |
633 | mAvailItemList.append( item ); | 623 | mAvailItemList.append( item ); |
634 | takeItem ( item ); | 624 | takeItem ( item ); |
635 | } | 625 | } |
636 | 626 | ||
637 | #ifdef DESKTOP_VERSION | 627 | #ifdef DESKTOP_VERSION |
638 | QToolTip::remove(this); | 628 | QToolTip::remove(this); |
639 | #endif | 629 | #endif |
640 | mToolTip.clear(); | 630 | mToolTip.clear(); |
641 | //qApp->processEvents(); | 631 | //qApp->processEvents(); |
642 | #if 0 | 632 | #if 0 |
643 | if ( !mHolidayString.isEmpty() ) { | 633 | if ( !mHolidayString.isEmpty() ) { |
644 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 634 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
645 | item->setPalette( mHolidayPalette ); | 635 | item->setPalette( mHolidayPalette ); |
646 | insertItem( item ); | 636 | insertItem( item ); |
647 | mToolTip.append ( mHolidayString ); | 637 | mToolTip.append ( mHolidayString ); |
648 | } | 638 | } |
649 | #endif | 639 | #endif |
650 | } | 640 | } |
651 | 641 | ||
652 | int MonthViewCell::insertEvent(Event *event) | 642 | int MonthViewCell::insertEvent(Event *event) |
653 | { | 643 | { |
654 | bool useToolTips = true; | 644 | bool useToolTips = true; |
655 | #ifndef DESKTOP_VERSION | 645 | #ifndef DESKTOP_VERSION |
656 | useToolTips = false; | 646 | useToolTips = false; |
657 | #endif | 647 | #endif |
658 | QString mToolTipText; | 648 | QString mToolTipText; |
659 | setFocusPolicy(WheelFocus); | 649 | setFocusPolicy(WheelFocus); |
660 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 650 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
661 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 651 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
662 | return mdayCount; | 652 | return mdayCount; |
663 | else | 653 | else |
664 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 654 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
665 | return mdayCount; | 655 | return mdayCount; |
666 | } | 656 | } |
667 | 657 | ||
668 | if ( event->isHoliday()) { | 658 | if ( event->isHoliday()) { |
669 | setHoliday( true ); | 659 | setHoliday( true ); |
670 | if ( mDate.dayOfWeek() == 7 ) | 660 | if ( mDate.dayOfWeek() == 7 ) |
671 | setLineWidth( 3 ); | 661 | setLineWidth( 3 ); |
672 | } | 662 | } |
673 | QString text; | 663 | QString text; |
674 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 664 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
675 | if (event->isMultiDay()) { | 665 | if (event->isMultiDay()) { |
676 | QString prefix = "<->";multiday = 2; | 666 | QString prefix = "<->";multiday = 2; |
677 | QString time; | 667 | QString time; |
678 | if ( event->doesRecur() ) { | 668 | if ( event->doesRecur() ) { |
679 | if ( event->recursOn( mDate) ) { | 669 | if ( event->recursOn( mDate) ) { |
680 | prefix ="->" ;multiday = 1; | 670 | prefix ="->" ;multiday = 1; |
681 | } | 671 | } |
682 | else { | 672 | else { |
683 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 673 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
684 | if ( event->recursOn( mDate.addDays( -days)) ) { | 674 | if ( event->recursOn( mDate.addDays( -days)) ) { |
685 | prefix ="<-" ;multiday = 3; | 675 | prefix ="<-" ;multiday = 3; |
686 | } | 676 | } |
687 | } | 677 | } |
688 | 678 | ||
689 | } else { | 679 | } else { |
690 | if (mDate == event->dtStart().date()) { | 680 | if (mDate == event->dtStart().date()) { |
691 | prefix ="->" ;multiday = 1; | 681 | prefix ="->" ;multiday = 1; |
692 | } else if (mDate == event->dtEnd().date()) { | 682 | } else if (mDate == event->dtEnd().date()) { |
693 | prefix ="<-" ;multiday = 3; | 683 | prefix ="<-" ;multiday = 3; |
694 | } | 684 | } |
695 | } | 685 | } |
696 | if ( !event->doesFloat() ) { | 686 | if ( !event->doesFloat() ) { |
697 | if ( mDate == event->dtStart().date () ) | 687 | if ( mDate == event->dtStart().date () ) |
698 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 688 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
699 | else if ( mDate == event->dtEnd().date () ) | 689 | else if ( mDate == event->dtEnd().date () ) |
700 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 690 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
701 | 691 | ||
702 | } | 692 | } |
703 | text = time + event->summary(); | 693 | text = time + event->summary(); |
704 | if ( useToolTips ) | 694 | if ( useToolTips ) |
705 | mToolTipText += prefix + text; | 695 | mToolTipText += prefix + text; |
706 | } else { | 696 | } else { |
707 | if (event->doesFloat()) { | 697 | if (event->doesFloat()) { |
708 | text = event->summary(); | 698 | text = event->summary(); |
709 | if ( useToolTips ) | 699 | if ( useToolTips ) |
710 | mToolTipText += text; | 700 | mToolTipText += text; |
711 | } | 701 | } |
712 | else { | 702 | else { |
713 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 703 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
714 | text += " " + event->summary(); | 704 | text += " " + event->summary(); |
715 | if ( useToolTips ) | 705 | if ( useToolTips ) |
716 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 706 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
717 | } | 707 | } |
718 | } | 708 | } |
719 | if ( useToolTips && ! event->location().isEmpty() ) { | 709 | if ( useToolTips && ! event->location().isEmpty() ) { |
720 | mToolTipText += " (" + event->location() +")"; | 710 | mToolTipText += " (" + event->location() +")"; |
721 | } | 711 | } |
722 | MonthViewItem *item ; | 712 | MonthViewItem *item ; |
723 | 713 | ||
724 | if ( mAvailItemList.count() ) { | 714 | if ( mAvailItemList.count() ) { |
725 | item = mAvailItemList.first(); | 715 | item = mAvailItemList.first(); |
726 | mAvailItemList.remove( item ); | 716 | mAvailItemList.remove( item ); |
727 | item->recycle( event, mDate, text ); | 717 | item->recycle( event, mDate, text ); |
728 | } else { | 718 | } else { |
729 | item = new MonthViewItem( event, mDate, text ); | 719 | item = new MonthViewItem( event, mDate, text ); |
730 | } | 720 | } |
731 | 721 | ||
732 | QPalette pal; | 722 | QPalette pal; |
733 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 723 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
734 | QStringList categories = event->categories(); | 724 | QStringList categories = event->categories(); |
735 | QString cat = categories.first(); | 725 | QString cat = categories.first(); |
736 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 726 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
737 | pal = getPalette(); | 727 | pal = getPalette(); |
738 | if (cat.isEmpty()) { | 728 | if (cat.isEmpty()) { |
739 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 729 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
740 | } else { | 730 | } else { |
741 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 731 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
742 | } | 732 | } |
743 | 733 | ||
744 | } else { | 734 | } else { |
745 | if (cat.isEmpty()) { | 735 | if (cat.isEmpty()) { |
746 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 736 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
747 | } else { | 737 | } else { |
748 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 738 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
749 | } | 739 | } |
750 | } | 740 | } |
751 | 741 | ||
752 | } else { | 742 | } else { |
753 | pal = mStandardPalette ; | 743 | pal = mStandardPalette ; |
754 | } | 744 | } |
755 | item->setPalette( pal ); | 745 | item->setPalette( pal ); |
756 | item->setRecur( event->recurrence()->doesRecur() ); | 746 | item->setRecur( event->recurrence()->doesRecur() ); |
757 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 747 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
758 | item->setMoreInfo( event->description().length() > 0 ); | 748 | item->setMoreInfo( event->description().length() > 0 ); |
759 | #ifdef DESKTOP_VERSION | 749 | #ifdef DESKTOP_VERSION |
760 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 750 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
761 | KOPrefs::instance()->email()); | 751 | KOPrefs::instance()->email()); |
762 | if ( me != 0 ) { | 752 | if ( me != 0 ) { |
763 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 753 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
764 | item->setReply(true && multiday < 2); | 754 | item->setReply(true && multiday < 2); |
765 | else | 755 | else |
766 | item->setReply(false); | 756 | item->setReply(false); |
767 | } else | 757 | } else |
768 | item->setReply(false); | 758 | item->setReply(false); |
769 | #endif | 759 | #endif |
770 | item->setMultiDay( multiday ); | 760 | item->setMultiDay( multiday ); |
771 | if ( multiday ) { | 761 | if ( multiday ) { |
772 | insertItem( item ,mdayCount); | 762 | insertItem( item ,mdayCount); |
773 | ++mdayCount; | 763 | ++mdayCount; |
774 | } else { | 764 | } else { |
775 | uint i; | 765 | uint i; |
776 | int pos = mdayCount; | 766 | int pos = mdayCount; |
777 | for ( i = mdayCount; i < count();++i ) { | 767 | for ( i = mdayCount; i < count();++i ) { |
778 | QListBoxItem* it = this->item ( i ); | 768 | QListBoxItem* it = this->item ( i ); |
779 | if ( text < it->text() ) { | 769 | if ( text < it->text() ) { |
780 | pos = i; | 770 | pos = i; |
781 | break; | 771 | break; |
782 | } | 772 | } |
783 | ++pos; | 773 | ++pos; |
784 | } | 774 | } |
785 | insertItem( item ,pos); | 775 | insertItem( item ,pos); |
786 | } | 776 | } |
787 | if ( useToolTips ) { | 777 | if ( useToolTips ) { |
788 | mToolTip.append( mToolTipText ); | 778 | mToolTip.append( mToolTipText ); |
789 | } | 779 | } |
790 | return mdayCount; | 780 | return mdayCount; |
791 | } | 781 | } |
792 | void MonthViewCell::insertTodo(Todo *todo) | 782 | void MonthViewCell::insertTodo(Todo *todo) |
793 | { | 783 | { |
794 | setFocusPolicy(WheelFocus); | 784 | setFocusPolicy(WheelFocus); |
795 | QString text; | 785 | QString text; |
796 | if (todo->hasDueDate()) { | 786 | if (todo->hasDueDate()) { |
797 | if (!todo->doesFloat()) { | 787 | if (!todo->doesFloat()) { |
798 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 788 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
799 | text += " "; | 789 | text += " "; |
800 | } | 790 | } |
801 | } | 791 | } |
802 | text += todo->summary(); | 792 | text += todo->summary(); |
803 | MonthViewItem *item ; | 793 | MonthViewItem *item ; |
804 | if ( mAvailItemList.count() ) { | 794 | if ( mAvailItemList.count() ) { |
805 | item = mAvailItemList.first(); | 795 | item = mAvailItemList.first(); |
806 | mAvailItemList.remove( item ); | 796 | mAvailItemList.remove( item ); |
807 | item->recycle( todo, mDate, text ); | 797 | item->recycle( todo, mDate, text ); |
808 | } else { | 798 | } else { |
809 | item = new MonthViewItem( todo, mDate, text ); | 799 | item = new MonthViewItem( todo, mDate, text ); |
810 | } | 800 | } |
811 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 801 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
812 | //item->setPalette( mStandardPalette ); | 802 | //item->setPalette( mStandardPalette ); |
813 | QPalette pal; | 803 | QPalette pal; |
814 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 804 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
815 | QStringList categories = todo->categories(); | 805 | QStringList categories = todo->categories(); |
816 | QString cat = categories.first(); | 806 | QString cat = categories.first(); |
817 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 807 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
818 | pal = getPalette(); | 808 | pal = getPalette(); |
819 | if (cat.isEmpty()) { | 809 | if (cat.isEmpty()) { |
820 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 810 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
821 | } else { | 811 | } else { |
822 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 812 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
823 | } | 813 | } |
824 | 814 | ||
825 | } else { | 815 | } else { |
826 | if (cat.isEmpty()) { | 816 | if (cat.isEmpty()) { |
827 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 817 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
828 | } else { | 818 | } else { |
829 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 819 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
830 | } | 820 | } |
831 | } | 821 | } |
832 | 822 | ||
833 | } else { | 823 | } else { |
834 | pal = mStandardPalette ; | 824 | pal = mStandardPalette ; |
835 | } | 825 | } |
836 | item->setPalette( pal ); | 826 | item->setPalette( pal ); |
837 | item->setRecur( todo->recurrence()->doesRecur() ); | 827 | item->setRecur( todo->recurrence()->doesRecur() ); |
838 | item->setAlarm( todo->isAlarmEnabled() ); | 828 | item->setAlarm( todo->isAlarmEnabled() ); |
839 | item->setMoreInfo( todo->description().length() > 0 ); | 829 | item->setMoreInfo( todo->description().length() > 0 ); |
840 | insertItem( item , count()); | 830 | insertItem( item , count()); |
841 | #ifdef DESKTOP_VERSION | 831 | #ifdef DESKTOP_VERSION |
842 | mToolTip.append( text ); | 832 | mToolTip.append( text ); |
843 | #endif | 833 | #endif |
844 | } | 834 | } |
845 | void MonthViewCell::repaintfinishUpdateCell() | 835 | void MonthViewCell::repaintfinishUpdateCell() |
846 | { | 836 | { |
847 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 837 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
848 | while ( mitem ) { | 838 | while ( mitem ) { |
849 | mitem->setBlockRepaint( false ); | 839 | mitem->setBlockRepaint( false ); |
850 | updateItem ( mitem ); | 840 | updateItem ( mitem ); |
851 | mitem = (MonthViewItem *)mitem->next(); | 841 | mitem = (MonthViewItem *)mitem->next(); |
852 | } | 842 | } |
853 | } | 843 | } |
854 | void MonthViewCell::finishUpdateCell() | 844 | void MonthViewCell::finishUpdateCell() |
855 | { | 845 | { |
856 | 846 | ||
857 | 847 | ||
858 | 848 | ||
859 | #ifdef DESKTOP_VERSION | 849 | #ifdef DESKTOP_VERSION |
860 | if (mToolTip.count() > 0 ) { | 850 | if (mToolTip.count() > 0 ) { |
861 | mToolTip.sort(); | 851 | mToolTip.sort(); |
862 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 852 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
863 | } | 853 | } |
864 | #endif | 854 | #endif |
865 | //sort(); | 855 | //sort(); |
866 | //setMyPalette(); | 856 | //setMyPalette(); |
867 | setMyPalette(); | 857 | setMyPalette(); |
868 | 858 | ||
869 | resizeEvent( 0 ); | 859 | resizeEvent( 0 ); |
870 | 860 | ||
871 | } | 861 | } |
872 | void MonthViewCell::updateCell() | 862 | void MonthViewCell::updateCell() |
873 | { | 863 | { |
874 | //qDebug("MonthViewCell::updateCell() "); | ||
875 | if ( !mMonthView->isUpdatePossible() ) | 864 | if ( !mMonthView->isUpdatePossible() ) |
876 | return; | 865 | return; |
877 | startUpdateCell(); | 866 | startUpdateCell(); |
878 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 867 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
879 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 868 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
880 | Event *event; | 869 | Event *event; |
881 | for( event = events.first(); event; event = events.next() ) { // for event | 870 | for( event = events.first(); event; event = events.next() ) { // for event |
882 | insertEvent(event); | 871 | insertEvent(event); |
883 | } | 872 | } |
884 | // insert due todos | 873 | // insert due todos |
885 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 874 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
886 | Todo *todo; | 875 | Todo *todo; |
887 | for(todo = todos.first(); todo; todo = todos.next()) { | 876 | for(todo = todos.first(); todo; todo = todos.next()) { |
888 | insertTodo( todo ); | 877 | insertTodo( todo ); |
889 | } | 878 | } |
890 | finishUpdateCell(); | 879 | finishUpdateCell(); |
891 | // if ( isVisible()) | 880 | // if ( isVisible()) |
892 | //qApp->processEvents(); | 881 | //qApp->processEvents(); |
893 | } | 882 | } |
894 | 883 | ||
895 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 884 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
896 | { | 885 | { |
897 | 886 | ||
898 | if ( bigFont ) { | 887 | if ( bigFont ) { |
899 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 888 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
900 | int ps = fo.pointSize() + 2; | 889 | int ps = fo.pointSize() + 2; |
901 | if ( ps < 18 ) | 890 | if ( ps < 18 ) |
902 | ps += 2; | 891 | ps += 2; |
903 | fo.setPointSize( ps ); | 892 | fo.setPointSize( ps ); |
904 | setFont( fo ); | 893 | setFont( fo ); |
905 | } else | 894 | } else |
906 | setFont( KOPrefs::instance()->mMonthViewFont ); | 895 | setFont( KOPrefs::instance()->mMonthViewFont ); |
907 | 896 | ||
908 | QFontMetrics fm( font() ); | 897 | QFontMetrics fm( font() ); |
909 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 898 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
910 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 899 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
911 | mHolidayPalette = mStandardPalette; | 900 | mHolidayPalette = mStandardPalette; |
912 | mPrimaryPalette = mStandardPalette; | 901 | mPrimaryPalette = mStandardPalette; |
913 | mNonPrimaryPalette = mStandardPalette; | 902 | mNonPrimaryPalette = mStandardPalette; |
914 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 903 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
915 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 904 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
916 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 905 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
917 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 906 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
918 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 907 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
919 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 908 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
920 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 909 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
921 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 910 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
922 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 911 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
923 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 912 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
924 | } | 913 | } |
925 | //updateCell(); | 914 | //updateCell(); |
926 | } | 915 | } |
927 | 916 | ||
928 | void MonthViewCell::enableScrollBars( bool enabled ) | 917 | void MonthViewCell::enableScrollBars( bool enabled ) |
929 | { | 918 | { |
930 | 919 | ||
931 | return; | 920 | return; |
932 | if ( enabled ) { | 921 | if ( enabled ) { |
933 | QListBoxItem *fi = firstItem (); | 922 | QListBoxItem *fi = firstItem (); |
934 | if (fi ) { | 923 | if (fi ) { |
935 | int ihei = fi->height( this ); | 924 | int ihei = fi->height( this ); |
936 | int hei = numRows () * ihei; | 925 | int hei = numRows () * ihei; |
937 | if ( hei < height() - horizontalScrollBar()->height () ) { | 926 | if ( hei < height() - horizontalScrollBar()->height () ) { |
938 | setVScrollBarMode(QScrollView::AlwaysOff); | 927 | setVScrollBarMode(QScrollView::AlwaysOff); |
939 | } | 928 | } |
940 | else | 929 | else |
941 | setVScrollBarMode(QScrollView::Auto); | 930 | setVScrollBarMode(QScrollView::Auto); |
942 | if ( ihei *3 > height() ) { | 931 | if ( ihei *3 > height() ) { |
943 | setHScrollBarMode(QScrollView::AlwaysOff); | 932 | setHScrollBarMode(QScrollView::AlwaysOff); |
944 | } | 933 | } |
945 | else { | 934 | else { |
946 | setHScrollBarMode(QScrollView::Auto); | 935 | setHScrollBarMode(QScrollView::Auto); |
947 | } | 936 | } |
948 | } else { | 937 | } else { |
949 | setVScrollBarMode(QScrollView::Auto); | 938 | setVScrollBarMode(QScrollView::Auto); |
950 | setHScrollBarMode(QScrollView::Auto); | 939 | setHScrollBarMode(QScrollView::Auto); |
951 | } | 940 | } |
952 | } else { | 941 | } else { |
953 | setVScrollBarMode(QScrollView::AlwaysOff); | 942 | setVScrollBarMode(QScrollView::AlwaysOff); |
954 | setHScrollBarMode(QScrollView::AlwaysOff); | 943 | setHScrollBarMode(QScrollView::AlwaysOff); |
955 | } | 944 | } |
956 | } | 945 | } |
957 | 946 | ||
958 | Incidence *MonthViewCell::selectedIncidence() | 947 | Incidence *MonthViewCell::selectedIncidence() |
959 | { | 948 | { |
960 | int index = currentItem(); | 949 | int index = currentItem(); |
961 | if ( index < 0 ) return 0; | 950 | if ( index < 0 ) return 0; |
962 | 951 | ||
963 | MonthViewItem *mitem = | 952 | MonthViewItem *mitem = |
964 | static_cast<MonthViewItem *>( item( index ) ); | 953 | static_cast<MonthViewItem *>( item( index ) ); |
965 | 954 | ||
966 | if ( !mitem ) return 0; | 955 | if ( !mitem ) return 0; |
967 | 956 | ||
968 | return mitem->incidence(); | 957 | return mitem->incidence(); |
969 | } | 958 | } |
970 | 959 | ||
971 | QDate MonthViewCell::selectedIncidenceDate() | 960 | QDate MonthViewCell::selectedIncidenceDate() |
972 | { | 961 | { |
973 | QDate qd; | 962 | QDate qd; |
974 | int index = currentItem(); | 963 | int index = currentItem(); |
975 | if ( index < 0 ) return qd; | 964 | if ( index < 0 ) return qd; |
976 | 965 | ||
977 | MonthViewItem *mitem = | 966 | MonthViewItem *mitem = |
978 | static_cast<MonthViewItem *>( item( index ) ); | 967 | static_cast<MonthViewItem *>( item( index ) ); |
979 | 968 | ||
980 | if ( !mitem ) return qd; | 969 | if ( !mitem ) return qd; |
981 | 970 | ||
982 | return mitem->incidenceDate(); | 971 | return mitem->incidenceDate(); |
983 | } | 972 | } |
984 | 973 | ||
985 | void MonthViewCell::deselect() | 974 | void MonthViewCell::deselect() |
986 | { | 975 | { |
987 | clearSelection(); | 976 | clearSelection(); |
988 | enableScrollBars( false ); | 977 | enableScrollBars( false ); |
989 | // updateCell(); | 978 | // updateCell(); |
990 | } | 979 | } |
991 | void MonthViewCell::select() | 980 | void MonthViewCell::select() |
992 | { | 981 | { |
993 | ;// updateCell(); | 982 | ;// updateCell(); |
994 | } | 983 | } |
995 | 984 | ||
996 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 985 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
997 | { | 986 | { |
998 | if ( !mMonthView->isUpdatePossible() ) | 987 | if ( !mMonthView->isUpdatePossible() ) |
999 | return; | 988 | return; |
1000 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 989 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1001 | deselect(); | 990 | deselect(); |
1002 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 991 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1003 | 992 | ||
1004 | QString text; | 993 | QString text; |
1005 | mLabel->setText( text ); | 994 | mLabel->setText( text ); |
1006 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 995 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1007 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 996 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1008 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 997 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
1009 | mLabel->resize( mLabelBigSize ); | 998 | mLabel->resize( mLabelBigSize ); |
1010 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 999 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1011 | } else { | 1000 | } else { |
1012 | mLabel->resize( mLabelSize ); | 1001 | mLabel->resize( mLabelSize ); |
1013 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1002 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1014 | } | 1003 | } |
1015 | mLabel->setText( text ); | 1004 | mLabel->setText( text ); |
1016 | 1005 | ||
1017 | int size = height() - mLabel->height() - lineWidth()-1; | 1006 | int size = height() - mLabel->height() - lineWidth()-1; |
1018 | //qDebug("LW %d ", lineWidth()); | 1007 | //qDebug("LW %d ", lineWidth()); |
1019 | if ( size > 0 ) | 1008 | if ( size > 0 ) |
1020 | verticalScrollBar()->setMaximumHeight( size ); | 1009 | verticalScrollBar()->setMaximumHeight( size ); |
1021 | size = width() - mLabel->width() -lineWidth()-1; | 1010 | size = width() - mLabel->width() -lineWidth()-1; |
1022 | if ( size > 0 ) | 1011 | if ( size > 0 ) |
1023 | horizontalScrollBar()->setMaximumWidth( size ); | 1012 | horizontalScrollBar()->setMaximumWidth( size ); |
1024 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1013 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1025 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1014 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1026 | // mItemList->resize ( width(), height () ); | 1015 | // mItemList->resize ( width(), height () ); |
1027 | if ( e ) | 1016 | if ( e ) |
1028 | KNoScrollListBox::resizeEvent ( e ); | 1017 | KNoScrollListBox::resizeEvent ( e ); |
1029 | } | 1018 | } |
1030 | 1019 | ||
1031 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1020 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1032 | { | 1021 | { |
1033 | 1022 | ||
1034 | if ( !item ) { | 1023 | if ( !item ) { |
1035 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1024 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1036 | emit newEventSignal( dt ); | 1025 | emit newEventSignal( dt ); |
1037 | return; | 1026 | return; |
1038 | } | 1027 | } |
1039 | 1028 | ||
1040 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1029 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1041 | Incidence *incidence = eventItem->incidence(); | 1030 | Incidence *incidence = eventItem->incidence(); |
1042 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1031 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1043 | } | 1032 | } |
1044 | void MonthViewCell::showDay() | 1033 | void MonthViewCell::showDay() |
1045 | { | 1034 | { |
1046 | emit showDaySignal( date() ); | 1035 | emit showDaySignal( date() ); |
1047 | } | 1036 | } |
1048 | void MonthViewCell::newEvent() | 1037 | void MonthViewCell::newEvent() |
1049 | { | 1038 | { |
1050 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1039 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1051 | emit newEventSignal( dt ); | 1040 | emit newEventSignal( dt ); |
1052 | } | 1041 | } |
1053 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1042 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1054 | { | 1043 | { |
1055 | mMonthView->setSelectedCell( this ); | 1044 | mMonthView->setSelectedCell( this ); |
1056 | qDebug("CELL "); | ||
1057 | if ( item == 0 ) { | 1045 | if ( item == 0 ) { |
1058 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1046 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1059 | emit newEventSignal( dt ); | 1047 | emit newEventSignal( dt ); |
1060 | return; | 1048 | return; |
1061 | } | 1049 | } |
1062 | 1050 | ||
1063 | } | 1051 | } |
1064 | 1052 | ||
1065 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1053 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1066 | { | 1054 | { |
1067 | mMonthView->setPopupCell( this ); | 1055 | mMonthView->setPopupCell( this ); |
1068 | if ( !item ) { | 1056 | if ( !item ) { |
1069 | mMonthView->showContextMenu( 0 ); | 1057 | mMonthView->showContextMenu( 0 ); |
1070 | return; | 1058 | return; |
1071 | } | 1059 | } |
1072 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1060 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1073 | Incidence *incidence = eventItem->incidence(); | 1061 | Incidence *incidence = eventItem->incidence(); |
1074 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1062 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1075 | } | 1063 | } |
1076 | 1064 | ||
1077 | void MonthViewCell::selection( QListBoxItem *item ) | 1065 | void MonthViewCell::selection( QListBoxItem *item ) |
1078 | { | 1066 | { |
1079 | if ( !item ) return; | 1067 | if ( !item ) return; |
1080 | 1068 | ||
1081 | mMonthView->setSelectedCell( this ); | 1069 | mMonthView->setSelectedCell( this ); |
1082 | } | 1070 | } |
1083 | 1071 | ||
1084 | 1072 | ||
1085 | // ******************************************************************************* | 1073 | // ******************************************************************************* |
1086 | // ******************************************************************************* | 1074 | // ******************************************************************************* |
1087 | // ******************************************************************************* | 1075 | // ******************************************************************************* |
1088 | 1076 | ||
1089 | 1077 | ||
1090 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1078 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1091 | : KOEventView( calendar, parent, name ), | 1079 | : KOEventView( calendar, parent, name ), |
1092 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1080 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1093 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1081 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1094 | { | 1082 | { |
1095 | mFlagKeyPressed = false; | 1083 | mFlagKeyPressed = false; |
1096 | mShortDayLabelsM = false; | 1084 | mShortDayLabelsM = false; |
1097 | mShortDayLabelsW = false; | 1085 | mShortDayLabelsW = false; |
1098 | skipResize = false; | 1086 | skipResize = false; |
1099 | clPending = true; | 1087 | clPending = true; |
1100 | mPopupCell = 0; | 1088 | mPopupCell = 0; |
1101 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1089 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1102 | mWidStack = new QWidgetStack( this ); | 1090 | mWidStack = new QWidgetStack( this ); |
1103 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1091 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1104 | mMonthView = new QWidget( mWidStack ); | 1092 | mMonthView = new QWidget( mWidStack ); |
1105 | mWeekView = new QWidget( mWidStack ); | 1093 | mWeekView = new QWidget( mWidStack ); |
1106 | #if QT_VERSION >= 0x030000 | 1094 | #if QT_VERSION >= 0x030000 |
1107 | mWidStack->addWidget(mMonthView ); | 1095 | mWidStack->addWidget(mMonthView ); |
1108 | mWidStack->addWidget(mWeekView ); | 1096 | mWidStack->addWidget(mWeekView ); |
1109 | #else | 1097 | #else |
1110 | mWidStack->addWidget( mMonthView, 1 ); | 1098 | mWidStack->addWidget( mMonthView, 1 ); |
1111 | mWidStack->addWidget( mWeekView , 1 ); | 1099 | mWidStack->addWidget( mWeekView , 1 ); |
1112 | #endif | 1100 | #endif |
1113 | hb->addWidget( mNavigatorBar ); | 1101 | hb->addWidget( mNavigatorBar ); |
1114 | hb->addWidget( mWidStack ); | 1102 | hb->addWidget( mWidStack ); |
1115 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1103 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1116 | updatePossible = false; | 1104 | updatePossible = false; |
1117 | //updatePossible = true; | 1105 | //updatePossible = true; |
1118 | mCells.setAutoDelete( true ); | 1106 | mCells.setAutoDelete( true ); |
1119 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1107 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1120 | mDayLabels.resize( mDaysPerWeek ); | 1108 | mDayLabels.resize( mDaysPerWeek ); |
1121 | mDayLabelsW.resize( mDaysPerWeek ); | 1109 | mDayLabelsW.resize( mDaysPerWeek ); |
1122 | QFont bfont = font(); | 1110 | QFont bfont = font(); |
1123 | if ( QApplication::desktop()->width() < 650 ) { | 1111 | if ( QApplication::desktop()->width() < 650 ) { |
1124 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1112 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1125 | } | 1113 | } |
1126 | bfont.setBold( true ); | 1114 | bfont.setBold( true ); |
1127 | int i; | 1115 | int i; |
1128 | 1116 | ||
1129 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1117 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1130 | QLabel *label = new QLabel( mMonthView ); | 1118 | QLabel *label = new QLabel( mMonthView ); |
1131 | label->setFont(bfont); | 1119 | label->setFont(bfont); |
1132 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1120 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1133 | label->setLineWidth(1); | 1121 | label->setLineWidth(1); |
1134 | label->setAlignment(AlignCenter); | 1122 | label->setAlignment(AlignCenter); |
1135 | mDayLabels.insert( i, label ); | 1123 | mDayLabels.insert( i, label ); |
1136 | label = new QLabel( mWeekView ); | 1124 | label = new QLabel( mWeekView ); |
1137 | label->setFont(bfont); | 1125 | label->setFont(bfont); |
1138 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1126 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1139 | label->setLineWidth(1); | 1127 | label->setLineWidth(1); |
1140 | label->setAlignment(AlignCenter); | 1128 | label->setAlignment(AlignCenter); |
1141 | mDayLabelsW.insert( i, label ); | 1129 | mDayLabelsW.insert( i, label ); |
1142 | } | 1130 | } |
1143 | 1131 | ||
1144 | bfont.setBold( false ); | 1132 | bfont.setBold( false ); |
1145 | mWeekLabels.resize( mNumWeeks+1 ); | 1133 | mWeekLabels.resize( mNumWeeks+1 ); |
1146 | mWeekLabelsW.resize( 2 ); | 1134 | mWeekLabelsW.resize( 2 ); |
1147 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1135 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1148 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1136 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1149 | label->setFocusPolicy(NoFocus); | 1137 | label->setFocusPolicy(NoFocus); |
1150 | label->setFont(bfont); | 1138 | label->setFont(bfont); |
1151 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1139 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1152 | label->setFlat(true); | 1140 | label->setFlat(true); |
1153 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1141 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1154 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1142 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1155 | //label->setLineWidth(1); | 1143 | //label->setLineWidth(1); |
1156 | //label->setAlignment(AlignCenter); | 1144 | //label->setAlignment(AlignCenter); |
1157 | mWeekLabels.insert( i, label ); | 1145 | mWeekLabels.insert( i, label ); |
1158 | } | 1146 | } |
1159 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1147 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1160 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1148 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1161 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1149 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1162 | 1150 | ||
1163 | for( i = 0; i < 1+1; i++ ) { | 1151 | for( i = 0; i < 1+1; i++ ) { |
1164 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1152 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1165 | label->setFocusPolicy(NoFocus); | 1153 | label->setFocusPolicy(NoFocus); |
1166 | label->setFont(bfont); | 1154 | label->setFont(bfont); |
1167 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1155 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1168 | label->setFlat(true); | 1156 | label->setFlat(true); |
1169 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1157 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1170 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1158 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1171 | //label->setLineWidth(1); | 1159 | //label->setLineWidth(1); |
1172 | //label->setAlignment(AlignCenter); | 1160 | //label->setAlignment(AlignCenter); |
1173 | mWeekLabelsW.insert( i, label ); | 1161 | mWeekLabelsW.insert( i, label ); |
1174 | } | 1162 | } |
1175 | mWeekLabelsW[1]->setText( i18n("W")); | 1163 | mWeekLabelsW[1]->setText( i18n("W")); |
1176 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1164 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1177 | 1165 | ||
1178 | 1166 | ||
1179 | int row, col; | 1167 | int row, col; |
1180 | mCells.resize( mNumCells ); | 1168 | mCells.resize( mNumCells ); |
1181 | for( row = 0; row < mNumWeeks; ++row ) { | 1169 | for( row = 0; row < mNumWeeks; ++row ) { |
1182 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1170 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1183 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1171 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1184 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1172 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1185 | 1173 | ||
1186 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1174 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1187 | SLOT( defaultAction( Incidence * ) ) ); | 1175 | SLOT( defaultAction( Incidence * ) ) ); |
1188 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1176 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1189 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1177 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1190 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1178 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1191 | SIGNAL( showDaySignal( QDate ) ) ); | 1179 | SIGNAL( showDaySignal( QDate ) ) ); |
1192 | connect( cell, SIGNAL( nextCell() ), | 1180 | connect( cell, SIGNAL( nextCell() ), |
1193 | SLOT( nextCell() ) ); | 1181 | SLOT( nextCell() ) ); |
1194 | connect( cell, SIGNAL( prevCell() ), | 1182 | connect( cell, SIGNAL( prevCell() ), |
1195 | SLOT( prevCell() ) ); | 1183 | SLOT( prevCell() ) ); |
1196 | } | 1184 | } |
1197 | } | 1185 | } |
1198 | mCellsW.resize( mDaysPerWeek ); | 1186 | mCellsW.resize( mDaysPerWeek ); |
1199 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1187 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1200 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1188 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1201 | mCellsW.insert( col, cell ); | 1189 | mCellsW.insert( col, cell ); |
1202 | 1190 | ||
1203 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1191 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1204 | SLOT( defaultAction( Incidence * ) ) ); | 1192 | SLOT( defaultAction( Incidence * ) ) ); |
1205 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1193 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1206 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1194 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1207 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1195 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1208 | SIGNAL( showDaySignal( QDate ) ) ); | 1196 | SIGNAL( showDaySignal( QDate ) ) ); |
1209 | connect( cell, SIGNAL( nextCell() ), | 1197 | connect( cell, SIGNAL( nextCell() ), |
1210 | SLOT( nextCell() ) ); | 1198 | SLOT( nextCell() ) ); |
1211 | connect( cell, SIGNAL( prevCell() ), | 1199 | connect( cell, SIGNAL( prevCell() ), |
1212 | SLOT( prevCell() ) ); | 1200 | SLOT( prevCell() ) ); |
1213 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1201 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1214 | } | 1202 | } |
1215 | 1203 | ||
1216 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1204 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1217 | mContextMenu = eventPopup(); | 1205 | mContextMenu = eventPopup(); |
1218 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1206 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1219 | i18n("New Event..."),this, | 1207 | i18n("New Event..."),this, |
1220 | SLOT(slotNewEvent()),false); | 1208 | SLOT(slotNewEvent()),false); |
1221 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1209 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1222 | i18n("New Todo..."),this, | 1210 | i18n("New Todo..."),this, |
1223 | SLOT(slotNewTodo()),false); | 1211 | SLOT(slotNewTodo()),false); |
1224 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1212 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1225 | i18n("Journal"),this, | 1213 | i18n("Journal"),this, |
1226 | SLOT(slotEditJournal()),false); | 1214 | SLOT(slotEditJournal()),false); |
1227 | 1215 | ||
1228 | 1216 | ||
1229 | 1217 | ||
1230 | QString pathString = ""; | 1218 | QString pathString = ""; |
1231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1219 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1232 | if ( QApplication::desktop()->width() < 480 ) | 1220 | if ( QApplication::desktop()->width() < 480 ) |
1233 | pathString += "icons16/"; | 1221 | pathString += "icons16/"; |
1234 | } else | 1222 | } else |
1235 | pathString += "iconsmini/"; | 1223 | pathString += "iconsmini/"; |
1236 | mNewItemMenu = new QPopupMenu( this ); | 1224 | mNewItemMenu = new QPopupMenu( this ); |
1237 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1225 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1238 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1226 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1239 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1227 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1240 | 1228 | ||
1241 | // updateConfig(); //useless here... | 1229 | // updateConfig(); //useless here... |
1242 | // ... but we need mWidthLongDayLabel computed | 1230 | // ... but we need mWidthLongDayLabel computed |
1243 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1231 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1244 | mWidthLongDayLabel = 0; | 1232 | mWidthLongDayLabel = 0; |
1245 | for (int i = 0; i < 7; i++) { | 1233 | for (int i = 0; i < 7; i++) { |
1246 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1234 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1247 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1235 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1248 | } | 1236 | } |
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro index 1a81c7d..d88c300 100644 --- a/korganizer/korganizer.pro +++ b/korganizer/korganizer.pro | |||
@@ -1,210 +1,208 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | TARGET = kopi | 3 | TARGET = kopi |
4 | OBJECTS_DIR = _obj/ | 4 | OBJECTS_DIR = _obj/ |
5 | MOC_DIR = _moc | 5 | MOC_DIR = _moc |
6 | DESTDIR= ../bin | 6 | DESTDIR= ../bin |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim | 10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim |
11 | #../qtcompat | 11 | #../qtcompat |
12 | DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 12 | DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
14 | #KORG_NOPRINTER KORG_NOKABC KORG_NODND | 14 | #KORG_NOPRINTER KORG_NOKABC KORG_NODND |
15 | DEFINES += KORG_NOLVALTERNATION | 15 | DEFINES += KORG_NOLVALTERNATION |
16 | DEFINES += DESKTOP_VERSION | 16 | DEFINES += DESKTOP_VERSION |
17 | unix : { | 17 | unix : { |
18 | staticlib: { | 18 | staticlib: { |
19 | LIBS += ../bin/libmicrokabc_qtopia.a | 19 | LIBS += ../bin/libmicrokabc_qtopia.a |
20 | LIBS += ../bin/libmicrokabc_file.a | 20 | LIBS += ../bin/libmicrokabc_file.a |
21 | LIBS += ../bin/libmicrokabc_dir.a | 21 | LIBS += ../bin/libmicrokabc_dir.a |
22 | LIBS += ../bin/libmicrokdepim.a | 22 | LIBS += ../bin/libmicrokdepim.a |
23 | LIBS += ../bin/libmicrokcal.a | 23 | LIBS += ../bin/libmicrokcal.a |
24 | LIBS += ../bin/libmicrokabc.a | 24 | LIBS += ../bin/libmicrokabc.a |
25 | LIBS += ../bin/libmicrokde.a | 25 | LIBS += ../bin/libmicrokde.a |
26 | LIBS += ../bin/libmicrokabc_qtopia.a | 26 | LIBS += ../bin/libmicrokabc_qtopia.a |
27 | LIBS += ../bin/libmicrokabc_file.a | 27 | LIBS += ../bin/libmicrokabc_file.a |
28 | LIBS += ../bin/libmicrokabc_dir.a | 28 | LIBS += ../bin/libmicrokabc_dir.a |
29 | LIBS += ../bin/libmicrokdepim.a | 29 | LIBS += ../bin/libmicrokdepim.a |
30 | LIBS += ../bin/libmicrokcal.a | 30 | LIBS += ../bin/libmicrokcal.a |
31 | LIBS += ../bin/libmicrokabc.a | 31 | LIBS += ../bin/libmicrokabc.a |
32 | LIBS += ../bin/libmicrokde.a | 32 | LIBS += ../bin/libmicrokde.a |
33 | LIBS += ../libical/lib/libical.a | 33 | LIBS += ../libical/lib/libical.a |
34 | LIBS += ../libical/lib/libicalss.a | 34 | LIBS += ../libical/lib/libicalss.a |
35 | } else { | 35 | } else { |
36 | LIBS += ../bin/libmicrokdepim.so | 36 | LIBS += ../bin/libmicrokdepim.so |
37 | LIBS += ../bin/libmicrokcal.so | 37 | LIBS += ../bin/libmicrokcal.so |
38 | LIBS += ../bin/libmicrokde.so | 38 | LIBS += ../bin/libmicrokde.so |
39 | LIBS += ../bin/libmicrokabc.so | 39 | LIBS += ../bin/libmicrokabc.so |
40 | #LIBS += -lbluetooth | 40 | #LIBS += -lbluetooth |
41 | #LIBS += -lsdp | 41 | #LIBS += -lsdp |
42 | 42 | ||
43 | #LIBS += -lldap | 43 | #LIBS += -lldap |
44 | } | 44 | } |
45 | OBJECTS_DIR = obj/unix | 45 | OBJECTS_DIR = obj/unix |
46 | MOC_DIR = moc/unix | 46 | MOC_DIR = moc/unix |
47 | } | 47 | } |
48 | win32: { | 48 | win32: { |
49 | RC_FILE = winicons.rc | 49 | RC_FILE = winicons.rc |
50 | DEFINES += _WIN32_ | 50 | DEFINES += _WIN32_ |
51 | LIBS += ../bin/microkdepim.lib | 51 | LIBS += ../bin/microkdepim.lib |
52 | LIBS += ../bin/microkcal.lib | 52 | LIBS += ../bin/microkcal.lib |
53 | LIBS += ../bin/microkde.lib | 53 | LIBS += ../bin/microkde.lib |
54 | LIBS += ../bin/microkabc.lib | 54 | LIBS += ../bin/microkabc.lib |
55 | LIBS += ../libical/lib/ical.lib | 55 | LIBS += ../libical/lib/ical.lib |
56 | LIBS += ../libical/lib/icalss.lib | 56 | LIBS += ../libical/lib/icalss.lib |
57 | #LIBS += atls.lib | 57 | #LIBS += atls.lib |
58 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 58 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
59 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT | 59 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT |
60 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib | 60 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib |
61 | OBJECTS_DIR = obj/win | 61 | OBJECTS_DIR = obj/win |
62 | MOC_DIR = moc/win | 62 | MOC_DIR = moc/win |
63 | #olimport section | 63 | #olimport section |
64 | #blabla: { | 64 | #blabla: { |
65 | LIBS += mfc71u.lib | 65 | LIBS += mfc71u.lib |
66 | DEFINES += _OL_IMPORT_ | 66 | DEFINES += _OL_IMPORT_ |
67 | 67 | ||
68 | HEADERS += ../outport/msoutl9.h \ | 68 | HEADERS += ../outport/msoutl9.h \ |
69 | koimportoldialog.h | 69 | koimportoldialog.h |
70 | SOURCES += ../outport/msoutl9.cpp \ | 70 | SOURCES += ../outport/msoutl9.cpp \ |
71 | koimportoldialog.cpp | 71 | koimportoldialog.cpp |
72 | #} | 72 | #} |
73 | #olimport section end | 73 | #olimport section end |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | INTERFACES = kofilterview_base.ui | 78 | INTERFACES = kofilterview_base.ui |
79 | #filteredit_base.ui | 79 | #filteredit_base.ui |
80 | 80 | ||
81 | # kdateedit.h \ | 81 | # kdateedit.h \ |
82 | 82 | ||
83 | HEADERS += datenavigatorcontainer.h \ | 83 | HEADERS += datenavigatorcontainer.h \ |
84 | filteredit_base.h \ | 84 | filteredit_base.h \ |
85 | alarmclient.h \ | 85 | alarmclient.h \ |
86 | calendarview.h \ | 86 | calendarview.h \ |
87 | customlistviewitem.h \ | 87 | customlistviewitem.h \ |
88 | datenavigator.h \ | 88 | datenavigator.h \ |
89 | docprefs.h \ | 89 | docprefs.h \ |
90 | filtereditdialog.h \ | 90 | filtereditdialog.h \ |
91 | incomingdialog.h \ | 91 | incomingdialog.h \ |
92 | incomingdialog_base.h \ | 92 | incomingdialog_base.h \ |
93 | interfaces/korganizer/baseview.h \ | 93 | interfaces/korganizer/baseview.h \ |
94 | interfaces/korganizer/calendarviewbase.h \ | 94 | interfaces/korganizer/calendarviewbase.h \ |
95 | journalentry.h \ | 95 | journalentry.h \ |
96 | kdatenavigator.h \ | 96 | kdatenavigator.h \ |
97 | koagenda.h \ | 97 | koagenda.h \ |
98 | koagendaitem.h \ | 98 | koagendaitem.h \ |
99 | koagendaview.h \ | 99 | koagendaview.h \ |
100 | kocounterdialog.h \ | 100 | kocounterdialog.h \ |
101 | kodaymatrix.h \ | 101 | kodaymatrix.h \ |
102 | kodialogmanager.h \ | 102 | kodialogmanager.h \ |
103 | koeditordetails.h \ | 103 | koeditordetails.h \ |
104 | koeditorgeneral.h \ | 104 | koeditorgeneral.h \ |
105 | koeditorgeneralevent.h \ | 105 | koeditorgeneralevent.h \ |
106 | koeditorgeneraltodo.h \ | 106 | koeditorgeneraltodo.h \ |
107 | koeditorrecurrence.h \ | 107 | koeditorrecurrence.h \ |
108 | koeventeditor.h \ | 108 | koeventeditor.h \ |
109 | koeventpopupmenu.h \ | 109 | koeventpopupmenu.h \ |
110 | koeventview.h \ | 110 | koeventview.h \ |
111 | koeventviewer.h \ | 111 | koeventviewer.h \ |
112 | koeventviewerdialog.h \ | 112 | koeventviewerdialog.h \ |
113 | kofilterview.h \ | 113 | kofilterview.h \ |
114 | koglobals.h \ | 114 | koglobals.h \ |
115 | koincidenceeditor.h \ | 115 | koincidenceeditor.h \ |
116 | kojournalview.h \ | 116 | kojournalview.h \ |
117 | kolistview.h \ | 117 | kolistview.h \ |
118 | kolocationbox.h \ | 118 | kolocationbox.h \ |
119 | komonthview.h \ | 119 | komonthview.h \ |
120 | koprefs.h \ | 120 | koprefs.h \ |
121 | koprefsdialog.h \ | 121 | koprefsdialog.h \ |
122 | kotimespanview.h \ | 122 | kotimespanview.h \ |
123 | kotodoeditor.h \ | 123 | kotodoeditor.h \ |
124 | kotodoview.h \ | 124 | kotodoview.h \ |
125 | kotodoviewitem.h \ | 125 | kotodoviewitem.h \ |
126 | koviewmanager.h \ | 126 | koviewmanager.h \ |
127 | kowhatsnextview.h \ | 127 | kowhatsnextview.h \ |
128 | ktimeedit.h \ | 128 | ktimeedit.h \ |
129 | lineview.h \ | 129 | lineview.h \ |
130 | mainwindow.h \ | 130 | mainwindow.h \ |
131 | navigatorbar.h \ | 131 | navigatorbar.h \ |
132 | outgoingdialog.h \ | 132 | outgoingdialog.h \ |
133 | outgoingdialog_base.h \ | 133 | outgoingdialog_base.h \ |
134 | publishdialog.h \ | 134 | publishdialog.h \ |
135 | publishdialog_base.h \ | 135 | publishdialog_base.h \ |
136 | savetemplatedialog.h \ | 136 | savetemplatedialog.h \ |
137 | searchdialog.h \ | 137 | searchdialog.h \ |
138 | simplealarmclient.h \ | ||
139 | statusdialog.h \ | 138 | statusdialog.h \ |
140 | timeline.h \ | 139 | timeline.h \ |
141 | timespanview.h \ | 140 | timespanview.h \ |
142 | version.h \ | 141 | version.h \ |
143 | ../kalarmd/alarmdialog.h \ | 142 | ../kalarmd/alarmdialog.h \ |
144 | 143 | ||
145 | 144 | ||
146 | SOURCES += datenavigatorcontainer.cpp \ | 145 | SOURCES += datenavigatorcontainer.cpp \ |
147 | filteredit_base.cpp \ | 146 | filteredit_base.cpp \ |
148 | calendarview.cpp \ | 147 | calendarview.cpp \ |
149 | datenavigator.cpp \ | 148 | datenavigator.cpp \ |
150 | docprefs.cpp \ | 149 | docprefs.cpp \ |
151 | filtereditdialog.cpp \ | 150 | filtereditdialog.cpp \ |
152 | incomingdialog.cpp \ | 151 | incomingdialog.cpp \ |
153 | incomingdialog_base.cpp \ | 152 | incomingdialog_base.cpp \ |
154 | journalentry.cpp \ | 153 | journalentry.cpp \ |
155 | kdatenavigator.cpp \ | 154 | kdatenavigator.cpp \ |
156 | koagenda.cpp \ | 155 | koagenda.cpp \ |
157 | koagendaitem.cpp \ | 156 | koagendaitem.cpp \ |
158 | koagendaview.cpp \ | 157 | koagendaview.cpp \ |
159 | kocounterdialog.cpp \ | 158 | kocounterdialog.cpp \ |
160 | kodaymatrix.cpp \ | 159 | kodaymatrix.cpp \ |
161 | kodialogmanager.cpp \ | 160 | kodialogmanager.cpp \ |
162 | koeditordetails.cpp \ | 161 | koeditordetails.cpp \ |
163 | koeditorgeneral.cpp \ | 162 | koeditorgeneral.cpp \ |
164 | koeditorgeneralevent.cpp \ | 163 | koeditorgeneralevent.cpp \ |
165 | koeditorgeneraltodo.cpp \ | 164 | koeditorgeneraltodo.cpp \ |
166 | koeditorrecurrence.cpp \ | 165 | koeditorrecurrence.cpp \ |
167 | koeventeditor.cpp \ | 166 | koeventeditor.cpp \ |
168 | koeventpopupmenu.cpp \ | 167 | koeventpopupmenu.cpp \ |
169 | koeventview.cpp \ | 168 | koeventview.cpp \ |
170 | koeventviewer.cpp \ | 169 | koeventviewer.cpp \ |
171 | koeventviewerdialog.cpp \ | 170 | koeventviewerdialog.cpp \ |
172 | kofilterview.cpp \ | 171 | kofilterview.cpp \ |
173 | koglobals.cpp \ | 172 | koglobals.cpp \ |
174 | koincidenceeditor.cpp \ | 173 | koincidenceeditor.cpp \ |
175 | kojournalview.cpp \ | 174 | kojournalview.cpp \ |
176 | kolistview.cpp \ | 175 | kolistview.cpp \ |
177 | kolocationbox.cpp \ | 176 | kolocationbox.cpp \ |
178 | komonthview.cpp \ | 177 | komonthview.cpp \ |
179 | koprefs.cpp \ | 178 | koprefs.cpp \ |
180 | koprefsdialog.cpp \ | 179 | koprefsdialog.cpp \ |
181 | kotimespanview.cpp \ | 180 | kotimespanview.cpp \ |
182 | kotodoeditor.cpp \ | 181 | kotodoeditor.cpp \ |
183 | kotodoview.cpp \ | 182 | kotodoview.cpp \ |
184 | kotodoviewitem.cpp \ | 183 | kotodoviewitem.cpp \ |
185 | koviewmanager.cpp \ | 184 | koviewmanager.cpp \ |
186 | kowhatsnextview.cpp \ | 185 | kowhatsnextview.cpp \ |
187 | ktimeedit.cpp \ | 186 | ktimeedit.cpp \ |
188 | lineview.cpp \ | 187 | lineview.cpp \ |
189 | main.cpp \ | 188 | main.cpp \ |
190 | mainwindow.cpp \ | 189 | mainwindow.cpp \ |
191 | navigatorbar.cpp \ | 190 | navigatorbar.cpp \ |
192 | outgoingdialog.cpp \ | 191 | outgoingdialog.cpp \ |
193 | outgoingdialog_base.cpp \ | 192 | outgoingdialog_base.cpp \ |
194 | publishdialog.cpp \ | 193 | publishdialog.cpp \ |
195 | publishdialog_base.cpp \ | 194 | publishdialog_base.cpp \ |
196 | savetemplatedialog.cpp \ | 195 | savetemplatedialog.cpp \ |
197 | searchdialog.cpp \ | 196 | searchdialog.cpp \ |
198 | simplealarmclient.cpp \ | ||
199 | statusdialog.cpp \ | 197 | statusdialog.cpp \ |
200 | timeline.cpp \ | 198 | timeline.cpp \ |
201 | timespanview.cpp \ | 199 | timespanview.cpp \ |
202 | ../kalarmd/alarmdialog.cpp | 200 | ../kalarmd/alarmdialog.cpp |
203 | 201 | ||
204 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h | 202 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h |
205 | INTERFACES += calprintdayconfig_base.ui \ | 203 | INTERFACES += calprintdayconfig_base.ui \ |
206 | calprintmonthconfig_base.ui \ | 204 | calprintmonthconfig_base.ui \ |
207 | calprinttodoconfig_base.ui \ | 205 | calprinttodoconfig_base.ui \ |
208 | calprintweekconfig_base.ui | 206 | calprintweekconfig_base.ui |
209 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp | 207 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp |
210 | 208 | ||
diff --git a/korganizer/korganizerE.pro b/korganizer/korganizerE.pro index 91b5a01..553c265 100644 --- a/korganizer/korganizerE.pro +++ b/korganizer/korganizerE.pro | |||
@@ -1,152 +1,150 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = kopi | 3 | TARGET = kopi |
4 | OBJECTS_DIR = obj/$(PLATFORM) | 4 | OBJECTS_DIR = obj/$(PLATFORM) |
5 | MOC_DIR = moc/$(PLATFORM) | 5 | MOC_DIR = moc/$(PLATFORM) |
6 | DESTDIR=$(QPEDIR)/bin | 6 | DESTDIR=$(QPEDIR)/bin |
7 | 7 | ||
8 | INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include | 8 | INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kdeui $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/libkdepim interfaces $(KDEPIMDIR)/kabc $(QPEDIR)/include |
9 | 9 | ||
10 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 10 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
11 | DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 11 | DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
12 | DEFINES += KORG_NOLVALTERNATION | 12 | DEFINES += KORG_NOLVALTERNATION |
13 | #KORG_NOKABC | 13 | #KORG_NOKABC |
14 | LIBS += -lmicrokdepim | 14 | LIBS += -lmicrokdepim |
15 | LIBS += -lmicrokcal | 15 | LIBS += -lmicrokcal |
16 | LIBS += -lmicrokde | 16 | LIBS += -lmicrokde |
17 | LIBS += -lmicroqtcompat | 17 | LIBS += -lmicroqtcompat |
18 | 18 | ||
19 | LIBS += $(GCC3EXTRALIB1) | 19 | LIBS += $(GCC3EXTRALIB1) |
20 | LIBS += $(GCC3EXTRALIB2) | 20 | LIBS += $(GCC3EXTRALIB2) |
21 | 21 | ||
22 | 22 | ||
23 | LIBS += -lqpe | 23 | LIBS += -lqpe |
24 | LIBS += -ljpeg | 24 | LIBS += -ljpeg |
25 | LIBS += $(QTOPIALIB) | 25 | LIBS += $(QTOPIALIB) |
26 | LIBS += -L$(QPEDIR)/lib | 26 | LIBS += -L$(QPEDIR)/lib |
27 | 27 | ||
28 | INTERFACES = kofilterview_base.ui | 28 | INTERFACES = kofilterview_base.ui |
29 | #filteredit_base.ui | 29 | #filteredit_base.ui |
30 | 30 | ||
31 | HEADERS = datenavigatorcontainer.h \ | 31 | HEADERS = datenavigatorcontainer.h \ |
32 | wordsgerman.h \ | 32 | wordsgerman.h \ |
33 | filteredit_base.h \ | 33 | filteredit_base.h \ |
34 | alarmclient.h \ | 34 | alarmclient.h \ |
35 | calendarview.h \ | 35 | calendarview.h \ |
36 | customlistviewitem.h \ | 36 | customlistviewitem.h \ |
37 | datenavigator.h \ | 37 | datenavigator.h \ |
38 | docprefs.h \ | 38 | docprefs.h \ |
39 | filtereditdialog.h \ | 39 | filtereditdialog.h \ |
40 | incomingdialog.h \ | 40 | incomingdialog.h \ |
41 | incomingdialog_base.h \ | 41 | incomingdialog_base.h \ |
42 | interfaces/korganizer/baseview.h \ | 42 | interfaces/korganizer/baseview.h \ |
43 | interfaces/korganizer/calendarviewbase.h \ | 43 | interfaces/korganizer/calendarviewbase.h \ |
44 | journalentry.h \ | 44 | journalentry.h \ |
45 | kdateedit.h \ | 45 | kdateedit.h \ |
46 | kdatenavigator.h \ | 46 | kdatenavigator.h \ |
47 | koagenda.h \ | 47 | koagenda.h \ |
48 | koagendaitem.h \ | 48 | koagendaitem.h \ |
49 | koagendaview.h \ | 49 | koagendaview.h \ |
50 | kocounterdialog.h \ | 50 | kocounterdialog.h \ |
51 | kodaymatrix.h \ | 51 | kodaymatrix.h \ |
52 | kodialogmanager.h \ | 52 | kodialogmanager.h \ |
53 | koeditordetails.h \ | 53 | koeditordetails.h \ |
54 | koeditorgeneral.h \ | 54 | koeditorgeneral.h \ |
55 | koeditorgeneralevent.h \ | 55 | koeditorgeneralevent.h \ |
56 | koeditorgeneraltodo.h \ | 56 | koeditorgeneraltodo.h \ |
57 | koeditorrecurrence.h \ | 57 | koeditorrecurrence.h \ |
58 | koeventeditor.h \ | 58 | koeventeditor.h \ |
59 | koeventpopupmenu.h \ | 59 | koeventpopupmenu.h \ |
60 | koeventview.h \ | 60 | koeventview.h \ |
61 | koeventviewer.h \ | 61 | koeventviewer.h \ |
62 | koeventviewerdialog.h \ | 62 | koeventviewerdialog.h \ |
63 | kofilterview.h \ | 63 | kofilterview.h \ |
64 | koglobals.h \ | 64 | koglobals.h \ |
65 | koincidenceeditor.h \ | 65 | koincidenceeditor.h \ |
66 | kojournalview.h \ | 66 | kojournalview.h \ |
67 | kolistview.h \ | 67 | kolistview.h \ |
68 | kolocationbox.h \ | 68 | kolocationbox.h \ |
69 | komonthview.h \ | 69 | komonthview.h \ |
70 | koprefs.h \ | 70 | koprefs.h \ |
71 | koprefsdialog.h \ | 71 | koprefsdialog.h \ |
72 | kotimespanview.h \ | 72 | kotimespanview.h \ |
73 | kotodoeditor.h \ | 73 | kotodoeditor.h \ |
74 | kotodoview.h \ | 74 | kotodoview.h \ |
75 | kotodoviewitem.h \ | 75 | kotodoviewitem.h \ |
76 | koviewmanager.h \ | 76 | koviewmanager.h \ |
77 | kowhatsnextview.h \ | 77 | kowhatsnextview.h \ |
78 | ktimeedit.h \ | 78 | ktimeedit.h \ |
79 | lineview.h \ | 79 | lineview.h \ |
80 | mainwindow.h \ | 80 | mainwindow.h \ |
81 | navigatorbar.h \ | 81 | navigatorbar.h \ |
82 | outgoingdialog.h \ | 82 | outgoingdialog.h \ |
83 | outgoingdialog_base.h \ | 83 | outgoingdialog_base.h \ |
84 | publishdialog.h \ | 84 | publishdialog.h \ |
85 | publishdialog_base.h \ | 85 | publishdialog_base.h \ |
86 | savetemplatedialog.h \ | 86 | savetemplatedialog.h \ |
87 | searchdialog.h \ | 87 | searchdialog.h \ |
88 | simplealarmclient.h \ | ||
89 | statusdialog.h \ | 88 | statusdialog.h \ |
90 | timeline.h \ | 89 | timeline.h \ |
91 | timespanview.h \ | 90 | timespanview.h \ |
92 | version.h \ | 91 | version.h \ |
93 | ../kalarmd/alarmdialog.h | 92 | ../kalarmd/alarmdialog.h |
94 | 93 | ||
95 | SOURCES = datenavigatorcontainer.cpp \ | 94 | SOURCES = datenavigatorcontainer.cpp \ |
96 | filteredit_base.cpp \ | 95 | filteredit_base.cpp \ |
97 | calendarview.cpp \ | 96 | calendarview.cpp \ |
98 | datenavigator.cpp \ | 97 | datenavigator.cpp \ |
99 | docprefs.cpp \ | 98 | docprefs.cpp \ |
100 | filtereditdialog.cpp \ | 99 | filtereditdialog.cpp \ |
101 | incomingdialog.cpp \ | 100 | incomingdialog.cpp \ |
102 | incomingdialog_base.cpp \ | 101 | incomingdialog_base.cpp \ |
103 | journalentry.cpp \ | 102 | journalentry.cpp \ |
104 | kdatenavigator.cpp \ | 103 | kdatenavigator.cpp \ |
105 | koagenda.cpp \ | 104 | koagenda.cpp \ |
106 | koagendaitem.cpp \ | 105 | koagendaitem.cpp \ |
107 | koagendaview.cpp \ | 106 | koagendaview.cpp \ |
108 | kocounterdialog.cpp \ | 107 | kocounterdialog.cpp \ |
109 | kodaymatrix.cpp \ | 108 | kodaymatrix.cpp \ |
110 | kodialogmanager.cpp \ | 109 | kodialogmanager.cpp \ |
111 | koeditordetails.cpp \ | 110 | koeditordetails.cpp \ |
112 | koeditorgeneral.cpp \ | 111 | koeditorgeneral.cpp \ |
113 | koeditorgeneralevent.cpp \ | 112 | koeditorgeneralevent.cpp \ |
114 | koeditorgeneraltodo.cpp \ | 113 | koeditorgeneraltodo.cpp \ |
115 | koeditorrecurrence.cpp \ | 114 | koeditorrecurrence.cpp \ |
116 | koeventeditor.cpp \ | 115 | koeventeditor.cpp \ |
117 | koeventpopupmenu.cpp \ | 116 | koeventpopupmenu.cpp \ |
118 | koeventview.cpp \ | 117 | koeventview.cpp \ |
119 | koeventviewer.cpp \ | 118 | koeventviewer.cpp \ |
120 | koeventviewerdialog.cpp \ | 119 | koeventviewerdialog.cpp \ |
121 | kofilterview.cpp \ | 120 | kofilterview.cpp \ |
122 | koglobals.cpp \ | 121 | koglobals.cpp \ |
123 | koincidenceeditor.cpp \ | 122 | koincidenceeditor.cpp \ |
124 | kojournalview.cpp \ | 123 | kojournalview.cpp \ |
125 | kolistview.cpp \ | 124 | kolistview.cpp \ |
126 | kolocationbox.cpp \ | 125 | kolocationbox.cpp \ |
127 | komonthview.cpp \ | 126 | komonthview.cpp \ |
128 | koprefs.cpp \ | 127 | koprefs.cpp \ |
129 | koprefsdialog.cpp \ | 128 | koprefsdialog.cpp \ |
130 | kotimespanview.cpp \ | 129 | kotimespanview.cpp \ |
131 | kotodoeditor.cpp \ | 130 | kotodoeditor.cpp \ |
132 | kotodoview.cpp \ | 131 | kotodoview.cpp \ |
133 | kotodoviewitem.cpp \ | 132 | kotodoviewitem.cpp \ |
134 | koviewmanager.cpp \ | 133 | koviewmanager.cpp \ |
135 | kowhatsnextview.cpp \ | 134 | kowhatsnextview.cpp \ |
136 | ktimeedit.cpp \ | 135 | ktimeedit.cpp \ |
137 | lineview.cpp \ | 136 | lineview.cpp \ |
138 | main.cpp \ | 137 | main.cpp \ |
139 | mainwindow.cpp \ | 138 | mainwindow.cpp \ |
140 | navigatorbar.cpp \ | 139 | navigatorbar.cpp \ |
141 | outgoingdialog.cpp \ | 140 | outgoingdialog.cpp \ |
142 | outgoingdialog_base.cpp \ | 141 | outgoingdialog_base.cpp \ |
143 | publishdialog.cpp \ | 142 | publishdialog.cpp \ |
144 | publishdialog_base.cpp \ | 143 | publishdialog_base.cpp \ |
145 | savetemplatedialog.cpp \ | 144 | savetemplatedialog.cpp \ |
146 | searchdialog.cpp \ | 145 | searchdialog.cpp \ |
147 | simplealarmclient.cpp \ | ||
148 | statusdialog.cpp \ | 146 | statusdialog.cpp \ |
149 | timeline.cpp \ | 147 | timeline.cpp \ |
150 | timespanview.cpp \ | 148 | timespanview.cpp \ |
151 | ../kalarmd/alarmdialog.cpp | 149 | ../kalarmd/alarmdialog.cpp |
152 | 150 | ||
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index dd2c081..0a608dc 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -519,865 +519,840 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
519 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 519 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
520 | this, SLOT( setAllClose() ),0,7 ); | 520 | this, SLOT( setAllClose() ),0,7 ); |
521 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 521 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
522 | this, SLOT( setAllFlat() ),0,8 ); | 522 | this, SLOT( setAllFlat() ),0,8 ); |
523 | mDocPrefs = new DocPrefs( name ); | 523 | mDocPrefs = new DocPrefs( name ); |
524 | 524 | ||
525 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 525 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
526 | mPopupMenu->setCheckable( true ); | 526 | mPopupMenu->setCheckable( true ); |
527 | mItemPopupMenu->setCheckable( true ); | 527 | mItemPopupMenu->setCheckable( true ); |
528 | 528 | ||
529 | 529 | ||
530 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 530 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
531 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 531 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
532 | 532 | ||
533 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 533 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
534 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 534 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
535 | 535 | ||
536 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 536 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
537 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 537 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
538 | 538 | ||
539 | 539 | ||
540 | // Double clicking conflicts with opening/closing the subtree | 540 | // Double clicking conflicts with opening/closing the subtree |
541 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 541 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
542 | SLOT( editItem( QListViewItem *) ) ); | 542 | SLOT( editItem( QListViewItem *) ) ); |
543 | /* | 543 | /* |
544 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 544 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
545 | const QPoint &,int ) ), | 545 | const QPoint &,int ) ), |
546 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 546 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
547 | */ | 547 | */ |
548 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 548 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
549 | const QPoint &,int ) ), | 549 | const QPoint &,int ) ), |
550 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 550 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
551 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 551 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
552 | SLOT( itemClicked( QListViewItem * ) ) ); | 552 | SLOT( itemClicked( QListViewItem * ) ) ); |
553 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 553 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
554 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 554 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
555 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 555 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
556 | SLOT( updateView() ) ); | 556 | SLOT( updateView() ) ); |
557 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 557 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
558 | SLOT( todoModified(Todo *, int) ) ); | 558 | SLOT( todoModified(Todo *, int) ) ); |
559 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 559 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
560 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 560 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
561 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 561 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
562 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 562 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
563 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 563 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
564 | SLOT( paintNeeded()) ); | 564 | SLOT( paintNeeded()) ); |
565 | 565 | ||
566 | #if 0 | 566 | #if 0 |
567 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 567 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
568 | SLOT(selectionChanged(QListViewItem *))); | 568 | SLOT(selectionChanged(QListViewItem *))); |
569 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 569 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
570 | SLOT(selectionChanged(QListViewItem *))); | 570 | SLOT(selectionChanged(QListViewItem *))); |
571 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 571 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
572 | SLOT(selectionChanged(QListViewItem *))); | 572 | SLOT(selectionChanged(QListViewItem *))); |
573 | #endif | 573 | #endif |
574 | 574 | ||
575 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 575 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
576 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 576 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
577 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 577 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
578 | 578 | ||
579 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 579 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
580 | SLOT( processSelectionChange() ) ); | 580 | SLOT( processSelectionChange() ) ); |
581 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 581 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
582 | SLOT( addQuickTodo() ) ); | 582 | SLOT( addQuickTodo() ) ); |
583 | 583 | ||
584 | } | 584 | } |
585 | 585 | ||
586 | KOTodoView::~KOTodoView() | 586 | KOTodoView::~KOTodoView() |
587 | { | 587 | { |
588 | // delete mKOTodoViewWhatsThis; | 588 | // delete mKOTodoViewWhatsThis; |
589 | delete mDocPrefs; | 589 | delete mDocPrefs; |
590 | } | 590 | } |
591 | QString KOTodoView::getWhatsThisText(QPoint p) | 591 | QString KOTodoView::getWhatsThisText(QPoint p) |
592 | { | 592 | { |
593 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 593 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
594 | if ( item ) | 594 | if ( item ) |
595 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 595 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
596 | KOPrefs::instance()->mWTshowDetails, | 596 | KOPrefs::instance()->mWTshowDetails, |
597 | KOPrefs::instance()->mWTshowCreated, | 597 | KOPrefs::instance()->mWTshowCreated, |
598 | KOPrefs::instance()->mWTshowChanged); | 598 | KOPrefs::instance()->mWTshowChanged); |
599 | return i18n("That is the todo view" ); | 599 | return i18n("That is the todo view" ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void KOTodoView::jumpToDate () | 603 | void KOTodoView::jumpToDate () |
604 | { | 604 | { |
605 | // if (mActiveItem) { | 605 | // if (mActiveItem) { |
606 | // mActiveItem->todo()); | 606 | // mActiveItem->todo()); |
607 | // if ( mActiveItem->todo()->hasDueDate() ) | 607 | // if ( mActiveItem->todo()->hasDueDate() ) |
608 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 608 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
609 | } | 609 | } |
610 | void KOTodoView::paintNeeded() | 610 | void KOTodoView::paintNeeded() |
611 | { | 611 | { |
612 | if ( mPendingUpdateBeforeRepaint ) { | 612 | if ( mPendingUpdateBeforeRepaint ) { |
613 | updateView(); | 613 | updateView(); |
614 | mPendingUpdateBeforeRepaint = false; | 614 | mPendingUpdateBeforeRepaint = false; |
615 | } | 615 | } |
616 | } | 616 | } |
617 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 617 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
618 | { | 618 | { |
619 | if ( mPendingUpdateBeforeRepaint ) { | 619 | if ( mPendingUpdateBeforeRepaint ) { |
620 | updateView(); | 620 | updateView(); |
621 | mPendingUpdateBeforeRepaint = false; | 621 | mPendingUpdateBeforeRepaint = false; |
622 | } | 622 | } |
623 | KOrg::BaseView::paintEvent( pevent); | 623 | KOrg::BaseView::paintEvent( pevent); |
624 | } | 624 | } |
625 | 625 | ||
626 | void KOTodoView::updateView() | 626 | void KOTodoView::updateView() |
627 | { | 627 | { |
628 | pendingSubtodo = 0; | 628 | pendingSubtodo = 0; |
629 | if ( mBlockUpdate ) { | 629 | if ( mBlockUpdate ) { |
630 | return; | 630 | return; |
631 | } | 631 | } |
632 | if ( !isVisible() ) { | 632 | if ( !isVisible() ) { |
633 | mPendingUpdateBeforeRepaint = true; | 633 | mPendingUpdateBeforeRepaint = true; |
634 | return; | 634 | return; |
635 | } | 635 | } |
636 | storeCurrentItem(); | 636 | storeCurrentItem(); |
637 | //qDebug("KOTodoView::updateView() %x", this); | 637 | //qDebug("KOTodoView::updateView() %x", this); |
638 | if ( isFlatDisplay ) { | 638 | if ( isFlatDisplay ) { |
639 | displayAllFlat(); | 639 | displayAllFlat(); |
640 | resetCurrentItem(); | 640 | resetCurrentItem(); |
641 | return; | 641 | return; |
642 | } | 642 | } |
643 | //qDebug("update "); | 643 | //qDebug("update "); |
644 | // kdDebug() << "KOTodoView::updateView()" << endl; | 644 | // kdDebug() << "KOTodoView::updateView()" << endl; |
645 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 645 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
646 | 646 | ||
647 | 647 | ||
648 | mTodoListView->clear(); | 648 | mTodoListView->clear(); |
649 | if ( mName == "todolistsmall" ) { | 649 | if ( mName == "todolistsmall" ) { |
650 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 650 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
651 | int ps = fo.pointSize() -2; | 651 | int ps = fo.pointSize() -2; |
652 | if ( ps > 12 ) | 652 | if ( ps > 12 ) |
653 | ps -= 2; | 653 | ps -= 2; |
654 | fo.setPointSize( ps ); | 654 | fo.setPointSize( ps ); |
655 | } | 655 | } |
656 | } | 656 | } |
657 | 657 | ||
658 | mTodoListView->setFont( fo ); | 658 | mTodoListView->setFont( fo ); |
659 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 659 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
660 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 660 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
661 | QPtrList<Todo> todoList = calendar()->todos(); | 661 | QPtrList<Todo> todoList = calendar()->todos(); |
662 | 662 | ||
663 | /* | 663 | /* |
664 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 664 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
665 | Event *t; | 665 | Event *t; |
666 | for(t = todoList.first(); t; t = todoList.next()) { | 666 | for(t = todoList.first(); t; t = todoList.next()) { |
667 | kdDebug() << " " << t->getSummary() << endl; | 667 | kdDebug() << " " << t->getSummary() << endl; |
668 | 668 | ||
669 | if (t->getRelatedTo()) { | 669 | if (t->getRelatedTo()) { |
670 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 670 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
671 | } | 671 | } |
672 | 672 | ||
673 | QPtrList<Event> l = t->getRelations(); | 673 | QPtrList<Event> l = t->getRelations(); |
674 | Event *c; | 674 | Event *c; |
675 | for(c=l.first();c;c=l.next()) { | 675 | for(c=l.first();c;c=l.next()) { |
676 | kdDebug() << " - relation: " << c->getSummary() << endl; | 676 | kdDebug() << " - relation: " << c->getSummary() << endl; |
677 | } | 677 | } |
678 | } | 678 | } |
679 | */ | 679 | */ |
680 | 680 | ||
681 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 681 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
682 | // specific order of events. That means that we have to generate parent items | 682 | // specific order of events. That means that we have to generate parent items |
683 | // recursively for proper hierarchical display of Todos. | 683 | // recursively for proper hierarchical display of Todos. |
684 | mTodoMap.clear(); | 684 | mTodoMap.clear(); |
685 | Todo *todo; | 685 | Todo *todo; |
686 | todo = todoList.first();// todo; todo = todoList.next()) { | 686 | todo = todoList.first();// todo; todo = todoList.next()) { |
687 | while ( todo ) { | 687 | while ( todo ) { |
688 | bool next = true; | 688 | bool next = true; |
689 | // qDebug("todo %s ", todo->summary().latin1()); | 689 | // qDebug("todo %s ", todo->summary().latin1()); |
690 | Incidence *incidence = todo->relatedTo(); | 690 | Incidence *incidence = todo->relatedTo(); |
691 | while ( incidence ) { | 691 | while ( incidence ) { |
692 | if ( incidence->type() == "Todo") { | 692 | if ( incidence->type() == "Todo") { |
693 | //qDebug("related %s ",incidence->summary().latin1() ); | 693 | //qDebug("related %s ",incidence->summary().latin1() ); |
694 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 694 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
695 | //qDebug("related not found "); | 695 | //qDebug("related not found "); |
696 | todoList.remove( ); | 696 | todoList.remove( ); |
697 | todo = todoList.current(); | 697 | todo = todoList.current(); |
698 | next = false; | 698 | next = false; |
699 | incidence = 0; | 699 | incidence = 0; |
700 | 700 | ||
701 | } else { | 701 | } else { |
702 | //qDebug("related found "); | 702 | //qDebug("related found "); |
703 | incidence = incidence->relatedTo(); | 703 | incidence = incidence->relatedTo(); |
704 | } | 704 | } |
705 | } else | 705 | } else |
706 | incidence = 0; | 706 | incidence = 0; |
707 | } | 707 | } |
708 | if ( next ) | 708 | if ( next ) |
709 | todo = todoList.next(); | 709 | todo = todoList.next(); |
710 | } | 710 | } |
711 | // qDebug("again .... "); | 711 | |
712 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | ||
713 | |||
714 | // qDebug("yytodo %s ", todo->summary().latin1()); | ||
715 | // } | ||
716 | //qDebug("for "); | ||
717 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 712 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
718 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 713 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
719 | { | 714 | { |
720 | insertTodoItem(todo); | 715 | insertTodoItem(todo); |
721 | } | 716 | } |
722 | } | 717 | } |
723 | //qDebug("for end "); | ||
724 | // Restore opened/closed state | 718 | // Restore opened/closed state |
725 | mTodoListView->blockSignals( true ); | 719 | mTodoListView->blockSignals( true ); |
726 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 720 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
727 | mTodoListView->blockSignals( false ); | 721 | mTodoListView->blockSignals( false ); |
728 | resetCurrentItem(); | 722 | resetCurrentItem(); |
729 | processSelectionChange(); | 723 | processSelectionChange(); |
730 | } | 724 | } |
731 | 725 | ||
732 | void KOTodoView::storeCurrentItem() | 726 | void KOTodoView::storeCurrentItem() |
733 | { | 727 | { |
734 | mCurItem = 0; | 728 | mCurItem = 0; |
735 | mCurItemRootParent = 0; | 729 | mCurItemRootParent = 0; |
736 | mCurItemParent = 0; | 730 | mCurItemParent = 0; |
737 | mCurItemAbove = 0; | 731 | mCurItemAbove = 0; |
738 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 732 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
739 | if (mActiveItem) { | 733 | if (mActiveItem) { |
740 | mCurItem = mActiveItem->todo(); | 734 | mCurItem = mActiveItem->todo(); |
741 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 735 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
742 | if ( activeItemAbove ) | 736 | if ( activeItemAbove ) |
743 | mCurItemAbove = activeItemAbove->todo(); | 737 | mCurItemAbove = activeItemAbove->todo(); |
744 | mCurItemRootParent = mCurItem; | 738 | mCurItemRootParent = mCurItem; |
745 | mCurItemParent = mCurItemRootParent->relatedTo(); | 739 | mCurItemParent = mCurItemRootParent->relatedTo(); |
746 | while ( mCurItemRootParent->relatedTo() != 0 ) | 740 | while ( mCurItemRootParent->relatedTo() != 0 ) |
747 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 741 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
748 | } | 742 | } |
749 | mActiveItem = 0; | 743 | mActiveItem = 0; |
750 | } | 744 | } |
751 | 745 | ||
752 | void KOTodoView::resetCurrentItem() | 746 | void KOTodoView::resetCurrentItem() |
753 | { | 747 | { |
754 | mTodoListView->setFocus(); | 748 | mTodoListView->setFocus(); |
755 | KOTodoViewItem* foundItem = 0; | 749 | KOTodoViewItem* foundItem = 0; |
756 | KOTodoViewItem* foundItemRoot = 0; | 750 | KOTodoViewItem* foundItemRoot = 0; |
757 | KOTodoViewItem* foundItemParent = 0; | 751 | KOTodoViewItem* foundItemParent = 0; |
758 | KOTodoViewItem* foundItemAbove = 0; | 752 | KOTodoViewItem* foundItemAbove = 0; |
759 | if ( mTodoListView->firstChild () ) { | 753 | if ( mTodoListView->firstChild () ) { |
760 | if ( mCurItem ) { | 754 | if ( mCurItem ) { |
761 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 755 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
762 | while ( item ) { | 756 | while ( item ) { |
763 | if ( item->todo() == mCurItem ) { | 757 | if ( item->todo() == mCurItem ) { |
764 | foundItem = item; | 758 | foundItem = item; |
765 | break; | 759 | break; |
766 | } else if ( item->todo() == mCurItemAbove ) { | 760 | } else if ( item->todo() == mCurItemAbove ) { |
767 | foundItemAbove = item; | 761 | foundItemAbove = item; |
768 | 762 | ||
769 | } | 763 | } |
770 | if ( item->todo() == mCurItemRootParent ) { | 764 | if ( item->todo() == mCurItemRootParent ) { |
771 | foundItemRoot = item; | 765 | foundItemRoot = item; |
772 | } | 766 | } |
773 | if ( item->todo() == mCurItemParent ) { | 767 | if ( item->todo() == mCurItemParent ) { |
774 | foundItemParent = item; | 768 | foundItemParent = item; |
775 | } | 769 | } |
776 | item = (KOTodoViewItem*)item->itemBelow(); | 770 | item = (KOTodoViewItem*)item->itemBelow(); |
777 | } | 771 | } |
778 | if ( ! foundItem ) { | 772 | if ( ! foundItem ) { |
779 | if ( foundItemParent ) { | 773 | if ( foundItemParent ) { |
780 | foundItem = foundItemParent; | 774 | foundItem = foundItemParent; |
781 | } else { | 775 | } else { |
782 | if ( foundItemRoot ) | 776 | if ( foundItemRoot ) |
783 | foundItem = foundItemRoot; | 777 | foundItem = foundItemRoot; |
784 | else | 778 | else |
785 | foundItem = foundItemAbove; | 779 | foundItem = foundItemAbove; |
786 | } | 780 | } |
787 | } | 781 | } |
788 | } | 782 | } |
789 | if ( foundItem ) { | 783 | if ( foundItem ) { |
790 | mTodoListView->setCurrentItem( foundItem ); | 784 | mTodoListView->setCurrentItem( foundItem ); |
791 | mTodoListView->ensureItemVisible( foundItem ); | 785 | mTodoListView->ensureItemVisible( foundItem ); |
792 | } else { | 786 | } else { |
793 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 787 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
794 | } | 788 | } |
795 | } | 789 | } |
796 | mTodoListView->setFocus(); | 790 | mTodoListView->setFocus(); |
797 | } | 791 | } |
798 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 792 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
799 | bool KOTodoView::checkTodo( Todo * todo ) | 793 | bool KOTodoView::checkTodo( Todo * todo ) |
800 | { | 794 | { |
801 | 795 | ||
802 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 796 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
803 | return false; | 797 | return false; |
804 | if ( !todo->isCompleted() ) { | 798 | if ( !todo->isCompleted() ) { |
805 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 799 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
806 | return true; | 800 | return true; |
807 | } | 801 | } |
808 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 802 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
809 | if ( todo->hasStartDate() ) | 803 | if ( todo->hasStartDate() ) |
810 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 804 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
811 | return false; | 805 | return false; |
812 | if ( todo->hasDueDate() ) | 806 | if ( todo->hasDueDate() ) |
813 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 807 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
814 | return false; | 808 | return false; |
815 | } | 809 | } |
816 | return true; | 810 | return true; |
817 | } | 811 | } |
818 | 812 | ||
819 | void KOTodoView::restoreItemState( QListViewItem *item ) | 813 | void KOTodoView::restoreItemState( QListViewItem *item ) |
820 | { | 814 | { |
821 | pendingSubtodo = 0; | 815 | pendingSubtodo = 0; |
822 | while( item ) { | 816 | while( item ) { |
823 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 817 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
824 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 818 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
825 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 819 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
826 | item = item->nextSibling(); | 820 | item = item->nextSibling(); |
827 | } | 821 | } |
828 | } | 822 | } |
829 | 823 | ||
830 | 824 | ||
831 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 825 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
832 | KOTodoView::insertTodoItem(Todo *todo) | 826 | KOTodoView::insertTodoItem(Todo *todo) |
833 | { | 827 | { |
834 | 828 | ||
835 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 829 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
836 | // TODO: Check, if dynmaic cast is necessary | 830 | // TODO: Check, if dynmaic cast is necessary |
837 | 831 | ||
838 | pendingSubtodo = 0; | 832 | pendingSubtodo = 0; |
839 | Incidence *incidence = todo->relatedTo(); | 833 | Incidence *incidence = todo->relatedTo(); |
840 | if (incidence && incidence->type() == "Todo") { | 834 | if (incidence && incidence->type() == "Todo") { |
841 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 835 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
842 | 836 | ||
843 | // kdDebug() << " has Related" << endl; | 837 | // kdDebug() << " has Related" << endl; |
844 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 838 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
845 | itemIterator = mTodoMap.find(relatedTodo); | 839 | itemIterator = mTodoMap.find(relatedTodo); |
846 | if (itemIterator == mTodoMap.end()) { | 840 | if (itemIterator == mTodoMap.end()) { |
847 | // kdDebug() << " related not yet in list" << endl; | 841 | // kdDebug() << " related not yet in list" << endl; |
848 | itemIterator = insertTodoItem (relatedTodo); | 842 | itemIterator = insertTodoItem (relatedTodo); |
849 | } | 843 | } |
850 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 844 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
851 | // and one into the map. Sure finding is more easy but why? -zecke | 845 | // and one into the map. Sure finding is more easy but why? -zecke |
852 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 846 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
853 | return mTodoMap.insert(todo,todoItem); | 847 | return mTodoMap.insert(todo,todoItem); |
854 | } else { | 848 | } else { |
855 | // kdDebug() << " no Related" << endl; | 849 | // kdDebug() << " no Related" << endl; |
856 | // see above -zecke | 850 | // see above -zecke |
857 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 851 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
858 | return mTodoMap.insert(todo,todoItem); | 852 | return mTodoMap.insert(todo,todoItem); |
859 | } | 853 | } |
860 | } | 854 | } |
861 | 855 | ||
862 | 856 | ||
863 | void KOTodoView::updateConfig() | 857 | void KOTodoView::updateConfig() |
864 | { | 858 | { |
865 | updateView(); | 859 | updateView(); |
866 | mTodoListView->repaintContents(); | 860 | mTodoListView->repaintContents(); |
867 | } | 861 | } |
868 | 862 | ||
869 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 863 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
870 | { | 864 | { |
871 | QPtrList<Incidence> selected; | 865 | QPtrList<Incidence> selected; |
872 | 866 | ||
873 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 867 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
874 | // if (!item) item = mActiveItem; | 868 | // if (!item) item = mActiveItem; |
875 | if (item) selected.append(item->todo()); | 869 | if (item) selected.append(item->todo()); |
876 | 870 | ||
877 | return selected; | 871 | return selected; |
878 | } | 872 | } |
879 | 873 | ||
880 | QPtrList<Todo> KOTodoView::selectedTodos() | 874 | QPtrList<Todo> KOTodoView::selectedTodos() |
881 | { | 875 | { |
882 | QPtrList<Todo> selected; | 876 | QPtrList<Todo> selected; |
883 | 877 | ||
884 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 878 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
885 | // if (!item) item = mActiveItem; | 879 | // if (!item) item = mActiveItem; |
886 | if (item) selected.append(item->todo()); | 880 | if (item) selected.append(item->todo()); |
887 | 881 | ||
888 | return selected; | 882 | return selected; |
889 | } | 883 | } |
890 | 884 | ||
891 | void KOTodoView::changeEventDisplay(Event *, int) | 885 | void KOTodoView::changeEventDisplay(Event *, int) |
892 | { | 886 | { |
893 | updateView(); | 887 | updateView(); |
894 | } | 888 | } |
895 | 889 | ||
896 | void KOTodoView::showDates(const QDate &, const QDate &) | 890 | void KOTodoView::showDates(const QDate &, const QDate &) |
897 | { | 891 | { |
898 | } | 892 | } |
899 | 893 | ||
900 | void KOTodoView::showEvents(QPtrList<Event>) | 894 | void KOTodoView::showEvents(QPtrList<Event>) |
901 | { | 895 | { |
902 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 896 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
903 | } | 897 | } |
904 | 898 | ||
905 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 899 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
906 | const QDate &td) | 900 | const QDate &td) |
907 | { | 901 | { |
908 | #ifndef KORG_NOPRINTER | 902 | #ifndef KORG_NOPRINTER |
909 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 903 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
910 | #endif | 904 | #endif |
911 | } | 905 | } |
912 | 906 | ||
913 | void KOTodoView::editItem(QListViewItem *item ) | 907 | void KOTodoView::editItem(QListViewItem *item ) |
914 | { | 908 | { |
915 | // qDebug("editItem(QListViewItem *item ) "); | ||
916 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 909 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
917 | } | 910 | } |
918 | 911 | ||
919 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 912 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
920 | { | 913 | { |
921 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 914 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
922 | } | 915 | } |
923 | 916 | ||
924 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 917 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
925 | { | 918 | { |
926 | pendingSubtodo = 0; | 919 | pendingSubtodo = 0; |
927 | mActiveItem = (KOTodoViewItem *)item; | 920 | mActiveItem = (KOTodoViewItem *)item; |
928 | if (item) { | 921 | if (item) { |
929 | switch (column){ | 922 | switch (column){ |
930 | case 1: | 923 | case 1: |
931 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 924 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
932 | case 2: | 925 | case 2: |
933 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 926 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
934 | case 3: | 927 | case 3: |
935 | moveTodo(); | 928 | moveTodo(); |
936 | break; | 929 | break; |
937 | case 8: | 930 | case 8: |
938 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 931 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
939 | default: | 932 | default: |
940 | mItemPopupMenu->popup(QCursor::pos()); | 933 | mItemPopupMenu->popup(QCursor::pos()); |
941 | } | 934 | } |
942 | } else mPopupMenu->popup(QCursor::pos()); | 935 | } else mPopupMenu->popup(QCursor::pos()); |
943 | } | 936 | } |
944 | void KOTodoView::newTodo() | 937 | void KOTodoView::newTodo() |
945 | { | 938 | { |
946 | emit newTodoSignal(); | 939 | emit newTodoSignal(); |
947 | } | 940 | } |
948 | 941 | ||
949 | void KOTodoView::newSubTodo() | 942 | void KOTodoView::newSubTodo() |
950 | { | 943 | { |
951 | if (mActiveItem) { | 944 | if (mActiveItem) { |
952 | emit newSubTodoSignal(mActiveItem->todo()); | 945 | emit newSubTodoSignal(mActiveItem->todo()); |
953 | } | 946 | } |
954 | } | 947 | } |
955 | void KOTodoView::unparentTodo() | 948 | void KOTodoView::unparentTodo() |
956 | { | 949 | { |
957 | if (mActiveItem) { | 950 | if (mActiveItem) { |
958 | emit unparentTodoSignal(mActiveItem->todo()); | 951 | emit unparentTodoSignal(mActiveItem->todo()); |
959 | } | 952 | } |
960 | } | 953 | } |
961 | 954 | ||
962 | void KOTodoView::reparentTodo() | 955 | void KOTodoView::reparentTodo() |
963 | { | 956 | { |
964 | if (mActiveItem) { | 957 | if (mActiveItem) { |
965 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 958 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
966 | pendingSubtodo = mActiveItem; | 959 | pendingSubtodo = mActiveItem; |
967 | } | 960 | } |
968 | } | 961 | } |
969 | void KOTodoView::editTodo() | 962 | void KOTodoView::editTodo() |
970 | { | 963 | { |
971 | if (mActiveItem) { | 964 | if (mActiveItem) { |
972 | emit editTodoSignal(mActiveItem->todo()); | 965 | emit editTodoSignal(mActiveItem->todo()); |
973 | } | 966 | } |
974 | } | 967 | } |
975 | void KOTodoView::cloneTodo() | 968 | void KOTodoView::cloneTodo() |
976 | { | 969 | { |
977 | if (mActiveItem) { | 970 | if (mActiveItem) { |
978 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 971 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
979 | } | 972 | } |
980 | } | 973 | } |
981 | void KOTodoView::cancelTodo() | 974 | void KOTodoView::cancelTodo() |
982 | { | 975 | { |
983 | if (mActiveItem) { | 976 | if (mActiveItem) { |
984 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 977 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
985 | } | 978 | } |
986 | } | 979 | } |
987 | void KOTodoView::moveTodo() | 980 | void KOTodoView::moveTodo() |
988 | { | 981 | { |
989 | if (mActiveItem) { | 982 | if (mActiveItem) { |
990 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 983 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
991 | } | 984 | } |
992 | } | 985 | } |
993 | void KOTodoView::beamTodo() | 986 | void KOTodoView::beamTodo() |
994 | { | 987 | { |
995 | if (mActiveItem) { | 988 | if (mActiveItem) { |
996 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 989 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
997 | } | 990 | } |
998 | } | 991 | } |
999 | 992 | ||
1000 | 993 | ||
1001 | void KOTodoView::showTodo() | 994 | void KOTodoView::showTodo() |
1002 | { | 995 | { |
1003 | if (mActiveItem) { | 996 | if (mActiveItem) { |
1004 | emit showTodoSignal(mActiveItem->todo()); | 997 | emit showTodoSignal(mActiveItem->todo()); |
1005 | } | 998 | } |
1006 | } | 999 | } |
1007 | 1000 | ||
1008 | void KOTodoView::deleteTodo() | 1001 | void KOTodoView::deleteTodo() |
1009 | { | 1002 | { |
1010 | if (mActiveItem) { | 1003 | if (mActiveItem) { |
1011 | emit deleteTodoSignal(mActiveItem->todo()); | 1004 | emit deleteTodoSignal(mActiveItem->todo()); |
1012 | } | 1005 | } |
1013 | } | 1006 | } |
1014 | 1007 | ||
1015 | void KOTodoView::setNewPriority(int index) | 1008 | void KOTodoView::setNewPriority(int index) |
1016 | { | 1009 | { |
1017 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1010 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1018 | mActiveItem->todo()->setPriority(mPriority[index]); | 1011 | mActiveItem->todo()->setPriority(mPriority[index]); |
1019 | mActiveItem->construct(); | 1012 | mActiveItem->construct(); |
1020 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1013 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1021 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1014 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1022 | } | 1015 | } |
1023 | } | 1016 | } |
1024 | 1017 | ||
1025 | void KOTodoView::setNewPercentage(int index) | 1018 | void KOTodoView::setNewPercentage(int index) |
1026 | { | 1019 | { |
1027 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1020 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1028 | 1021 | ||
1029 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1022 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1030 | mActiveItem->setOn( true ); | 1023 | mActiveItem->setOn( true ); |
1031 | return; | 1024 | return; |
1032 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1025 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1033 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1026 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1034 | if ( par && par->isOn() ) | 1027 | if ( par && par->isOn() ) |
1035 | par->setOn( false ); | 1028 | par->setOn( false ); |
1036 | } | 1029 | } |
1037 | if (mPercentage[index] == 100) { | 1030 | if (mPercentage[index] == 100) { |
1038 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1031 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1039 | } else { | 1032 | } else { |
1040 | mActiveItem->todo()->setCompleted(false); | 1033 | mActiveItem->todo()->setCompleted(false); |
1041 | } | 1034 | } |
1042 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1035 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1043 | mActiveItem->construct(); | 1036 | mActiveItem->construct(); |
1044 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1037 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1045 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1038 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1046 | } | 1039 | } |
1047 | } | 1040 | } |
1048 | 1041 | ||
1049 | 1042 | ||
1050 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1043 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1051 | { | 1044 | { |
1052 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1045 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1053 | QStringList checkedCategories = todoItem->todo()->categories (); | 1046 | QStringList checkedCategories = todoItem->todo()->categories (); |
1054 | 1047 | ||
1055 | tempMenu->setCheckable (true); | 1048 | tempMenu->setCheckable (true); |
1056 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1049 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1057 | it != KOPrefs::instance()->mCustomCategories.end (); | 1050 | it != KOPrefs::instance()->mCustomCategories.end (); |
1058 | ++it) { | 1051 | ++it) { |
1059 | int index = tempMenu->insertItem (*it); | 1052 | int index = tempMenu->insertItem (*it); |
1060 | mCategory[index] = *it; | 1053 | mCategory[index] = *it; |
1061 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1054 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1062 | } | 1055 | } |
1063 | 1056 | ||
1064 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1057 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1065 | return tempMenu; | 1058 | return tempMenu; |
1066 | 1059 | ||
1067 | 1060 | ||
1068 | } | 1061 | } |
1069 | void KOTodoView::changedCategories(int index) | 1062 | void KOTodoView::changedCategories(int index) |
1070 | { | 1063 | { |
1071 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1064 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1072 | QStringList categories = mActiveItem->todo()->categories (); | 1065 | QStringList categories = mActiveItem->todo()->categories (); |
1073 | QString colcat = categories.first(); | 1066 | QString colcat = categories.first(); |
1074 | if (categories.find (mCategory[index]) != categories.end ()) | 1067 | if (categories.find (mCategory[index]) != categories.end ()) |
1075 | categories.remove (mCategory[index]); | 1068 | categories.remove (mCategory[index]); |
1076 | else | 1069 | else |
1077 | categories.insert (categories.end(), mCategory[index]); | 1070 | categories.insert (categories.end(), mCategory[index]); |
1078 | categories.sort (); | 1071 | categories.sort (); |
1079 | if ( !colcat.isEmpty() ) { | 1072 | if ( !colcat.isEmpty() ) { |
1080 | if ( categories.find ( colcat ) != categories.end () ) { | 1073 | if ( categories.find ( colcat ) != categories.end () ) { |
1081 | categories.remove( colcat ); | 1074 | categories.remove( colcat ); |
1082 | categories.prepend( colcat ); | 1075 | categories.prepend( colcat ); |
1083 | } | 1076 | } |
1084 | } | 1077 | } |
1085 | mActiveItem->todo()->setCategories (categories); | 1078 | mActiveItem->todo()->setCategories (categories); |
1086 | mActiveItem->construct(); | 1079 | mActiveItem->construct(); |
1087 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1080 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1088 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1081 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1089 | } | 1082 | } |
1090 | } | 1083 | } |
1091 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1084 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1092 | { | 1085 | { |
1093 | if ( pendingSubtodo != 0 ) { | 1086 | if ( pendingSubtodo != 0 ) { |
1094 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1087 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1095 | } | 1088 | } |
1096 | pendingSubtodo = 0; | 1089 | pendingSubtodo = 0; |
1097 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1090 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1098 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1091 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1099 | qDebug("ROW %d ", row); | 1092 | //qDebug("ROW %d ", row); |
1100 | if (!item) { | 1093 | if (!item) { |
1101 | newTodo(); | 1094 | newTodo(); |
1102 | return; | 1095 | return; |
1103 | } else { | 1096 | } else { |
1104 | if ( row == 2 || row == 1 ) { | 1097 | if ( row == 2 || row == 1 ) { |
1105 | mActiveItem = (KOTodoViewItem *) item; | 1098 | mActiveItem = (KOTodoViewItem *) item; |
1106 | newSubTodo(); | 1099 | newSubTodo(); |
1107 | return; | 1100 | return; |
1108 | } | 1101 | } |
1109 | if ( row == 5 || row == 6 ) { | 1102 | if ( row == 5 || row == 6 ) { |
1110 | mActiveItem = (KOTodoViewItem *) item; | 1103 | mActiveItem = (KOTodoViewItem *) item; |
1111 | toggleRunningItem(); | 1104 | toggleRunningItem(); |
1112 | return; | 1105 | return; |
1113 | } | 1106 | } |
1114 | } | 1107 | } |
1115 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1108 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1116 | editItem( item ); | 1109 | editItem( item ); |
1117 | else | 1110 | else |
1118 | showItem( item , QPoint(), 0 ); | 1111 | showItem( item , QPoint(), 0 ); |
1119 | } | 1112 | } |
1120 | void KOTodoView::toggleRunningItem() | 1113 | void KOTodoView::toggleRunningItem() |
1121 | { | 1114 | { |
1122 | // qDebug("KOTodoView::toggleRunning() "); | 1115 | // qDebug("KOTodoView::toggleRunning() "); |
1123 | if ( ! mActiveItem ) | 1116 | if ( ! mActiveItem ) |
1124 | return; | 1117 | return; |
1125 | Todo * t = mActiveItem->todo(); | 1118 | Todo * t = mActiveItem->todo(); |
1126 | if ( t->isRunning() ) { | 1119 | if ( t->isRunning() ) { |
1127 | int result = KMessageBox::warningContinueCancel(this, | 1120 | int result = KMessageBox::warningContinueCancel(this, |
1128 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); | 1121 | i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); |
1129 | if (result != KMessageBox::Continue) return; | 1122 | if (result != KMessageBox::Continue) return; |
1130 | t->setRunning( false ); | 1123 | t->setRunning( false ); |
1131 | mActiveItem->construct(); | 1124 | mActiveItem->construct(); |
1132 | } else { | 1125 | } else { |
1133 | int result = KMessageBox::warningContinueCancel(this, | 1126 | int result = KMessageBox::warningContinueCancel(this, |
1134 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); | 1127 | i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); |
1135 | if (result != KMessageBox::Continue) return; | 1128 | if (result != KMessageBox::Continue) return; |
1136 | t->setRunning( true ); | 1129 | t->setRunning( true ); |
1137 | mActiveItem->construct(); | 1130 | mActiveItem->construct(); |
1138 | } | 1131 | } |
1139 | } | 1132 | } |
1140 | 1133 | ||
1141 | void KOTodoView::itemClicked(QListViewItem *item) | 1134 | void KOTodoView::itemClicked(QListViewItem *item) |
1142 | { | 1135 | { |
1143 | //qDebug("KOTodoView::itemClicked %d", item); | 1136 | //qDebug("KOTodoView::itemClicked %d", item); |
1144 | if (!item) { | 1137 | if (!item) { |
1145 | if ( pendingSubtodo != 0 ) { | 1138 | if ( pendingSubtodo != 0 ) { |
1146 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1139 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1147 | } | 1140 | } |
1148 | pendingSubtodo = 0; | 1141 | pendingSubtodo = 0; |
1149 | return; | 1142 | return; |
1150 | } | 1143 | } |
1151 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1144 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1152 | if ( pendingSubtodo != 0 ) { | 1145 | if ( pendingSubtodo != 0 ) { |
1153 | bool allowReparent = true; | 1146 | bool allowReparent = true; |
1154 | QListViewItem *par = item; | 1147 | QListViewItem *par = item; |
1155 | while ( par ) { | 1148 | while ( par ) { |
1156 | if ( par == pendingSubtodo ) { | 1149 | if ( par == pendingSubtodo ) { |
1157 | allowReparent = false; | 1150 | allowReparent = false; |
1158 | break; | 1151 | break; |
1159 | } | 1152 | } |
1160 | par = par->parent(); | 1153 | par = par->parent(); |
1161 | } | 1154 | } |
1162 | if ( !allowReparent ) { | 1155 | if ( !allowReparent ) { |
1163 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1156 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1164 | pendingSubtodo = 0; | 1157 | pendingSubtodo = 0; |
1165 | } else { | 1158 | } else { |
1166 | Todo* newParent = todoItem->todo(); | 1159 | Todo* newParent = todoItem->todo(); |
1167 | Todo* newSub = pendingSubtodo->todo(); | 1160 | Todo* newSub = pendingSubtodo->todo(); |
1168 | pendingSubtodo = 0; | 1161 | pendingSubtodo = 0; |
1169 | emit reparentTodoSignal( newParent,newSub ); | 1162 | emit reparentTodoSignal( newParent,newSub ); |
1170 | return; | 1163 | return; |
1171 | } | 1164 | } |
1172 | } | 1165 | } |
1173 | #if 0 | 1166 | |
1174 | // handled by the item itself | ||
1175 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | ||
1176 | qDebug("com %d ",completed ); | ||
1177 | qDebug("itemclicked "); | ||
1178 | if (todoItem->isOn()) { | ||
1179 | qDebug("on "); | ||
1180 | if (!completed) { | ||
1181 | qDebug("set true "); | ||
1182 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | ||
1183 | } | ||
1184 | } else { | ||
1185 | qDebug("not on "); | ||
1186 | if (completed) { | ||
1187 | qDebug("set false "); | ||
1188 | todoItem->todo()->setCompleted(false); | ||
1189 | } | ||
1190 | } | ||
1191 | #endif | ||
1192 | } | 1167 | } |
1193 | 1168 | ||
1194 | void KOTodoView::setDocumentId( const QString &id ) | 1169 | void KOTodoView::setDocumentId( const QString &id ) |
1195 | { | 1170 | { |
1196 | 1171 | ||
1197 | mDocPrefs->setDoc( id ); | 1172 | mDocPrefs->setDoc( id ); |
1198 | } | 1173 | } |
1199 | 1174 | ||
1200 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1175 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1201 | { | 1176 | { |
1202 | if (!item) return; | 1177 | if (!item) return; |
1203 | 1178 | ||
1204 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1179 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1205 | 1180 | ||
1206 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1181 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1207 | 1182 | ||
1208 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1183 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1209 | } | 1184 | } |
1210 | 1185 | ||
1211 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1186 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1212 | { | 1187 | { |
1213 | mTodoListView->saveLayout(config,group); | 1188 | mTodoListView->saveLayout(config,group); |
1214 | } | 1189 | } |
1215 | 1190 | ||
1216 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1191 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1217 | { | 1192 | { |
1218 | mTodoListView->restoreLayout(config,group); | 1193 | mTodoListView->restoreLayout(config,group); |
1219 | } | 1194 | } |
1220 | 1195 | ||
1221 | void KOTodoView::processSelectionChange() | 1196 | void KOTodoView::processSelectionChange() |
1222 | { | 1197 | { |
1223 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1198 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1224 | 1199 | ||
1225 | KOTodoViewItem *item = | 1200 | KOTodoViewItem *item = |
1226 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1201 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1227 | 1202 | ||
1228 | if ( !item ) { | 1203 | if ( !item ) { |
1229 | emit incidenceSelected( 0 ); | 1204 | emit incidenceSelected( 0 ); |
1230 | } else { | 1205 | } else { |
1231 | emit incidenceSelected( item->todo() ); | 1206 | emit incidenceSelected( item->todo() ); |
1232 | } | 1207 | } |
1233 | } | 1208 | } |
1234 | 1209 | ||
1235 | void KOTodoView::modified(bool b) | 1210 | void KOTodoView::modified(bool b) |
1236 | { | 1211 | { |
1237 | emit isModified(b); | 1212 | emit isModified(b); |
1238 | } | 1213 | } |
1239 | void KOTodoView::setTodoModified( Todo* todo ) | 1214 | void KOTodoView::setTodoModified( Todo* todo ) |
1240 | { | 1215 | { |
1241 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1216 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1242 | } | 1217 | } |
1243 | void KOTodoView::clearSelection() | 1218 | void KOTodoView::clearSelection() |
1244 | { | 1219 | { |
1245 | mTodoListView->selectAll( false ); | 1220 | mTodoListView->selectAll( false ); |
1246 | } | 1221 | } |
1247 | void KOTodoView::setAllOpen() | 1222 | void KOTodoView::setAllOpen() |
1248 | { | 1223 | { |
1249 | if ( isFlatDisplay ) { | 1224 | if ( isFlatDisplay ) { |
1250 | isFlatDisplay = false; | 1225 | isFlatDisplay = false; |
1251 | mPopupMenu->setItemChecked( 8,false ); | 1226 | mPopupMenu->setItemChecked( 8,false ); |
1252 | updateView(); | 1227 | updateView(); |
1253 | } else { | 1228 | } else { |
1254 | storeCurrentItem(); | 1229 | storeCurrentItem(); |
1255 | } | 1230 | } |
1256 | setOpen(mTodoListView->firstChild(), true); | 1231 | setOpen(mTodoListView->firstChild(), true); |
1257 | resetCurrentItem(); | 1232 | resetCurrentItem(); |
1258 | } | 1233 | } |
1259 | void KOTodoView::setAllClose() | 1234 | void KOTodoView::setAllClose() |
1260 | { | 1235 | { |
1261 | if ( isFlatDisplay ) { | 1236 | if ( isFlatDisplay ) { |
1262 | isFlatDisplay = false; | 1237 | isFlatDisplay = false; |
1263 | mPopupMenu->setItemChecked( 8,false ); | 1238 | mPopupMenu->setItemChecked( 8,false ); |
1264 | updateView(); | 1239 | updateView(); |
1265 | } else { | 1240 | } else { |
1266 | storeCurrentItem(); | 1241 | storeCurrentItem(); |
1267 | } | 1242 | } |
1268 | setOpen(mTodoListView->firstChild(), false); | 1243 | setOpen(mTodoListView->firstChild(), false); |
1269 | resetCurrentItem(); | 1244 | resetCurrentItem(); |
1270 | } | 1245 | } |
1271 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1246 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1272 | { | 1247 | { |
1273 | 1248 | ||
1274 | while ( item ) { | 1249 | while ( item ) { |
1275 | setOpen( item->firstChild(), setOpenI ); | 1250 | setOpen( item->firstChild(), setOpenI ); |
1276 | item->setOpen( setOpenI ); | 1251 | item->setOpen( setOpenI ); |
1277 | item = item->nextSibling(); | 1252 | item = item->nextSibling(); |
1278 | } | 1253 | } |
1279 | } | 1254 | } |
1280 | 1255 | ||
1281 | void KOTodoView::displayAllFlat() | 1256 | void KOTodoView::displayAllFlat() |
1282 | { | 1257 | { |
1283 | pendingSubtodo = 0; | 1258 | pendingSubtodo = 0; |
1284 | if ( mBlockUpdate ) { | 1259 | if ( mBlockUpdate ) { |
1285 | return; | 1260 | return; |
1286 | } | 1261 | } |
1287 | mPopupMenu->setItemChecked( 8,true ); | 1262 | mPopupMenu->setItemChecked( 8,true ); |
1288 | isFlatDisplay = true; | 1263 | isFlatDisplay = true; |
1289 | QPtrList<Todo> todoList = calendar()->todos(); | 1264 | QPtrList<Todo> todoList = calendar()->todos(); |
1290 | mTodoMap.clear(); | 1265 | mTodoMap.clear(); |
1291 | mTodoListView->clear(); | 1266 | mTodoListView->clear(); |
1292 | Todo *todo; | 1267 | Todo *todo; |
1293 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1268 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1294 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1269 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1295 | mTodoMap.insert(todo,todoItem); | 1270 | mTodoMap.insert(todo,todoItem); |
1296 | } | 1271 | } |
1297 | mTodoListView->setFocus(); | 1272 | mTodoListView->setFocus(); |
1298 | processSelectionChange(); | 1273 | processSelectionChange(); |
1299 | } | 1274 | } |
1300 | 1275 | ||
1301 | void KOTodoView::setAllFlat() | 1276 | void KOTodoView::setAllFlat() |
1302 | { | 1277 | { |
1303 | if ( isFlatDisplay ) { | 1278 | if ( isFlatDisplay ) { |
1304 | isFlatDisplay = false; | 1279 | isFlatDisplay = false; |
1305 | mPopupMenu->setItemChecked( 8,false ); | 1280 | mPopupMenu->setItemChecked( 8,false ); |
1306 | updateView(); | 1281 | updateView(); |
1307 | return; | 1282 | return; |
1308 | } | 1283 | } |
1309 | storeCurrentItem(); | 1284 | storeCurrentItem(); |
1310 | displayAllFlat(); | 1285 | displayAllFlat(); |
1311 | resetCurrentItem(); | 1286 | resetCurrentItem(); |
1312 | } | 1287 | } |
1313 | 1288 | ||
1314 | void KOTodoView::purgeCompleted() | 1289 | void KOTodoView::purgeCompleted() |
1315 | { | 1290 | { |
1316 | emit purgeCompletedSignal(); | 1291 | emit purgeCompletedSignal(); |
1317 | 1292 | ||
1318 | } | 1293 | } |
1319 | void KOTodoView::toggleQuickTodo() | 1294 | void KOTodoView::toggleQuickTodo() |
1320 | { | 1295 | { |
1321 | if ( mQuickAdd->isVisible() ) { | 1296 | if ( mQuickAdd->isVisible() ) { |
1322 | mQuickAdd->hide(); | 1297 | mQuickAdd->hide(); |
1323 | KOPrefs::instance()->mEnableQuickTodo = false; | 1298 | KOPrefs::instance()->mEnableQuickTodo = false; |
1324 | } | 1299 | } |
1325 | else { | 1300 | else { |
1326 | mQuickAdd->show(); | 1301 | mQuickAdd->show(); |
1327 | KOPrefs::instance()->mEnableQuickTodo = true; | 1302 | KOPrefs::instance()->mEnableQuickTodo = true; |
1328 | } | 1303 | } |
1329 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1304 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1330 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1305 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1331 | } | 1306 | } |
1332 | 1307 | ||
1333 | void KOTodoView::toggleRunning() | 1308 | void KOTodoView::toggleRunning() |
1334 | { | 1309 | { |
1335 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1310 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1336 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1311 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1337 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1312 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1338 | updateView(); | 1313 | updateView(); |
1339 | } | 1314 | } |
1340 | 1315 | ||
1341 | void KOTodoView::toggleCompleted() | 1316 | void KOTodoView::toggleCompleted() |
1342 | { | 1317 | { |
1343 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1318 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1344 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1319 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1345 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1320 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1346 | updateView(); | 1321 | updateView(); |
1347 | } | 1322 | } |
1348 | 1323 | ||
1349 | void KOTodoView::addQuickTodo() | 1324 | void KOTodoView::addQuickTodo() |
1350 | { | 1325 | { |
1351 | Todo *todo = new Todo(); | 1326 | Todo *todo = new Todo(); |
1352 | todo->setSummary(mQuickAdd->text()); | 1327 | todo->setSummary(mQuickAdd->text()); |
1353 | todo->setOrganizer(KOPrefs::instance()->email()); | 1328 | todo->setOrganizer(KOPrefs::instance()->email()); |
1354 | CalFilter * cf = mCalendar->filter(); | 1329 | CalFilter * cf = mCalendar->filter(); |
1355 | if ( cf ) { | 1330 | if ( cf ) { |
1356 | if ( cf->isEnabled()&& cf->showCategories()) { | 1331 | if ( cf->isEnabled()&& cf->showCategories()) { |
1357 | todo->setCategories(cf->categoryList()); | 1332 | todo->setCategories(cf->categoryList()); |
1358 | } | 1333 | } |
1359 | if ( cf->isEnabled() ) | 1334 | if ( cf->isEnabled() ) |
1360 | todo->setSecrecy( cf->getSecrecy()); | 1335 | todo->setSecrecy( cf->getSecrecy()); |
1361 | } | 1336 | } |
1362 | mCalendar->addTodo(todo); | 1337 | mCalendar->addTodo(todo); |
1363 | mQuickAdd->setText(""); | 1338 | mQuickAdd->setText(""); |
1364 | todoModified (todo, KOGlobals::EVENTADDED ); | 1339 | todoModified (todo, KOGlobals::EVENTADDED ); |
1365 | updateView(); | 1340 | updateView(); |
1366 | } | 1341 | } |
1367 | 1342 | ||
1368 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1343 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1369 | { | 1344 | { |
1370 | // e->ignore(); | 1345 | // e->ignore(); |
1371 | //return; | 1346 | //return; |
1372 | //qDebug("KOTodoView::keyPressEvent "); | 1347 | //qDebug("KOTodoView::keyPressEvent "); |
1373 | switch ( e->key() ) { | 1348 | switch ( e->key() ) { |
1374 | case Qt::Key_Down: | 1349 | case Qt::Key_Down: |
1375 | case Qt::Key_Up: | 1350 | case Qt::Key_Up: |
1376 | QWidget::keyPressEvent ( e ); | 1351 | QWidget::keyPressEvent ( e ); |
1377 | break; | 1352 | break; |
1378 | 1353 | ||
1379 | case Qt::Key_Q: | 1354 | case Qt::Key_Q: |
1380 | toggleQuickTodo(); | 1355 | toggleQuickTodo(); |
1381 | break; | 1356 | break; |
1382 | case Qt::Key_U: | 1357 | case Qt::Key_U: |
1383 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1358 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index f1f2dd2..3aa9b6c 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -361,393 +361,385 @@ void KOViewManager::updateView() | |||
361 | { | 361 | { |
362 | // qDebug("KOViewManager::updateView() "); | 362 | // qDebug("KOViewManager::updateView() "); |
363 | // if we are updating mTodoView, we get endless recursion | 363 | // if we are updating mTodoView, we get endless recursion |
364 | if ( mTodoView == mCurrentView ) | 364 | if ( mTodoView == mCurrentView ) |
365 | return; | 365 | return; |
366 | if ( mCurrentView ) mCurrentView->updateView(); | 366 | if ( mCurrentView ) mCurrentView->updateView(); |
367 | 367 | ||
368 | } | 368 | } |
369 | 369 | ||
370 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 370 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
371 | { | 371 | { |
372 | // kdDebug() << "KOViewManager::updateView()" << endl; | 372 | // kdDebug() << "KOViewManager::updateView()" << endl; |
373 | 373 | ||
374 | if (mCurrentView) mCurrentView->showDates(start, end); | 374 | if (mCurrentView) mCurrentView->showDates(start, end); |
375 | 375 | ||
376 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 376 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void KOViewManager::updateWNview() | 380 | void KOViewManager::updateWNview() |
381 | { | 381 | { |
382 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 382 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
383 | mWhatsNextView->updateView(); | 383 | mWhatsNextView->updateView(); |
384 | if ( mCurrentView == mMonthView && mMonthView ) | 384 | if ( mCurrentView == mMonthView && mMonthView ) |
385 | mMonthView->updateView(); | 385 | mMonthView->updateView(); |
386 | 386 | ||
387 | } | 387 | } |
388 | void KOViewManager::showWhatsNextView() | 388 | void KOViewManager::showWhatsNextView() |
389 | { | 389 | { |
390 | if (!mWhatsNextView) { | 390 | if (!mWhatsNextView) { |
391 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 391 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
392 | "KOViewManager::WhatsNextView"); | 392 | "KOViewManager::WhatsNextView"); |
393 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 393 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
394 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 394 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
395 | addView(mWhatsNextView); | 395 | addView(mWhatsNextView); |
396 | connect(this, SIGNAL( printWNV() ), | 396 | connect(this, SIGNAL( printWNV() ), |
397 | mWhatsNextView, SLOT( printMe() ) ); | 397 | mWhatsNextView, SLOT( printMe() ) ); |
398 | } | 398 | } |
399 | globalFlagBlockAgenda = 1; | 399 | globalFlagBlockAgenda = 1; |
400 | showView(mWhatsNextView, true ); | 400 | showView(mWhatsNextView, true ); |
401 | //mWhatsNextView->updateView(); | 401 | //mWhatsNextView->updateView(); |
402 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; | 402 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; |
403 | } | 403 | } |
404 | 404 | ||
405 | void KOViewManager::slotprintWNV() | 405 | void KOViewManager::slotprintWNV() |
406 | { | 406 | { |
407 | if (!mWhatsNextView) | 407 | if (!mWhatsNextView) |
408 | showWhatsNextView(); | 408 | showWhatsNextView(); |
409 | emit printWNV(); | 409 | emit printWNV(); |
410 | 410 | ||
411 | } | 411 | } |
412 | void KOViewManager::showListView() | 412 | void KOViewManager::showListView() |
413 | { | 413 | { |
414 | if (!mListView) { | 414 | if (!mListView) { |
415 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 415 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
416 | addView(mListView); | 416 | addView(mListView); |
417 | 417 | ||
418 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 418 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
419 | mMainView, SLOT(showIncidence(Incidence *))); | 419 | mMainView, SLOT(showIncidence(Incidence *))); |
420 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 420 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
421 | mMainView, SLOT(editIncidence(Incidence *))); | 421 | mMainView, SLOT(editIncidence(Incidence *))); |
422 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 422 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
423 | mMainView, SLOT(deleteIncidence(Incidence *))); | 423 | mMainView, SLOT(deleteIncidence(Incidence *))); |
424 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 424 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
425 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 425 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
426 | connect( mListView, SIGNAL( signalNewEvent() ), | 426 | connect( mListView, SIGNAL( signalNewEvent() ), |
427 | mMainView, SLOT( newEvent() ) ); | 427 | mMainView, SLOT( newEvent() ) ); |
428 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 428 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
429 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 429 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
430 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 430 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
431 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 431 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
432 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 432 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
433 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 433 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
434 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 434 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
435 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 435 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
436 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 436 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
437 | } | 437 | } |
438 | // bool temp = mFlagShowNextxDays; | 438 | // bool temp = mFlagShowNextxDays; |
439 | //globalFlagBlockPainting = true; | 439 | //globalFlagBlockPainting = true; |
440 | globalFlagBlockAgenda = 1; | 440 | globalFlagBlockAgenda = 1; |
441 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 441 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
442 | mMainView->setBlockShowDates( true ); | 442 | mMainView->setBlockShowDates( true ); |
443 | mMainView->dateNavigator()->selectMonth(); | 443 | mMainView->dateNavigator()->selectMonth(); |
444 | mMainView->setBlockShowDates( false ); | 444 | mMainView->setBlockShowDates( false ); |
445 | } | 445 | } |
446 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 446 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
447 | //mFlagShowNextxDays = temp; | 447 | //mFlagShowNextxDays = temp; |
448 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; | 448 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; |
449 | } | 449 | } |
450 | 450 | ||
451 | void KOViewManager::showAgendaView( bool fullScreen ) | 451 | void KOViewManager::showAgendaView( bool fullScreen ) |
452 | { | 452 | { |
453 | 453 | ||
454 | mMainView->dialogManager()->hideSearchDialog(); | 454 | mMainView->dialogManager()->hideSearchDialog(); |
455 | // qDebug("KOViewManager::showAgendaView "); | 455 | // qDebug("KOViewManager::showAgendaView "); |
456 | bool full; | 456 | bool full; |
457 | full = fullScreen; | 457 | full = fullScreen; |
458 | if (!mAgendaView) { | 458 | if (!mAgendaView) { |
459 | full = false; | 459 | full = false; |
460 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 460 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
461 | addView(mAgendaView); | 461 | addView(mAgendaView); |
462 | #ifndef DESKTOP_VERSION | 462 | #ifndef DESKTOP_VERSION |
463 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 463 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
464 | #endif | 464 | #endif |
465 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 465 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
466 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 466 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
467 | 467 | ||
468 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 468 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
469 | 469 | ||
470 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 470 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
471 | 471 | ||
472 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 472 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
473 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 473 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
474 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 474 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
475 | mMainView, SLOT(newEvent(QDateTime))); | 475 | mMainView, SLOT(newEvent(QDateTime))); |
476 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 476 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
477 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 477 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
478 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 478 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
479 | mMainView, SLOT(newEvent(QDate))); | 479 | mMainView, SLOT(newEvent(QDate))); |
480 | 480 | ||
481 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 481 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
482 | mMainView, SLOT(editIncidence(Incidence *))); | 482 | mMainView, SLOT(editIncidence(Incidence *))); |
483 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 483 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
484 | mMainView, SLOT(showIncidence(Incidence *))); | 484 | mMainView, SLOT(showIncidence(Incidence *))); |
485 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 485 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
486 | mMainView, SLOT(deleteIncidence(Incidence *))); | 486 | mMainView, SLOT(deleteIncidence(Incidence *))); |
487 | 487 | ||
488 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 488 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
489 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 489 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
490 | 490 | ||
491 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 491 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
492 | mMainView, SLOT( toggleExpand() ) ); | 492 | mMainView, SLOT( toggleExpand() ) ); |
493 | 493 | ||
494 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 494 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
495 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 495 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
496 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 496 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
497 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 497 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
498 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 498 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
499 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 499 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
500 | SLOT( updateTodo( Todo *, int ) ) ); | 500 | SLOT( updateTodo( Todo *, int ) ) ); |
501 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 501 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
502 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 502 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
503 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 503 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
504 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 504 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
505 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 505 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
506 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 506 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
507 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), | 507 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), |
508 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); | 508 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); |
509 | mAgendaView->readSettings(); | 509 | mAgendaView->readSettings(); |
510 | mAgendaView->updateConfig(); | 510 | mAgendaView->updateConfig(); |
511 | } | 511 | } |
512 | 512 | ||
513 | showView( mAgendaView, full); | 513 | showView( mAgendaView, full); |
514 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; | 514 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; |
515 | } | 515 | } |
516 | 516 | ||
517 | void KOViewManager::showDayView() | 517 | void KOViewManager::showDayView() |
518 | { | 518 | { |
519 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 519 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
520 | mFlagShowNextxDays = false; | 520 | mFlagShowNextxDays = false; |
521 | globalFlagBlockLabel = 1; | 521 | globalFlagBlockLabel = 1; |
522 | globalFlagBlockAgenda = 1; | 522 | globalFlagBlockAgenda = 1; |
523 | if ( mCurrentAgendaView != 1 ) | 523 | if ( mCurrentAgendaView != 1 ) |
524 | mCurrentAgendaView = -1; | 524 | mCurrentAgendaView = -1; |
525 | showAgendaView(); | 525 | showAgendaView(); |
526 | qApp->processEvents(); | 526 | qApp->processEvents(); |
527 | globalFlagBlockAgenda = 2; | 527 | globalFlagBlockAgenda = 2; |
528 | globalFlagBlockLabel = 0; | 528 | globalFlagBlockLabel = 0; |
529 | mMainView->dateNavigator()->selectDates( 1 ); | 529 | mMainView->dateNavigator()->selectDates( 1 ); |
530 | mCurrentAgendaView = 1 ; | 530 | mCurrentAgendaView = 1 ; |
531 | 531 | ||
532 | } | 532 | } |
533 | 533 | ||
534 | void KOViewManager::showWorkWeekView() | 534 | void KOViewManager::showWorkWeekView() |
535 | { | 535 | { |
536 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 536 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
537 | mFlagShowNextxDays = false; | 537 | mFlagShowNextxDays = false; |
538 | globalFlagBlockAgenda = 1; | 538 | globalFlagBlockAgenda = 1; |
539 | globalFlagBlockLabel = 1; | 539 | globalFlagBlockLabel = 1; |
540 | if ( mCurrentAgendaView != 5 ) | 540 | if ( mCurrentAgendaView != 5 ) |
541 | mCurrentAgendaView = -1; | 541 | mCurrentAgendaView = -1; |
542 | showAgendaView(); | 542 | showAgendaView(); |
543 | qApp->processEvents(); | 543 | qApp->processEvents(); |
544 | globalFlagBlockAgenda = 2; | 544 | globalFlagBlockAgenda = 2; |
545 | globalFlagBlockLabel = 0; | 545 | globalFlagBlockLabel = 0; |
546 | mMainView->dateNavigator()->selectWorkWeek(); | 546 | mMainView->dateNavigator()->selectWorkWeek(); |
547 | mCurrentAgendaView = 5 ; | 547 | mCurrentAgendaView = 5 ; |
548 | 548 | ||
549 | } | 549 | } |
550 | 550 | ||
551 | void KOViewManager::showWeekView() | 551 | void KOViewManager::showWeekView() |
552 | { | 552 | { |
553 | /* | 553 | |
554 | globalFlagBlockAgenda = 2; | ||
555 | qDebug("4globalFlagBlockAgenda = 2; "); | ||
556 | //globalFlagBlockPainting = true; | ||
557 | mMainView->dateNavigator()->selectWeek(); | ||
558 | showAgendaView(); | ||
559 | */ | ||
560 | |||
561 | |||
562 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); | 554 | mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); |
563 | mFlagShowNextxDays = false; | 555 | mFlagShowNextxDays = false; |
564 | globalFlagBlockAgenda = 1; | 556 | globalFlagBlockAgenda = 1; |
565 | globalFlagBlockLabel = 1; | 557 | globalFlagBlockLabel = 1; |
566 | if ( mCurrentAgendaView != 7 ) | 558 | if ( mCurrentAgendaView != 7 ) |
567 | mCurrentAgendaView = -1; | 559 | mCurrentAgendaView = -1; |
568 | showAgendaView(); | 560 | showAgendaView(); |
569 | qApp->processEvents(); | 561 | qApp->processEvents(); |
570 | globalFlagBlockAgenda = 2; | 562 | globalFlagBlockAgenda = 2; |
571 | globalFlagBlockLabel = 0; | 563 | globalFlagBlockLabel = 0; |
572 | mMainView->dateNavigator()->selectWeek(); | 564 | mMainView->dateNavigator()->selectWeek(); |
573 | mCurrentAgendaView = 7 ; | 565 | mCurrentAgendaView = 7 ; |
574 | } | 566 | } |
575 | 567 | ||
576 | void KOViewManager::showNextXView() | 568 | void KOViewManager::showNextXView() |
577 | { | 569 | { |
578 | 570 | ||
579 | globalFlagBlockAgenda = 1; | 571 | globalFlagBlockAgenda = 1; |
580 | if ( mCurrentAgendaView != 3 ) | 572 | if ( mCurrentAgendaView != 3 ) |
581 | mCurrentAgendaView = -1; | 573 | mCurrentAgendaView = -1; |
582 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 574 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
583 | globalFlagBlockAgenda = 2; | 575 | globalFlagBlockAgenda = 2; |
584 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 576 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
585 | KOPrefs::instance()->mNextXDays ); | 577 | KOPrefs::instance()->mNextXDays ); |
586 | mFlagShowNextxDays = true; | 578 | mFlagShowNextxDays = true; |
587 | mCurrentAgendaView = 3 ; | 579 | mCurrentAgendaView = 3 ; |
588 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; | 580 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; |
589 | } | 581 | } |
590 | bool KOViewManager::showsNextDays() | 582 | bool KOViewManager::showsNextDays() |
591 | { | 583 | { |
592 | return mFlagShowNextxDays; | 584 | return mFlagShowNextxDays; |
593 | } | 585 | } |
594 | void KOViewManager::createMonthView() | 586 | void KOViewManager::createMonthView() |
595 | { | 587 | { |
596 | if (!mMonthView) { | 588 | if (!mMonthView) { |
597 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 589 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
598 | 590 | ||
599 | addView(mMonthView); | 591 | addView(mMonthView); |
600 | // mMonthView->show(); | 592 | // mMonthView->show(); |
601 | // SIGNALS/SLOTS FOR MONTH VIEW | 593 | // SIGNALS/SLOTS FOR MONTH VIEW |
602 | 594 | ||
603 | connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); | 595 | connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); |
604 | 596 | ||
605 | connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), | 597 | connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), |
606 | mMainView, SLOT(newTodoDateTime(QDateTime, bool))); | 598 | mMainView, SLOT(newTodoDateTime(QDateTime, bool))); |
607 | 599 | ||
608 | 600 | ||
609 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 601 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
610 | mMainView, SLOT(newEvent(QDateTime))); | 602 | mMainView, SLOT(newEvent(QDateTime))); |
611 | 603 | ||
612 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 604 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
613 | mMainView, SLOT(showIncidence(Incidence *))); | 605 | mMainView, SLOT(showIncidence(Incidence *))); |
614 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 606 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
615 | mMainView, SLOT(editIncidence(Incidence *))); | 607 | mMainView, SLOT(editIncidence(Incidence *))); |
616 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 608 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
617 | mMainView, SLOT(deleteIncidence(Incidence *))); | 609 | mMainView, SLOT(deleteIncidence(Incidence *))); |
618 | 610 | ||
619 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 611 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
620 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 612 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
621 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 613 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
622 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 614 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
623 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 615 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
624 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 616 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
625 | 617 | ||
626 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 618 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
627 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 619 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
628 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 620 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
629 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 621 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
630 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 622 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
631 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); | 623 | mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); |
632 | connect( mMonthView, SIGNAL( selectMonth() ), | 624 | connect( mMonthView, SIGNAL( selectMonth() ), |
633 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); | 625 | mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); |
634 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 626 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
635 | mMainView, SLOT ( showDay( QDate ) ) ); | 627 | mMainView, SLOT ( showDay( QDate ) ) ); |
636 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 628 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
637 | connect( mMonthView, SIGNAL(nextMonth() ), | 629 | connect( mMonthView, SIGNAL(nextMonth() ), |
638 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 630 | mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
639 | connect( mMonthView, SIGNAL(prevMonth() ), | 631 | connect( mMonthView, SIGNAL(prevMonth() ), |
640 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 632 | mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
641 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), | 633 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), |
642 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); | 634 | mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); |
643 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), | 635 | connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), |
644 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); | 636 | mMainView->dateNavigator(), SLOT( selectNextYear() ) ); |
645 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), | 637 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), |
646 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); | 638 | mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); |
647 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), | 639 | connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), |
648 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); | 640 | mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); |
649 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), | 641 | connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), |
650 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); | 642 | mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); |
651 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), | 643 | connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), |
652 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); | 644 | mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); |
653 | 645 | ||
654 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 646 | connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
655 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); | 647 | mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); |
656 | 648 | ||
657 | 649 | ||
658 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), | 650 | connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), |
659 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); | 651 | mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); |
660 | 652 | ||
661 | } | 653 | } |
662 | } | 654 | } |
663 | void KOViewManager::showMonthViewWeek() | 655 | void KOViewManager::showMonthViewWeek() |
664 | { | 656 | { |
665 | createMonthView(); | 657 | createMonthView(); |
666 | globalFlagBlockAgenda = 1; | 658 | globalFlagBlockAgenda = 1; |
667 | bool full = true; | 659 | bool full = true; |
668 | if ( mCurrentView == mMonthView) | 660 | if ( mCurrentView == mMonthView) |
669 | full = mMainView->leftFrame()->isVisible(); | 661 | full = mMainView->leftFrame()->isVisible(); |
670 | if ( !KOPrefs::instance()->mMonthViewWeek ) { | 662 | if ( !KOPrefs::instance()->mMonthViewWeek ) { |
671 | mMonthView->switchView(); | 663 | mMonthView->switchView(); |
672 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) | 664 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) |
673 | full = false; | 665 | full = false; |
674 | else | 666 | else |
675 | full = true; | 667 | full = true; |
676 | } | 668 | } |
677 | mMainView->dateNavigator()->selectWeek(); | 669 | mMainView->dateNavigator()->selectWeek(); |
678 | showView(mMonthView, full ); | 670 | showView(mMonthView, full ); |
679 | mMonthView->setKeyBFocus(); | 671 | mMonthView->setKeyBFocus(); |
680 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; | 672 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; |
681 | } | 673 | } |
682 | 674 | ||
683 | void KOViewManager::showMonth( const QDate & date ) | 675 | void KOViewManager::showMonth( const QDate & date ) |
684 | { | 676 | { |
685 | mMainView->dateNavigator()->blockSignals( true ); | 677 | mMainView->dateNavigator()->blockSignals( true ); |
686 | mMainView->dateNavigator()->selectDate( date ); | 678 | mMainView->dateNavigator()->selectDate( date ); |
687 | mMainView->dateNavigator()->blockSignals( false ); | 679 | mMainView->dateNavigator()->blockSignals( false ); |
688 | showMonthView(); | 680 | showMonthView(); |
689 | } | 681 | } |
690 | void KOViewManager::showMonthView() | 682 | void KOViewManager::showMonthView() |
691 | { | 683 | { |
692 | 684 | ||
693 | createMonthView(); | 685 | createMonthView(); |
694 | globalFlagBlockAgenda = 1; | 686 | globalFlagBlockAgenda = 1; |
695 | //mFlagShowNextxDays = false; | 687 | //mFlagShowNextxDays = false; |
696 | bool full = true; | 688 | bool full = true; |
697 | if ( mCurrentView == mMonthView) | 689 | if ( mCurrentView == mMonthView) |
698 | full = mMainView->leftFrame()->isVisible(); | 690 | full = mMainView->leftFrame()->isVisible(); |
699 | // if(mMonthView == mCurrentView) return; | 691 | // if(mMonthView == mCurrentView) return; |
700 | if ( KOPrefs::instance()->mMonthViewWeek ) { | 692 | if ( KOPrefs::instance()->mMonthViewWeek ) { |
701 | mMonthView->switchView(); | 693 | mMonthView->switchView(); |
702 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) | 694 | if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) |
703 | full = false; | 695 | full = false; |
704 | else | 696 | else |
705 | full = true; | 697 | full = true; |
706 | } | 698 | } |
707 | mMainView->dateNavigator()->selectMonth(); | 699 | mMainView->dateNavigator()->selectMonth(); |
708 | 700 | ||
709 | showView(mMonthView, full ); | 701 | showView(mMonthView, full ); |
710 | mMonthView->setKeyBFocus(); | 702 | mMonthView->setKeyBFocus(); |
711 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; | 703 | KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; |
712 | 704 | ||
713 | } | 705 | } |
714 | 706 | ||
715 | void KOViewManager::showTodoView() | 707 | void KOViewManager::showTodoView() |
716 | { | 708 | { |
717 | //mFlagShowNextxDays = false; | 709 | //mFlagShowNextxDays = false; |
718 | if ( !mTodoView ) { | 710 | if ( !mTodoView ) { |
719 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 711 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
720 | "KOViewManager::TodoView" ); | 712 | "KOViewManager::TodoView" ); |
721 | 713 | ||
722 | addView( mTodoView ); | 714 | addView( mTodoView ); |
723 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 715 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
724 | 716 | ||
725 | // SIGNALS/SLOTS FOR TODO VIEW | 717 | // SIGNALS/SLOTS FOR TODO VIEW |
726 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 718 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
727 | mMainView, SLOT( newTodo() ) ); | 719 | mMainView, SLOT( newTodo() ) ); |
728 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 720 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
729 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 721 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
730 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 722 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
731 | mMainView, SLOT( showTodo( Todo * ) ) ); | 723 | mMainView, SLOT( showTodo( Todo * ) ) ); |
732 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 724 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
733 | mMainView, SLOT( editTodo( Todo * ) ) ); | 725 | mMainView, SLOT( editTodo( Todo * ) ) ); |
734 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 726 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
735 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 727 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
736 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 728 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
737 | mMainView, SLOT( purgeCompleted() ) ); | 729 | mMainView, SLOT( purgeCompleted() ) ); |
738 | 730 | ||
739 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 731 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
740 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 732 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
741 | 733 | ||
742 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 734 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
743 | SLOT( updateConfig() ) ); | 735 | SLOT( updateConfig() ) ); |
744 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 736 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
745 | SLOT( updateTodo( Todo *, int ) ) ); | 737 | SLOT( updateTodo( Todo *, int ) ) ); |
746 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 738 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
747 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 739 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
748 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 740 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
749 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 741 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
750 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 742 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
751 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 743 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
752 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 744 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
753 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 745 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 8473db9..65d8ac3 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,281 +1,279 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include "koeventviewer.h" | 44 | #include "koeventviewer.h" |
45 | #include <qstylesheet.h> | 45 | #include <qstylesheet.h> |
46 | #include "kowhatsnextview.h" | 46 | #include "kowhatsnextview.h" |
47 | using namespace KOrg; | 47 | using namespace KOrg; |
48 | 48 | ||
49 | void WhatsNextTextBrowser::setSource(const QString& n) | 49 | void WhatsNextTextBrowser::setSource(const QString& n) |
50 | { | 50 | { |
51 | 51 | ||
52 | if (n.startsWith("event:")) { | 52 | if (n.startsWith("event:")) { |
53 | emit showIncidence(n); | 53 | emit showIncidence(n); |
54 | return; | 54 | return; |
55 | } else if (n.startsWith("todo:")) { | 55 | } else if (n.startsWith("todo:")) { |
56 | emit showIncidence(n); | 56 | emit showIncidence(n); |
57 | return; | 57 | return; |
58 | } else { | 58 | } else { |
59 | QTextBrowser::setSource(n); | 59 | QTextBrowser::setSource(n); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | void WhatsNextTextBrowser::printMe() | 62 | void WhatsNextTextBrowser::printMe() |
63 | { | 63 | { |
64 | #ifdef DESKTOP_VERSION | 64 | #ifdef DESKTOP_VERSION |
65 | KOPrintPrefs pp ( this ); | 65 | KOPrintPrefs pp ( this ); |
66 | if (!pp.exec() ) | 66 | if (!pp.exec() ) |
67 | return; | 67 | return; |
68 | int scaleval = pp.printMode() ; | 68 | int scaleval = pp.printMode() ; |
69 | 69 | ||
70 | QPrinter printer; | 70 | QPrinter printer; |
71 | if (!printer.setup() ) | 71 | if (!printer.setup() ) |
72 | return; | 72 | return; |
73 | QPainter p; | 73 | QPainter p; |
74 | p.begin ( &printer ); | 74 | p.begin ( &printer ); |
75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
76 | float dx, dy; | 76 | float dx, dy; |
77 | int wid = (m.width() * 9)/10; | 77 | int wid = (m.width() * 9)/10; |
78 | dx = (float) wid/(float)contentsWidth (); | 78 | dx = (float) wid/(float)contentsWidth (); |
79 | dy = (float)(m.height()) / (float)contentsHeight (); | 79 | dy = (float)(m.height()) / (float)contentsHeight (); |
80 | float scale; | 80 | float scale; |
81 | // scale to fit the width or height of the paper | 81 | // scale to fit the width or height of the paper |
82 | if ( dx < dy ) | 82 | if ( dx < dy ) |
83 | scale = dx; | 83 | scale = dx; |
84 | else | 84 | else |
85 | scale = dy; | 85 | scale = dy; |
86 | p.translate( m.width()/10,0 ); | 86 | p.translate( m.width()/10,0 ); |
87 | qDebug("Scale: %f ", scale ); | ||
88 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 87 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
89 | qDebug("SCALE "); | ||
90 | p.scale( scale, scale ); | 88 | p.scale( scale, scale ); |
91 | } | 89 | } |
92 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 90 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
93 | p.end(); | 91 | p.end(); |
94 | #endif | 92 | #endif |
95 | } | 93 | } |
96 | 94 | ||
97 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 95 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
98 | const char *name) | 96 | const char *name) |
99 | : KOrg::BaseView(calendar, parent, name) | 97 | : KOrg::BaseView(calendar, parent, name) |
100 | { | 98 | { |
101 | // mDateLabel = | 99 | // mDateLabel = |
102 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 100 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
103 | // mDateLabel->setMargin(2); | 101 | // mDateLabel->setMargin(2); |
104 | // mDateLabel->setAlignment(AlignCenter); | 102 | // mDateLabel->setAlignment(AlignCenter); |
105 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 103 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
106 | mView = new WhatsNextTextBrowser(this); | 104 | mView = new WhatsNextTextBrowser(this); |
107 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 105 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
108 | QStyleSheet* stsh = mView->styleSheet(); | 106 | QStyleSheet* stsh = mView->styleSheet(); |
109 | QStyleSheetItem * style ; | 107 | QStyleSheetItem * style ; |
110 | style = stsh->item ("h2" ); | 108 | style = stsh->item ("h2" ); |
111 | if ( style ) { | 109 | if ( style ) { |
112 | style->setMargin(QStyleSheetItem::MarginAll,0); | 110 | style->setMargin(QStyleSheetItem::MarginAll,0); |
113 | } | 111 | } |
114 | style = stsh->item ("h3" ); | 112 | style = stsh->item ("h3" ); |
115 | if ( style ) { | 113 | if ( style ) { |
116 | style->setMargin(QStyleSheetItem::MarginAll,0); | 114 | style->setMargin(QStyleSheetItem::MarginAll,0); |
117 | } | 115 | } |
118 | mEventViewer = 0; | 116 | mEventViewer = 0; |
119 | 117 | ||
120 | QBoxLayout *topLayout = new QVBoxLayout(this); | 118 | QBoxLayout *topLayout = new QVBoxLayout(this); |
121 | // topLayout->addWidget(mDateLabel); | 119 | // topLayout->addWidget(mDateLabel); |
122 | topLayout->addWidget(mView); | 120 | topLayout->addWidget(mView); |
123 | mTimer = new QTimer( this ); | 121 | mTimer = new QTimer( this ); |
124 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 122 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
125 | 123 | ||
126 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 124 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
127 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 125 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
128 | } | 126 | } |
129 | 127 | ||
130 | KOWhatsNextView::~KOWhatsNextView() | 128 | KOWhatsNextView::~KOWhatsNextView() |
131 | { | 129 | { |
132 | } | 130 | } |
133 | 131 | ||
134 | int KOWhatsNextView::maxDatesHint() | 132 | int KOWhatsNextView::maxDatesHint() |
135 | { | 133 | { |
136 | return 0; | 134 | return 0; |
137 | } | 135 | } |
138 | 136 | ||
139 | int KOWhatsNextView::currentDateCount() | 137 | int KOWhatsNextView::currentDateCount() |
140 | { | 138 | { |
141 | return 0; | 139 | return 0; |
142 | } | 140 | } |
143 | 141 | ||
144 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 142 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
145 | { | 143 | { |
146 | QPtrList<Incidence> eventList; | 144 | QPtrList<Incidence> eventList; |
147 | 145 | ||
148 | return eventList; | 146 | return eventList; |
149 | } | 147 | } |
150 | 148 | ||
151 | void KOWhatsNextView::printMe() | 149 | void KOWhatsNextView::printMe() |
152 | { | 150 | { |
153 | #ifdef DESKTOP_VERSION | 151 | #ifdef DESKTOP_VERSION |
154 | mView->printMe(); | 152 | mView->printMe(); |
155 | #endif | 153 | #endif |
156 | } | 154 | } |
157 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 155 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
158 | const QDate &td) | 156 | const QDate &td) |
159 | { | 157 | { |
160 | #ifndef KORG_NOPRINTER | 158 | #ifndef KORG_NOPRINTER |
161 | calPrinter->preview(CalPrinter::Day, fd, td); | 159 | calPrinter->preview(CalPrinter::Day, fd, td); |
162 | #endif | 160 | #endif |
163 | } | 161 | } |
164 | void KOWhatsNextView::updateConfig() | 162 | void KOWhatsNextView::updateConfig() |
165 | { | 163 | { |
166 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 164 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
167 | updateView(); | 165 | updateView(); |
168 | 166 | ||
169 | } | 167 | } |
170 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 168 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
171 | { | 169 | { |
172 | //qDebug("KOWhatsNextView::showEvent "); | 170 | //qDebug("KOWhatsNextView::showEvent "); |
173 | restartTimer(); | 171 | restartTimer(); |
174 | QWidget::showEvent ( e ); | 172 | QWidget::showEvent ( e ); |
175 | } | 173 | } |
176 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 174 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
177 | { | 175 | { |
178 | //qDebug(" KOWhatsNextView::hideEvent"); | 176 | //qDebug(" KOWhatsNextView::hideEvent"); |
179 | mTimer->stop(); | 177 | mTimer->stop(); |
180 | QWidget::hideEvent ( e ); | 178 | QWidget::hideEvent ( e ); |
181 | } | 179 | } |
182 | void KOWhatsNextView::restartTimer() | 180 | void KOWhatsNextView::restartTimer() |
183 | { | 181 | { |
184 | //qDebug("KOWhatsNextView::restartTimer() "); | 182 | //qDebug("KOWhatsNextView::restartTimer() "); |
185 | mTimer->start( 300000 ); | 183 | mTimer->start( 300000 ); |
186 | //mTimer->start( 5000 ); | 184 | //mTimer->start( 5000 ); |
187 | } | 185 | } |
188 | void KOWhatsNextView::updateView() | 186 | void KOWhatsNextView::updateView() |
189 | { | 187 | { |
190 | //qDebug("KOWhatsNextView::updateView() "); | 188 | //qDebug("KOWhatsNextView::updateView() "); |
191 | if ( mTimer->isActive() ) | 189 | if ( mTimer->isActive() ) |
192 | restartTimer(); | 190 | restartTimer(); |
193 | mCurrentMaxPrio = 5; | 191 | mCurrentMaxPrio = 5; |
194 | //qDebug("KOWhatsNextView::updateView() "); | 192 | //qDebug("KOWhatsNextView::updateView() "); |
195 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 193 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
196 | KIconLoader kil("korganizer"); | 194 | KIconLoader kil("korganizer"); |
197 | QString ipath;// = new QString(); | 195 | QString ipath;// = new QString(); |
198 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 196 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
199 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 197 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
200 | mText = "<table width=\"100%\">\n"; | 198 | mText = "<table width=\"100%\">\n"; |
201 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 199 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
202 | #ifdef DESKTOP_VERSION | 200 | #ifdef DESKTOP_VERSION |
203 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 201 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
204 | #else | 202 | #else |
205 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 203 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
206 | #endif | 204 | #endif |
207 | // mText += "<img src=\""; | 205 | // mText += "<img src=\""; |
208 | // mText += ipath; | 206 | // mText += ipath; |
209 | // mText += "\">"; | 207 | // mText += "\">"; |
210 | mEventDate = QDate::currentDate(); | 208 | mEventDate = QDate::currentDate(); |
211 | #ifdef DESKTOP_VERSION | 209 | #ifdef DESKTOP_VERSION |
212 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 210 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
213 | #else | 211 | #else |
214 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 212 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
215 | #endif | 213 | #endif |
216 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 214 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
217 | int iii; | 215 | int iii; |
218 | mTodos.clear(); | 216 | mTodos.clear(); |
219 | QPtrList<Event> events; | 217 | QPtrList<Event> events; |
220 | QPtrList<Todo> todos = calendar()->todos(); | 218 | QPtrList<Todo> todos = calendar()->todos(); |
221 | Todo * todo; | 219 | Todo * todo; |
222 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 220 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
223 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 221 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
224 | bool itemAdded = false; | 222 | bool itemAdded = false; |
225 | for ( iii = 0; iii < daysToShow; ++iii ) { | 223 | for ( iii = 0; iii < daysToShow; ++iii ) { |
226 | QString date; | 224 | QString date; |
227 | itemAdded = false; | 225 | itemAdded = false; |
228 | events = calendar()->events( mEventDate, true ); | 226 | events = calendar()->events( mEventDate, true ); |
229 | 227 | ||
230 | if ( iii == 0 ) { // today !!! | 228 | if ( iii == 0 ) { // today !!! |
231 | todo = todos.first(); | 229 | todo = todos.first(); |
232 | while(todo) { | 230 | while(todo) { |
233 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 231 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
234 | if ( ! itemAdded ) { | 232 | if ( ! itemAdded ) { |
235 | appendDay ( iii, mEventDate ); | 233 | appendDay ( iii, mEventDate ); |
236 | //itemAdded = true; | 234 | //itemAdded = true; |
237 | 235 | ||
238 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 236 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
239 | appendEvent(todo, false, false, !itemAdded ); | 237 | appendEvent(todo, false, false, !itemAdded ); |
240 | itemAdded = true; | 238 | itemAdded = true; |
241 | } | 239 | } |
242 | todo = todos.next(); | 240 | todo = todos.next(); |
243 | } | 241 | } |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | if (events.count() > 0) { | 245 | if (events.count() > 0) { |
248 | // mText += "<p></p>"; | 246 | // mText += "<p></p>"; |
249 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 247 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
250 | // mText += "<h2>"; | 248 | // mText += "<h2>"; |
251 | //mText += " <img src=\""; | 249 | //mText += " <img src=\""; |
252 | //mText += ipath; | 250 | //mText += ipath; |
253 | //mText += "\">"; | 251 | //mText += "\">"; |
254 | if ( ! itemAdded ) { | 252 | if ( ! itemAdded ) { |
255 | appendDay ( iii, mEventDate ); | 253 | appendDay ( iii, mEventDate ); |
256 | 254 | ||
257 | } | 255 | } |
258 | // for first day (iii == 0) | 256 | // for first day (iii == 0) |
259 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 257 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
260 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 258 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
261 | // we must append it in the first successful call of appendEvent() | 259 | // we must append it in the first successful call of appendEvent() |
262 | Event *ev = events.first(); | 260 | Event *ev = events.first(); |
263 | while(ev) { | 261 | while(ev) { |
264 | //qDebug("+++++event append %s", ev->summary().latin1()); | 262 | //qDebug("+++++event append %s", ev->summary().latin1()); |
265 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 263 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
266 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 264 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
267 | itemAdded = true; | 265 | itemAdded = true; |
268 | } | 266 | } |
269 | ev = events.next(); | 267 | ev = events.next(); |
270 | } | 268 | } |
271 | 269 | ||
272 | //mText += "</table>\n"; | 270 | //mText += "</table>\n"; |
273 | } | 271 | } |
274 | 272 | ||
275 | todo = todos.first(); | 273 | todo = todos.first(); |
276 | while(todo) { | 274 | while(todo) { |
277 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 275 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
278 | if ( ! itemAdded ) { | 276 | if ( ! itemAdded ) { |
279 | appendDay ( iii, mEventDate ); | 277 | appendDay ( iii, mEventDate ); |
280 | //itemAdded = true; | 278 | //itemAdded = true; |
281 | } | 279 | } |
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index 61a0931..df9b2fc 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp | |||
@@ -148,329 +148,327 @@ void KOTimeEdit::hilit(int ) | |||
148 | 148 | ||
149 | void KOTimeEdit::addTime(QTime qt, bool update) | 149 | void KOTimeEdit::addTime(QTime qt, bool update) |
150 | { | 150 | { |
151 | // Calculate the new time. | 151 | // Calculate the new time. |
152 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); | 152 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); |
153 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); | 153 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); |
154 | // if ( update ) | 154 | // if ( update ) |
155 | updateText(); | 155 | updateText(); |
156 | emit timeChanged(mTime); | 156 | emit timeChanged(mTime); |
157 | } | 157 | } |
158 | 158 | ||
159 | void KOTimeEdit::subTime(QTime qt, bool update) | 159 | void KOTimeEdit::subTime(QTime qt, bool update) |
160 | { | 160 | { |
161 | int h, m; | 161 | int h, m; |
162 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); | 162 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); |
163 | 163 | ||
164 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); | 164 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); |
165 | // store the newly calculated time. | 165 | // store the newly calculated time. |
166 | // mTime.setHMS(h, m, 0); | 166 | // mTime.setHMS(h, m, 0); |
167 | //if ( update ) | 167 | //if ( update ) |
168 | updateText(); | 168 | updateText(); |
169 | emit timeChanged(mTime); | 169 | emit timeChanged(mTime); |
170 | } | 170 | } |
171 | 171 | ||
172 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) | 172 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) |
173 | // { | 173 | // { |
174 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); | 174 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); |
175 | // } | 175 | // } |
176 | 176 | ||
177 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) | 177 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) |
178 | // { | 178 | // { |
179 | // qDebug("focusInEvent ( QFocusEvent * ) "); | 179 | // qDebug("focusInEvent ( QFocusEvent * ) "); |
180 | // } | 180 | // } |
181 | 181 | ||
182 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) | 182 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) |
183 | { | 183 | { |
184 | if ( !e->isAutoRepeat() ) { | 184 | if ( !e->isAutoRepeat() ) { |
185 | mFlagKeyPressed = false; | 185 | mFlagKeyPressed = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | } | 188 | } |
189 | void KOTimeEdit::setSelect( int from, int to ) | 189 | void KOTimeEdit::setSelect( int from, int to ) |
190 | { | 190 | { |
191 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) | 191 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) |
192 | lineEdit()->setSelection( from , to ); | 192 | lineEdit()->setSelection( from , to ); |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) | 196 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) |
197 | { | 197 | { |
198 | 198 | ||
199 | qApp->processEvents(); | 199 | qApp->processEvents(); |
200 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); | 200 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); |
201 | int maxpos = hour12Format?7:5; | 201 | int maxpos = hour12Format?7:5; |
202 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 202 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
203 | e->ignore(); | 203 | e->ignore(); |
204 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 204 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | if (! e->isAutoRepeat() ) { | 207 | if (! e->isAutoRepeat() ) { |
208 | mFlagKeyPressed = true; | 208 | mFlagKeyPressed = true; |
209 | } | 209 | } |
210 | // Tap -> Focus Next Widget | 210 | // Tap -> Focus Next Widget |
211 | if ( e->key() == Key_Tab ) { | 211 | if ( e->key() == Key_Tab ) { |
212 | QComboBox::keyPressEvent(e); | 212 | QComboBox::keyPressEvent(e); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | // save Text from QLineEdit and CursorPosition | 216 | // save Text from QLineEdit and CursorPosition |
217 | QString text = lineEdit()->text(); | 217 | QString text = lineEdit()->text(); |
218 | int cpos = lineEdit()->cursorPosition(); | 218 | int cpos = lineEdit()->cursorPosition(); |
219 | // qDebug("cpos %d ", cpos); | 219 | // qDebug("cpos %d ", cpos); |
220 | 220 | ||
221 | // Switch for arrows, backspace and escape | 221 | // Switch for arrows, backspace and escape |
222 | switch(e->key()) { | 222 | switch(e->key()) { |
223 | case Key_Escape: | 223 | case Key_Escape: |
224 | lineEdit()->deselect(); | 224 | lineEdit()->deselect(); |
225 | case Key_Tab: | 225 | case Key_Tab: |
226 | QComboBox::keyPressEvent(e); | 226 | QComboBox::keyPressEvent(e); |
227 | break; | 227 | break; |
228 | case Key_Up: | 228 | case Key_Up: |
229 | if ( e->state () == Qt::ControlButton ) { | 229 | if ( e->state () == Qt::ControlButton ) { |
230 | addTime(QTime(0,15,0), false ); | 230 | addTime(QTime(0,15,0), false ); |
231 | lineEdit()->setCursorPosition(3); | 231 | lineEdit()->setCursorPosition(3); |
232 | setSelect( 3 , 2 ); | 232 | setSelect( 3 , 2 ); |
233 | } | 233 | } |
234 | else | 234 | else |
235 | if ( e->state () == Qt::ShiftButton ) { | 235 | if ( e->state () == Qt::ShiftButton ) { |
236 | addTime(QTime(1,0,0), false ); | 236 | addTime(QTime(1,0,0), false ); |
237 | lineEdit()->setCursorPosition(0); | 237 | lineEdit()->setCursorPosition(0); |
238 | setSelect( 0 , 2 ); | 238 | setSelect( 0 , 2 ); |
239 | } | 239 | } |
240 | else | 240 | else |
241 | // switch time up, cursor location depend | 241 | // switch time up, cursor location depend |
242 | switch (cpos) { | 242 | switch (cpos) { |
243 | case 7: | 243 | case 7: |
244 | case 6: | 244 | case 6: |
245 | case 5: | 245 | case 5: |
246 | if(!hour12Format) { | 246 | if(!hour12Format) { |
247 | lineEdit()->setCursorPosition(cpos = 4); | 247 | lineEdit()->setCursorPosition(cpos = 4); |
248 | } else { | 248 | } else { |
249 | addTime(QTime(12,0,0), false ); | 249 | addTime(QTime(12,0,0), false ); |
250 | setSelect ( 5 , 2 ); | 250 | setSelect ( 5 , 2 ); |
251 | break; | 251 | break; |
252 | } | 252 | } |
253 | case 4: | 253 | case 4: |
254 | addTime(QTime(0,1,0), false ); | 254 | addTime(QTime(0,1,0), false ); |
255 | setSelect ( cpos , 1 ); | 255 | setSelect ( cpos , 1 ); |
256 | break; | 256 | break; |
257 | case 3: | 257 | case 3: |
258 | addTime(QTime(0,10,0), false ); | 258 | addTime(QTime(0,10,0), false ); |
259 | setSelect ( cpos , 1 ); | 259 | setSelect ( cpos , 1 ); |
260 | break; | 260 | break; |
261 | case 2: | 261 | case 2: |
262 | lineEdit()->setCursorPosition(--cpos); | 262 | lineEdit()->setCursorPosition(--cpos); |
263 | case 1: | 263 | case 1: |
264 | case 0: | 264 | case 0: |
265 | addTime(QTime(1,0,0), false ); | 265 | addTime(QTime(1,0,0), false ); |
266 | setSelect ( 0, 2 ); | 266 | setSelect ( 0, 2 ); |
267 | break; | 267 | break; |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | case Key_Down: | 270 | case Key_Down: |
271 | if ( e->state () == Qt::ControlButton ) { | 271 | if ( e->state () == Qt::ControlButton ) { |
272 | subTime(QTime(0,15,0), false ); | 272 | subTime(QTime(0,15,0), false ); |
273 | lineEdit()->setCursorPosition(3); | 273 | lineEdit()->setCursorPosition(3); |
274 | setSelect( 3 , 2 ); | 274 | setSelect( 3 , 2 ); |
275 | } | 275 | } |
276 | else | 276 | else |
277 | if ( e->state () == Qt::ShiftButton ) { | 277 | if ( e->state () == Qt::ShiftButton ) { |
278 | subTime(QTime(1,0,0), false ); | 278 | subTime(QTime(1,0,0), false ); |
279 | lineEdit()->setCursorPosition(0); | 279 | lineEdit()->setCursorPosition(0); |
280 | setSelect( 0 , 2 ); | 280 | setSelect( 0 , 2 ); |
281 | } | 281 | } |
282 | else | 282 | else |
283 | // switch time down, cursor location depend | 283 | // switch time down, cursor location depend |
284 | switch (cpos) { | 284 | switch (cpos) { |
285 | case 7: | 285 | case 7: |
286 | case 6: | 286 | case 6: |
287 | case 5: | 287 | case 5: |
288 | if(!hour12Format) { | 288 | if(!hour12Format) { |
289 | lineEdit()->setCursorPosition(cpos = 4); | 289 | lineEdit()->setCursorPosition(cpos = 4); |
290 | } else { | 290 | } else { |
291 | subTime(QTime(12,0,0), false ); | 291 | subTime(QTime(12,0,0), false ); |
292 | setSelect ( 5 , 2 ); | 292 | setSelect ( 5 , 2 ); |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | case 4: | 295 | case 4: |
296 | subTime(QTime(0,1,0), false ); | 296 | subTime(QTime(0,1,0), false ); |
297 | setSelect ( cpos , 1 ); | 297 | setSelect ( cpos , 1 ); |
298 | break; | 298 | break; |
299 | case 3: | 299 | case 3: |
300 | subTime(QTime(0,10,0), false ); | 300 | subTime(QTime(0,10,0), false ); |
301 | setSelect ( cpos , 1 ); | 301 | setSelect ( cpos , 1 ); |
302 | break; | 302 | break; |
303 | case 2: | 303 | case 2: |
304 | lineEdit()->setCursorPosition(--cpos); | 304 | lineEdit()->setCursorPosition(--cpos); |
305 | case 1: | 305 | case 1: |
306 | case 0: | 306 | case 0: |
307 | subTime(QTime(1,0,0), false ); | 307 | subTime(QTime(1,0,0), false ); |
308 | setSelect ( 0 , 2 ); | 308 | setSelect ( 0 , 2 ); |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | break; | 311 | break; |
312 | // set cursor to correct place | 312 | // set cursor to correct place |
313 | case Key_Left: | 313 | case Key_Left: |
314 | if ( cpos == 3 ) | 314 | if ( cpos == 3 ) |
315 | --cpos; | 315 | --cpos; |
316 | if ( cpos > 0) { | 316 | if ( cpos > 0) { |
317 | lineEdit()->setCursorPosition(--cpos); | 317 | lineEdit()->setCursorPosition(--cpos); |
318 | setSelect ( cpos , 1 ); | 318 | setSelect ( cpos , 1 ); |
319 | } | 319 | } |
320 | else | 320 | else |
321 | setSelect ( 0 , 1 ); | 321 | setSelect ( 0 , 1 ); |
322 | break; | 322 | break; |
323 | // set cursor to correct place | 323 | // set cursor to correct place |
324 | case Key_Right: | 324 | case Key_Right: |
325 | if ( cpos == 1 ) | 325 | if ( cpos == 1 ) |
326 | ++cpos; | 326 | ++cpos; |
327 | if ( cpos < maxpos ) { | 327 | if ( cpos < maxpos ) { |
328 | lineEdit()->setCursorPosition(++cpos); | 328 | lineEdit()->setCursorPosition(++cpos); |
329 | setSelect ( cpos , 1 ); | 329 | setSelect ( cpos , 1 ); |
330 | } | 330 | } |
331 | break; | 331 | break; |
332 | // rest | 332 | // rest |
333 | case Key_Prior: | 333 | case Key_Prior: |
334 | subTime(QTime(1,0,0)); | 334 | subTime(QTime(1,0,0)); |
335 | break; | 335 | break; |
336 | case Key_Next: | 336 | case Key_Next: |
337 | addTime(QTime(1,0,0)); | 337 | addTime(QTime(1,0,0)); |
338 | break; | 338 | break; |
339 | case Key_Backspace: | 339 | case Key_Backspace: |
340 | qDebug("+++++++++++back "); | ||
341 | if ( cpos > 0) { | 340 | if ( cpos > 0) { |
342 | if ( cpos == 3 ) | 341 | if ( cpos == 3 ) |
343 | --cpos; | 342 | --cpos; |
344 | if ( cpos > 5) | 343 | if ( cpos > 5) |
345 | cpos = 5; | 344 | cpos = 5; |
346 | text.at( cpos-1 ) = '0'; | 345 | text.at( cpos-1 ) = '0'; |
347 | lineEdit()->setText( text ); | 346 | lineEdit()->setText( text ); |
348 | lineEdit()->setCursorPosition(--cpos); | 347 | lineEdit()->setCursorPosition(--cpos); |
349 | setSelect ( cpos , 1 ); | 348 | setSelect ( cpos , 1 ); |
350 | changedText(); | 349 | changedText(); |
351 | qDebug("---------back "); | ||
352 | } | 350 | } |
353 | break; | 351 | break; |
354 | } // switch arrows | 352 | } // switch arrows |
355 | 353 | ||
356 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos | 354 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos |
357 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { | 355 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { |
358 | lineEdit()->deselect(); | 356 | lineEdit()->deselect(); |
359 | cpos = 0; | 357 | cpos = 0; |
360 | lineEdit()->setCursorPosition(cpos); | 358 | lineEdit()->setCursorPosition(cpos); |
361 | setSelect(cpos , 1); | 359 | setSelect(cpos , 1); |
362 | } | 360 | } |
363 | 361 | ||
364 | if ( cpos == 2 ) { | 362 | if ( cpos == 2 ) { |
365 | lineEdit()->setCursorPosition(++cpos); | 363 | lineEdit()->setCursorPosition(++cpos); |
366 | } | 364 | } |
367 | 365 | ||
368 | // num keys when cursorPos preEnd | 366 | // num keys when cursorPos preEnd |
369 | if ( cpos < 5 ) { | 367 | if ( cpos < 5 ) { |
370 | // switch another keys | 368 | // switch another keys |
371 | switch(e->key()) { | 369 | switch(e->key()) { |
372 | case Key_Delete: | 370 | case Key_Delete: |
373 | text.at( cpos ) = '0'; | 371 | text.at( cpos ) = '0'; |
374 | lineEdit()->setText( text ); | 372 | lineEdit()->setText( text ); |
375 | lineEdit()->setCursorPosition(cpos); | 373 | lineEdit()->setCursorPosition(cpos); |
376 | setSelect ( cpos , 1 ); | 374 | setSelect ( cpos , 1 ); |
377 | changedText(); | 375 | changedText(); |
378 | break; | 376 | break; |
379 | case Key_9: | 377 | case Key_9: |
380 | case Key_8: | 378 | case Key_8: |
381 | case Key_7: | 379 | case Key_7: |
382 | case Key_6: | 380 | case Key_6: |
383 | if ( !(cpos == 1 || cpos == 4) ) | 381 | if ( !(cpos == 1 || cpos == 4) ) |
384 | return; | 382 | return; |
385 | if ( cpos == 1 && text.at( 0 ) > '1') | 383 | if ( cpos == 1 && text.at( 0 ) > '1') |
386 | text.at( 0 ) = '1'; | 384 | text.at( 0 ) = '1'; |
387 | case Key_5: | 385 | case Key_5: |
388 | case Key_4: | 386 | case Key_4: |
389 | case Key_3: | 387 | case Key_3: |
390 | if ( cpos < 1 ) | 388 | if ( cpos < 1 ) |
391 | return; | 389 | return; |
392 | if ( hour12Format && cpos == 1 ) | 390 | if ( hour12Format && cpos == 1 ) |
393 | return; | 391 | return; |
394 | case Key_2: | 392 | case Key_2: |
395 | if ( hour12Format && cpos == 0 ) | 393 | if ( hour12Format && cpos == 0 ) |
396 | return; | 394 | return; |
397 | if ( cpos == 0 && text.at( 1 ) > '3') | 395 | if ( cpos == 0 && text.at( 1 ) > '3') |
398 | text.at( 1 ) = '3'; | 396 | text.at( 1 ) = '3'; |
399 | case Key_1: | 397 | case Key_1: |
400 | case Key_0: | 398 | case Key_0: |
401 | if ( hour12Format ) { | 399 | if ( hour12Format ) { |
402 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) | 400 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) |
403 | return; | 401 | return; |
404 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) | 402 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) |
405 | text.at( 1 ) = '1'; | 403 | text.at( 1 ) = '1'; |
406 | } | 404 | } |
407 | text.at( cpos ) = QChar ( e->key() ); | 405 | text.at( cpos ) = QChar ( e->key() ); |
408 | lineEdit()->setText( text ); | 406 | lineEdit()->setText( text ); |
409 | if ( cpos == 1 ) | 407 | if ( cpos == 1 ) |
410 | ++cpos; | 408 | ++cpos; |
411 | if ( cpos < 5) | 409 | if ( cpos < 5) |
412 | lineEdit()->setCursorPosition(++cpos); | 410 | lineEdit()->setCursorPosition(++cpos); |
413 | setSelect( cpos , 1 ); | 411 | setSelect( cpos , 1 ); |
414 | changedText(); | 412 | changedText(); |
415 | break; | 413 | break; |
416 | case Key_Home: | 414 | case Key_Home: |
417 | lineEdit()->setCursorPosition(0); | 415 | lineEdit()->setCursorPosition(0); |
418 | setSelect( cpos , 1 ); | 416 | setSelect( cpos , 1 ); |
419 | break; | 417 | break; |
420 | case Key_End: | 418 | case Key_End: |
421 | lineEdit()->setCursorPosition(5); | 419 | lineEdit()->setCursorPosition(5); |
422 | lineEdit()->deselect(); | 420 | lineEdit()->deselect(); |
423 | break; | 421 | break; |
424 | default: | 422 | default: |
425 | // QComboBox::keyPressEvent(e); | 423 | // QComboBox::keyPressEvent(e); |
426 | break; | 424 | break; |
427 | } // switch num keys | 425 | } // switch num keys |
428 | } else if ( cpos == 5 ) {// if cpos < 5 | 426 | } else if ( cpos == 5 ) {// if cpos < 5 |
429 | if ( hour12Format ) { | 427 | if ( hour12Format ) { |
430 | if ( e->key() == Key_A ) { | 428 | if ( e->key() == Key_A ) { |
431 | text.at( 5 ) = 'a'; | 429 | text.at( 5 ) = 'a'; |
432 | lineEdit()->setText( text ); | 430 | lineEdit()->setText( text ); |
433 | lineEdit()->setCursorPosition(5); | 431 | lineEdit()->setCursorPosition(5); |
434 | 432 | ||
435 | } else if ( e->key() == Key_P ) { | 433 | } else if ( e->key() == Key_P ) { |
436 | text.at( 5 ) = 'p'; | 434 | text.at( 5 ) = 'p'; |
437 | lineEdit()->setText( text ); | 435 | lineEdit()->setText( text ); |
438 | lineEdit()->setCursorPosition(5); | 436 | lineEdit()->setCursorPosition(5); |
439 | 437 | ||
440 | } | 438 | } |
441 | } | 439 | } |
442 | } | 440 | } |
443 | 441 | ||
444 | 442 | ||
445 | } | 443 | } |
446 | 444 | ||
447 | void KOTimeEdit::updateText() | 445 | void KOTimeEdit::updateText() |
448 | { | 446 | { |
449 | listBox()->blockSignals( true ); | 447 | listBox()->blockSignals( true ); |
450 | blockSignals( true ); | 448 | blockSignals( true ); |
451 | QString s = KGlobal::locale()->formatTime(mTime); | 449 | QString s = KGlobal::locale()->formatTime(mTime); |
452 | // Set the text but without emitting signals, nor losing the cursor position | 450 | // Set the text but without emitting signals, nor losing the cursor position |
453 | QLineEdit *line = lineEdit(); | 451 | QLineEdit *line = lineEdit(); |
454 | line->blockSignals(true); | 452 | line->blockSignals(true); |
455 | int pos = line->cursorPosition(); | 453 | int pos = line->cursorPosition(); |
456 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); | 454 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
457 | line->setText(s); | 455 | line->setText(s); |
458 | line->setCursorPosition(pos); | 456 | line->setCursorPosition(pos); |
459 | line->blockSignals(false); | 457 | line->blockSignals(false); |
460 | blockSignals( false ); | 458 | blockSignals( false ); |
461 | listBox()->blockSignals( false ); | 459 | listBox()->blockSignals( false ); |
462 | 460 | ||
463 | } | 461 | } |
464 | 462 | ||
465 | void KOTimeEdit::changedText() | 463 | void KOTimeEdit::changedText() |
466 | { | 464 | { |
467 | int pos = lineEdit()->cursorPosition(); | 465 | int pos = lineEdit()->cursorPosition(); |
468 | mTime = getTime(); | 466 | mTime = getTime(); |
469 | blockSignals( true ); | 467 | blockSignals( true ); |
470 | QString text = lineEdit()->text(); | 468 | QString text = lineEdit()->text(); |
471 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); | 469 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
472 | lineEdit()->setText(text); | 470 | lineEdit()->setText(text); |
473 | blockSignals( false ); | 471 | blockSignals( false ); |
474 | emit timeChanged(mTime); | 472 | emit timeChanged(mTime); |
475 | lineEdit()->setCursorPosition(pos); | 473 | lineEdit()->setCursorPosition(pos); |
476 | } | 474 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 8e5d108..95bef66 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,619 +1,617 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "ktoolbar.h" | 60 | #include "ktoolbar.h" |
61 | #include "klocale.h" | 61 | #include "klocale.h" |
62 | #include "kconfig.h" | 62 | #include "kconfig.h" |
63 | #include "simplealarmclient.h" | ||
64 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
65 | 64 | ||
66 | using namespace KCal; | 65 | using namespace KCal; |
67 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
68 | #include <unistd.h> | 67 | #include <unistd.h> |
69 | #else | 68 | #else |
70 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
71 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
72 | #endif | 71 | #endif |
73 | #endif | 72 | #endif |
74 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
75 | 74 | ||
76 | 75 | ||
77 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
78 | { | 77 | { |
79 | public: | 78 | public: |
80 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
81 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
82 | { | 81 | { |
83 | setCaption( i18n("Export to phone options") ); | 82 | setCaption( i18n("Export to phone options") ); |
84 | QVBoxLayout* lay = new QVBoxLayout( this ); | 83 | QVBoxLayout* lay = new QVBoxLayout( this ); |
85 | lay->setSpacing( 3 ); | 84 | lay->setSpacing( 3 ); |
86 | lay->setMargin( 3 ); | 85 | lay->setMargin( 3 ); |
87 | QLabel *lab; | 86 | QLabel *lab; |
88 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
89 | lab->setAlignment (AlignHCenter ); | 88 | lab->setAlignment (AlignHCenter ); |
90 | QHBox* temphb; | 89 | QHBox* temphb; |
91 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("I/O device: "), temphb ); | 91 | new QLabel( i18n("I/O device: "), temphb ); |
93 | mPhoneDevice = new QLineEdit( temphb); | 92 | mPhoneDevice = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Connection: "), temphb ); | 95 | new QLabel( i18n("Connection: "), temphb ); |
97 | mPhoneConnection = new QLineEdit( temphb); | 96 | mPhoneConnection = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
99 | temphb = new QHBox( this ); | 98 | temphb = new QHBox( this ); |
100 | new QLabel( i18n("Model(opt.): "), temphb ); | 99 | new QLabel( i18n("Model(opt.): "), temphb ); |
101 | mPhoneModel = new QLineEdit( temphb); | 100 | mPhoneModel = new QLineEdit( temphb); |
102 | lay->addWidget( temphb ); | 101 | lay->addWidget( temphb ); |
103 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
104 | mWriteBackFuture->setChecked( true ); | 103 | mWriteBackFuture->setChecked( true ); |
105 | lay->addWidget( mWriteBackFuture ); | 104 | lay->addWidget( mWriteBackFuture ); |
106 | temphb = new QHBox( this ); | 105 | temphb = new QHBox( this ); |
107 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
108 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
109 | mWriteBackFutureWeeks->setValue( 8 ); | 108 | mWriteBackFutureWeeks->setValue( 8 ); |
110 | lay->addWidget( temphb ); | 109 | lay->addWidget( temphb ); |
111 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
112 | lab->setAlignment (AlignHCenter ); | 111 | lab->setAlignment (AlignHCenter ); |
113 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
114 | lay->addWidget( ok ); | 113 | lay->addWidget( ok ); |
115 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
116 | lay->addWidget( cancel ); | 115 | lay->addWidget( cancel ); |
117 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
118 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
119 | resize( 220, 240 ); | 118 | resize( 220, 240 ); |
120 | qApp->processEvents(); | 119 | qApp->processEvents(); |
121 | int dw = QApplication::desktop()->width(); | 120 | int dw = QApplication::desktop()->width(); |
122 | int dh = QApplication::desktop()->height(); | 121 | int dh = QApplication::desktop()->height(); |
123 | move( (dw-width())/2, (dh - height() )/2 ); | 122 | move( (dw-width())/2, (dh - height() )/2 ); |
124 | } | 123 | } |
125 | 124 | ||
126 | public: | 125 | public: |
127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
128 | QCheckBox* mWriteBackFuture; | 127 | QCheckBox* mWriteBackFuture; |
129 | QSpinBox* mWriteBackFutureWeeks; | 128 | QSpinBox* mWriteBackFutureWeeks; |
130 | }; | 129 | }; |
131 | 130 | ||
132 | int globalFlagBlockStartup; | 131 | int globalFlagBlockStartup; |
133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 132 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
134 | QMainWindow( parent, name ) | 133 | QMainWindow( parent, name ) |
135 | { | 134 | { |
136 | 135 | ||
137 | mClosed = false; | 136 | mClosed = false; |
138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 137 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
139 | QString confFile = locateLocal("config","korganizerrc"); | 138 | QString confFile = locateLocal("config","korganizerrc"); |
140 | QFileInfo finf ( confFile ); | 139 | QFileInfo finf ( confFile ); |
141 | bool showWarning = !finf.exists(); | 140 | bool showWarning = !finf.exists(); |
142 | setIcon(SmallIcon( "ko24" ) ); | 141 | setIcon(SmallIcon( "ko24" ) ); |
143 | mBlockAtStartup = true; | 142 | mBlockAtStartup = true; |
144 | mFlagKeyPressed = false; | 143 | mFlagKeyPressed = false; |
145 | setCaption("KO/Pi"); | 144 | setCaption("KO/Pi"); |
146 | KOPrefs *p = KOPrefs::instance(); | 145 | KOPrefs *p = KOPrefs::instance(); |
147 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 146 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
148 | p->mCurrentDisplayedView = 0; | 147 | p->mCurrentDisplayedView = 0; |
149 | if ( p->mHourSize > 22 ) | 148 | if ( p->mHourSize > 22 ) |
150 | p->mHourSize = 22; | 149 | p->mHourSize = 22; |
151 | QMainWindow::ToolBarDock tbd; | 150 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 151 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 152 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 153 | tbd = Bottom; |
155 | else | 154 | else |
156 | tbd = Top; | 155 | tbd = Top; |
157 | } | 156 | } |
158 | else { | 157 | else { |
159 | if ( p->mToolBarUp ) | 158 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 159 | tbd = Right; |
161 | else | 160 | else |
162 | tbd = Left; | 161 | tbd = Left; |
163 | } | 162 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 163 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 164 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 165 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 166 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 167 | addToolBar (iconToolBar , tbd ); |
169 | 168 | ||
170 | #ifdef DESKTOP_VERSION | 169 | #ifdef DESKTOP_VERSION |
171 | if ( KOPrefs::instance()->mShowIconFilter ) | 170 | if ( KOPrefs::instance()->mShowIconFilter ) |
172 | #else | 171 | #else |
173 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) | 172 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) |
174 | #endif | 173 | #endif |
175 | 174 | ||
176 | { | 175 | { |
177 | if ( p->mToolBarHorF ) { | 176 | if ( p->mToolBarHorF ) { |
178 | if ( p->mToolBarUpF ) | 177 | if ( p->mToolBarUpF ) |
179 | tbd = Bottom; | 178 | tbd = Bottom; |
180 | else | 179 | else |
181 | tbd = Top; | 180 | tbd = Top; |
182 | } | 181 | } |
183 | else { | 182 | else { |
184 | if ( p->mToolBarUpF ) | 183 | if ( p->mToolBarUpF ) |
185 | tbd = Right; | 184 | tbd = Right; |
186 | else | 185 | else |
187 | tbd = Left; | 186 | tbd = Left; |
188 | } | 187 | } |
189 | filterToolBar = new QPEToolBar ( this ); | 188 | filterToolBar = new QPEToolBar ( this ); |
190 | filterMenubar = new QPEMenuBar( filterToolBar ); | 189 | filterMenubar = new QPEMenuBar( filterToolBar ); |
191 | QFontMetrics fm ( filterMenubar->font() ); | 190 | QFontMetrics fm ( filterMenubar->font() ); |
192 | 191 | ||
193 | filterPopupMenu = new QPopupMenu( this ); | 192 | filterPopupMenu = new QPopupMenu( this ); |
194 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 193 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
195 | QString addTest = "Ax"; | 194 | QString addTest = "Ax"; |
196 | #ifdef DESKTOP_VERSION | 195 | #ifdef DESKTOP_VERSION |
197 | addTest = "AAAx"; | 196 | addTest = "AAAx"; |
198 | #endif | 197 | #endif |
199 | filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); | 198 | filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); |
200 | addToolBar (filterToolBar , tbd ); | 199 | addToolBar (filterToolBar , tbd ); |
201 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 200 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
202 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 201 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
203 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 202 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
204 | filterToolBar->hide(); | 203 | filterToolBar->hide(); |
205 | } else { | 204 | } else { |
206 | filterToolBar = 0; | 205 | filterToolBar = 0; |
207 | filterMenubar = 0; | 206 | filterMenubar = 0; |
208 | filterPopupMenu = 0; | 207 | filterPopupMenu = 0; |
209 | } | 208 | } |
210 | if ( p->mShowIconOnetoolbar ) { | 209 | if ( p->mShowIconOnetoolbar ) { |
211 | viewToolBar = iconToolBar ; | 210 | viewToolBar = iconToolBar ; |
212 | navigatorToolBar = iconToolBar ; | 211 | navigatorToolBar = iconToolBar ; |
213 | } else { | 212 | } else { |
214 | #ifndef DESKTOP_VERSION | 213 | #ifndef DESKTOP_VERSION |
215 | setToolBarsMovable( false ); | 214 | setToolBarsMovable( false ); |
216 | #endif | 215 | #endif |
217 | if ( p->mToolBarHorV ) { | 216 | if ( p->mToolBarHorV ) { |
218 | if ( p->mToolBarUpV ) | 217 | if ( p->mToolBarUpV ) |
219 | tbd = Bottom; | 218 | tbd = Bottom; |
220 | else | 219 | else |
221 | tbd = Top; | 220 | tbd = Top; |
222 | } | 221 | } |
223 | else { | 222 | else { |
224 | if ( p->mToolBarUpV ) | 223 | if ( p->mToolBarUpV ) |
225 | tbd = Right; | 224 | tbd = Right; |
226 | else | 225 | else |
227 | tbd = Left; | 226 | tbd = Left; |
228 | } | 227 | } |
229 | viewToolBar = new QPEToolBar( this ); | 228 | viewToolBar = new QPEToolBar( this ); |
230 | addToolBar (viewToolBar , tbd ); | 229 | addToolBar (viewToolBar , tbd ); |
231 | if ( p->mToolBarHorN ) { | 230 | if ( p->mToolBarHorN ) { |
232 | if ( p->mToolBarUpN ) | 231 | if ( p->mToolBarUpN ) |
233 | tbd = Bottom; | 232 | tbd = Bottom; |
234 | else | 233 | else |
235 | tbd = Top; | 234 | tbd = Top; |
236 | } | 235 | } |
237 | else { | 236 | else { |
238 | if ( p->mToolBarUpN ) | 237 | if ( p->mToolBarUpN ) |
239 | tbd = Right; | 238 | tbd = Right; |
240 | else | 239 | else |
241 | tbd = Left; | 240 | tbd = Left; |
242 | } | 241 | } |
243 | navigatorToolBar = new QPEToolBar( this ); | 242 | navigatorToolBar = new QPEToolBar( this ); |
244 | addToolBar (navigatorToolBar , tbd ); | 243 | addToolBar (navigatorToolBar , tbd ); |
245 | } | 244 | } |
246 | 245 | ||
247 | 246 | ||
248 | 247 | ||
249 | mCalendarModifiedFlag = false; | 248 | mCalendarModifiedFlag = false; |
250 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 249 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
251 | splash->setAlignment ( AlignCenter ); | 250 | splash->setAlignment ( AlignCenter ); |
252 | setCentralWidget( splash ); | 251 | setCentralWidget( splash ); |
253 | #ifndef DESKTOP_VERSION | 252 | #ifndef DESKTOP_VERSION |
254 | showMaximized(); | 253 | showMaximized(); |
255 | #endif | 254 | #endif |
256 | 255 | ||
257 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 256 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
258 | setDefaultPreferences(); | 257 | setDefaultPreferences(); |
259 | mCalendar = new CalendarLocal(); | 258 | mCalendar = new CalendarLocal(); |
260 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 259 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
261 | mView->hide(); | 260 | mView->hide(); |
262 | //mView->resize(splash->size() ); | 261 | //mView->resize(splash->size() ); |
263 | initActions(); | 262 | initActions(); |
264 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 263 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
265 | mSyncManager->setBlockSave(false); | 264 | mSyncManager->setBlockSave(false); |
266 | mView->setSyncManager(mSyncManager); | 265 | mView->setSyncManager(mSyncManager); |
267 | #ifndef DESKTOP_VERSION | 266 | #ifndef DESKTOP_VERSION |
268 | iconToolBar->show(); | 267 | iconToolBar->show(); |
269 | qApp->processEvents(); | 268 | qApp->processEvents(); |
270 | #endif | 269 | #endif |
271 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 270 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
272 | int vh = height() ; | 271 | int vh = height() ; |
273 | int vw = width(); | 272 | int vw = width(); |
274 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 273 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
275 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 274 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
276 | vh -= iconToolBar->height(); | 275 | vh -= iconToolBar->height(); |
277 | } else { | 276 | } else { |
278 | vw -= iconToolBar->height(); | 277 | vw -= iconToolBar->height(); |
279 | } | 278 | } |
280 | //mView->setMaximumSize( splash->size() ); | 279 | //mView->setMaximumSize( splash->size() ); |
281 | //mView->resize( splash->size() ); | 280 | //mView->resize( splash->size() ); |
282 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 281 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
283 | mView->readSettings(); | 282 | mView->readSettings(); |
284 | bool newFile = false; | 283 | bool newFile = false; |
285 | if( !QFile::exists( defaultFileName() ) ) { | 284 | if( !QFile::exists( defaultFileName() ) ) { |
286 | QFileInfo finfo ( defaultFileName() ); | 285 | QFileInfo finfo ( defaultFileName() ); |
287 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 286 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
288 | qDebug("oldfile %s ", oldFile.latin1()); | ||
289 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 287 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
290 | finfo.setFile( oldFile ); | 288 | finfo.setFile( oldFile ); |
291 | if (finfo.exists() ) { | 289 | if (finfo.exists() ) { |
292 | KMessageBox::information( this, message); | 290 | KMessageBox::information( this, message); |
293 | mView->openCalendar( oldFile ); | 291 | mView->openCalendar( oldFile ); |
294 | qApp->processEvents(); | 292 | qApp->processEvents(); |
295 | } else { | 293 | } else { |
296 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 294 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
297 | finfo.setFile( oldFile ); | 295 | finfo.setFile( oldFile ); |
298 | if (finfo.exists() ) { | 296 | if (finfo.exists() ) { |
299 | KMessageBox::information( this, message); | 297 | KMessageBox::information( this, message); |
300 | mView->openCalendar( oldFile ); | 298 | mView->openCalendar( oldFile ); |
301 | qApp->processEvents(); | 299 | qApp->processEvents(); |
302 | } | 300 | } |
303 | } | 301 | } |
304 | mView->saveCalendar( defaultFileName() ); | 302 | mView->saveCalendar( defaultFileName() ); |
305 | newFile = true; | 303 | newFile = true; |
306 | } | 304 | } |
307 | 305 | ||
308 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 306 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
309 | mView->openCalendar( defaultFileName() ); | 307 | mView->openCalendar( defaultFileName() ); |
310 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 308 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
311 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 309 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
312 | 310 | ||
313 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 311 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
314 | KOPrefs::instance()->setAllDefaults(); | 312 | KOPrefs::instance()->setAllDefaults(); |
315 | int count = mView->addCategories(); | 313 | int count = mView->addCategories(); |
316 | } | 314 | } |
317 | processIncidenceSelection( 0 ); | 315 | processIncidenceSelection( 0 ); |
318 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 316 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
319 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 317 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
320 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 318 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
321 | SLOT( slotModifiedChanged( bool ) ) ); | 319 | SLOT( slotModifiedChanged( bool ) ) ); |
322 | 320 | ||
323 | 321 | ||
324 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 322 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
325 | SLOT( disableBR(bool) ) ); | 323 | SLOT( disableBR(bool) ) ); |
326 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 324 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
327 | mView->setModified( false ); | 325 | mView->setModified( false ); |
328 | mBlockAtStartup = false; | 326 | mBlockAtStartup = false; |
329 | mView->setModified( false ); | 327 | mView->setModified( false ); |
330 | setCentralWidget( mView ); | 328 | setCentralWidget( mView ); |
331 | globalFlagBlockStartup = 0; | 329 | globalFlagBlockStartup = 0; |
332 | mView->show(); | 330 | mView->show(); |
333 | delete splash; | 331 | delete splash; |
334 | if ( newFile ) | 332 | if ( newFile ) |
335 | mView->updateConfig(); | 333 | mView->updateConfig(); |
336 | // qApp->processEvents(); | 334 | // qApp->processEvents(); |
337 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 335 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
338 | //fillSyncMenu(); | 336 | //fillSyncMenu(); |
339 | 337 | ||
340 | 338 | ||
341 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 339 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
342 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 340 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
343 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 341 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
344 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 342 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
345 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 343 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
346 | mSyncManager->setDefaultFileName( sentSyncFile()); | 344 | mSyncManager->setDefaultFileName( sentSyncFile()); |
347 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 345 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
348 | mSyncManager->fillSyncMenu(); | 346 | mSyncManager->fillSyncMenu(); |
349 | 347 | ||
350 | 348 | ||
351 | 349 | ||
352 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 350 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
353 | if ( showWarning ) { | 351 | if ( showWarning ) { |
354 | KMessageBox::information( this, | 352 | KMessageBox::information( this, |
355 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 353 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
356 | qApp->processEvents(); | 354 | qApp->processEvents(); |
357 | mView->dialogManager()->showSyncOptions(); | 355 | mView->dialogManager()->showSyncOptions(); |
358 | } | 356 | } |
359 | 357 | ||
360 | //US listen for result adressed from Ka/Pi | 358 | //US listen for result adressed from Ka/Pi |
361 | #ifndef DESKTOP_VERSION | 359 | #ifndef DESKTOP_VERSION |
362 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 360 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
363 | #endif | 361 | #endif |
364 | #ifndef DESKTOP_VERSION | 362 | #ifndef DESKTOP_VERSION |
365 | infrared = 0; | 363 | infrared = 0; |
366 | #endif | 364 | #endif |
367 | updateFilterToolbar(); | 365 | updateFilterToolbar(); |
368 | updateWeek( mView->startDate() ); | 366 | updateWeek( mView->startDate() ); |
369 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 367 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
370 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 368 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
371 | mBRdisabled = false; | 369 | mBRdisabled = false; |
372 | //toggleBeamReceive(); | 370 | //toggleBeamReceive(); |
373 | } | 371 | } |
374 | MainWindow::~MainWindow() | 372 | MainWindow::~MainWindow() |
375 | { | 373 | { |
376 | //qDebug("MainWindow::~MainWindow() "); | 374 | //qDebug("MainWindow::~MainWindow() "); |
377 | //save toolbar location | 375 | //save toolbar location |
378 | delete mCalendar; | 376 | delete mCalendar; |
379 | delete mSyncManager; | 377 | delete mSyncManager; |
380 | #ifndef DESKTOP_VERSION | 378 | #ifndef DESKTOP_VERSION |
381 | if ( infrared ) | 379 | if ( infrared ) |
382 | delete infrared; | 380 | delete infrared; |
383 | #endif | 381 | #endif |
384 | 382 | ||
385 | 383 | ||
386 | } | 384 | } |
387 | 385 | ||
388 | void MainWindow::disableBR(bool b) | 386 | void MainWindow::disableBR(bool b) |
389 | { | 387 | { |
390 | #ifndef DESKTOP_VERSION | 388 | #ifndef DESKTOP_VERSION |
391 | if ( b ) { | 389 | if ( b ) { |
392 | if ( infrared ) { | 390 | if ( infrared ) { |
393 | toggleBeamReceive(); | 391 | toggleBeamReceive(); |
394 | mBRdisabled = true; | 392 | mBRdisabled = true; |
395 | } | 393 | } |
396 | mBRdisabled = true; | 394 | mBRdisabled = true; |
397 | } else { | 395 | } else { |
398 | if ( mBRdisabled ) { | 396 | if ( mBRdisabled ) { |
399 | mBRdisabled = false; | 397 | mBRdisabled = false; |
400 | //makes no sense,because other cal ap is probably running | 398 | //makes no sense,because other cal ap is probably running |
401 | // toggleBeamReceive(); | 399 | // toggleBeamReceive(); |
402 | } | 400 | } |
403 | } | 401 | } |
404 | #endif | 402 | #endif |
405 | 403 | ||
406 | } | 404 | } |
407 | bool MainWindow::beamReceiveEnabled() | 405 | bool MainWindow::beamReceiveEnabled() |
408 | { | 406 | { |
409 | #ifndef DESKTOP_VERSION | 407 | #ifndef DESKTOP_VERSION |
410 | return ( infrared != 0 ); | 408 | return ( infrared != 0 ); |
411 | #endif | 409 | #endif |
412 | return false; | 410 | return false; |
413 | } | 411 | } |
414 | 412 | ||
415 | void MainWindow::toggleBeamReceive() | 413 | void MainWindow::toggleBeamReceive() |
416 | { | 414 | { |
417 | if ( mBRdisabled ) | 415 | if ( mBRdisabled ) |
418 | return; | 416 | return; |
419 | #ifndef DESKTOP_VERSION | 417 | #ifndef DESKTOP_VERSION |
420 | if ( infrared ) { | 418 | if ( infrared ) { |
421 | qDebug("disable BeamReceive "); | 419 | qDebug("KO: Disable BeamReceive "); |
422 | delete infrared; | 420 | delete infrared; |
423 | infrared = 0; | 421 | infrared = 0; |
424 | brAction->setOn(false); | 422 | brAction->setOn(false); |
425 | return; | 423 | return; |
426 | } | 424 | } |
427 | qDebug("enable BeamReceive "); | 425 | qDebug("KO: Enable BeamReceive "); |
428 | brAction->setOn(true); | 426 | brAction->setOn(true); |
429 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 427 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
430 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 428 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
431 | #endif | 429 | #endif |
432 | } | 430 | } |
433 | void MainWindow::showMaximized () | 431 | void MainWindow::showMaximized () |
434 | { | 432 | { |
435 | #ifndef DESKTOP_VERSION | 433 | #ifndef DESKTOP_VERSION |
436 | if ( ! globalFlagBlockStartup ) | 434 | if ( ! globalFlagBlockStartup ) |
437 | if ( mClosed ) | 435 | if ( mClosed ) |
438 | mView->goToday(); | 436 | mView->goToday(); |
439 | #endif | 437 | #endif |
440 | QWidget::showMaximized () ; | 438 | QWidget::showMaximized () ; |
441 | mClosed = false; | 439 | mClosed = false; |
442 | } | 440 | } |
443 | void MainWindow::closeEvent( QCloseEvent* ce ) | 441 | void MainWindow::closeEvent( QCloseEvent* ce ) |
444 | { | 442 | { |
445 | 443 | ||
446 | 444 | ||
447 | 445 | ||
448 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 446 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
449 | saveOnClose(); | 447 | saveOnClose(); |
450 | mClosed = true; | 448 | mClosed = true; |
451 | ce->accept(); | 449 | ce->accept(); |
452 | return; | 450 | return; |
453 | 451 | ||
454 | } | 452 | } |
455 | 453 | ||
456 | switch( QMessageBox::information( this, "KO/Pi", | 454 | switch( QMessageBox::information( this, "KO/Pi", |
457 | i18n("Do you really want\nto close KO/Pi?"), | 455 | i18n("Do you really want\nto close KO/Pi?"), |
458 | i18n("Close"), i18n("No"), | 456 | i18n("Close"), i18n("No"), |
459 | 0, 0 ) ) { | 457 | 0, 0 ) ) { |
460 | case 0: | 458 | case 0: |
461 | saveOnClose(); | 459 | saveOnClose(); |
462 | mClosed = true; | 460 | mClosed = true; |
463 | ce->accept(); | 461 | ce->accept(); |
464 | break; | 462 | break; |
465 | case 1: | 463 | case 1: |
466 | ce->ignore(); | 464 | ce->ignore(); |
467 | break; | 465 | break; |
468 | case 2: | 466 | case 2: |
469 | 467 | ||
470 | default: | 468 | default: |
471 | break; | 469 | break; |
472 | } | 470 | } |
473 | 471 | ||
474 | 472 | ||
475 | } | 473 | } |
476 | 474 | ||
477 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 475 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
478 | { | 476 | { |
479 | QDataStream stream( data, IO_ReadOnly ); | 477 | QDataStream stream( data, IO_ReadOnly ); |
480 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 478 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
481 | //QString datamess; | 479 | //QString datamess; |
482 | //qDebug("message "); | 480 | //qDebug("message "); |
483 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 481 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
484 | 482 | ||
485 | if ( cmsg == "setDocument(QString)" ) { | 483 | if ( cmsg == "setDocument(QString)" ) { |
486 | QDataStream stream( data, IO_ReadOnly ); | 484 | QDataStream stream( data, IO_ReadOnly ); |
487 | QString fileName; | 485 | QString fileName; |
488 | stream >> fileName; | 486 | stream >> fileName; |
489 | //qDebug("filename %s ", fileName.latin1()); | 487 | //qDebug("filename %s ", fileName.latin1()); |
490 | showMaximized(); | 488 | showMaximized(); |
491 | raise(); | 489 | raise(); |
492 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 490 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
493 | mSyncManager->slotSyncMenu( 1002 ); | 491 | mSyncManager->slotSyncMenu( 1002 ); |
494 | return; | 492 | return; |
495 | } | 493 | } |
496 | 494 | ||
497 | if ( cmsg == "-writeFile" ) { | 495 | if ( cmsg == "-writeFile" ) { |
498 | // I made from the "-writeFile" an "-writeAlarm" | 496 | // I made from the "-writeFile" an "-writeAlarm" |
499 | mView->viewManager()->showWhatsNextView(); | 497 | mView->viewManager()->showWhatsNextView(); |
500 | mCalendar->checkAlarmForIncidence( 0, true); | 498 | mCalendar->checkAlarmForIncidence( 0, true); |
501 | showMaximized(); | 499 | showMaximized(); |
502 | raise(); | 500 | raise(); |
503 | return; | 501 | return; |
504 | 502 | ||
505 | } | 503 | } |
506 | if ( cmsg == "-writeFileSilent" ) { | 504 | if ( cmsg == "-writeFileSilent" ) { |
507 | // I made from the "-writeFile" an "-writeAlarm" | 505 | // I made from the "-writeFile" an "-writeAlarm" |
508 | // mView->viewManager()->showWhatsNextView(); | 506 | // mView->viewManager()->showWhatsNextView(); |
509 | mCalendar->checkAlarmForIncidence( 0, true); | 507 | mCalendar->checkAlarmForIncidence( 0, true); |
510 | //showMaximized(); | 508 | //showMaximized(); |
511 | //raise(); | 509 | //raise(); |
512 | hide(); | 510 | hide(); |
513 | return; | 511 | return; |
514 | } | 512 | } |
515 | if ( cmsg == "-newCountdown" ) { | 513 | if ( cmsg == "-newCountdown" ) { |
516 | qDebug("newCountdown "); | 514 | qDebug("newCountdown "); |
517 | 515 | ||
518 | } | 516 | } |
519 | QString msg ; | 517 | QString msg ; |
520 | QString allmsg = cmsg; | 518 | QString allmsg = cmsg; |
521 | while ( allmsg.length() > 0 ) { | 519 | while ( allmsg.length() > 0 ) { |
522 | int nextC = allmsg.find( "-", 1 ); | 520 | int nextC = allmsg.find( "-", 1 ); |
523 | if ( nextC == -1 ) { | 521 | if ( nextC == -1 ) { |
524 | msg = allmsg; | 522 | msg = allmsg; |
525 | allmsg = ""; | 523 | allmsg = ""; |
526 | } else{ | 524 | } else{ |
527 | msg = allmsg.left( nextC ); | 525 | msg = allmsg.left( nextC ); |
528 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 526 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
529 | } | 527 | } |
530 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 528 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
531 | if ( msg == "-newEvent" ) { | 529 | if ( msg == "-newEvent" ) { |
532 | mView->newEvent(); | 530 | mView->newEvent(); |
533 | } | 531 | } |
534 | if ( msg == "-newTodo" ) { | 532 | if ( msg == "-newTodo" ) { |
535 | mView->newTodo(); | 533 | mView->newTodo(); |
536 | 534 | ||
537 | } | 535 | } |
538 | if ( msg == "-showWN" ) { | 536 | if ( msg == "-showWN" ) { |
539 | mView->viewManager()->showWhatsNextView(); | 537 | mView->viewManager()->showWhatsNextView(); |
540 | } | 538 | } |
541 | if ( msg == "-showTodo" ) { | 539 | if ( msg == "-showTodo" ) { |
542 | mView->viewManager()->showTodoView(); | 540 | mView->viewManager()->showTodoView(); |
543 | } | 541 | } |
544 | if ( msg == "-showList" ) { | 542 | if ( msg == "-showList" ) { |
545 | mView->viewManager()->showListView(); | 543 | mView->viewManager()->showListView(); |
546 | } | 544 | } |
547 | else if ( msg == "-showDay" ) { | 545 | else if ( msg == "-showDay" ) { |
548 | mView->viewManager()->showDayView(); | 546 | mView->viewManager()->showDayView(); |
549 | } | 547 | } |
550 | else if ( msg == "-showWWeek" ) { | 548 | else if ( msg == "-showWWeek" ) { |
551 | mView->viewManager()->showWorkWeekView(); | 549 | mView->viewManager()->showWorkWeekView(); |
552 | } | 550 | } |
553 | else if ( msg == "-ringSync" ) { | 551 | else if ( msg == "-ringSync" ) { |
554 | mSyncManager->multiSync( false ); | 552 | mSyncManager->multiSync( false ); |
555 | } | 553 | } |
556 | else if ( msg == "-showWeek" ) { | 554 | else if ( msg == "-showWeek" ) { |
557 | mView->viewManager()->showWeekView(); | 555 | mView->viewManager()->showWeekView(); |
558 | } | 556 | } |
559 | else if ( msg == "-showTodo" ) { | 557 | else if ( msg == "-showTodo" ) { |
560 | mView->viewManager()->showTodoView(); | 558 | mView->viewManager()->showTodoView(); |
561 | } | 559 | } |
562 | else if ( msg == "-showJournal" ) { | 560 | else if ( msg == "-showJournal" ) { |
563 | mView->dateNavigator()->selectDates( 1 ); | 561 | mView->dateNavigator()->selectDates( 1 ); |
564 | mView->dateNavigator()->selectToday(); | 562 | mView->dateNavigator()->selectToday(); |
565 | mView->viewManager()->showJournalView(); | 563 | mView->viewManager()->showJournalView(); |
566 | } | 564 | } |
567 | else if ( msg == "-showKO" ) { | 565 | else if ( msg == "-showKO" ) { |
568 | mView->viewManager()->showNextXView(); | 566 | mView->viewManager()->showNextXView(); |
569 | } | 567 | } |
570 | else if ( msg == "-showWNext" ) { | 568 | else if ( msg == "-showWNext" ) { |
571 | mView->viewManager()->showWhatsNextView(); | 569 | mView->viewManager()->showWhatsNextView(); |
572 | } | 570 | } |
573 | else if ( msg == "nextView()" ) { | 571 | else if ( msg == "nextView()" ) { |
574 | mView->viewManager()->showNextView(); | 572 | mView->viewManager()->showNextView(); |
575 | } | 573 | } |
576 | else if ( msg == "-showNextXView" ) { | 574 | else if ( msg == "-showNextXView" ) { |
577 | mView->viewManager()->showNextXView(); | 575 | mView->viewManager()->showNextXView(); |
578 | } | 576 | } |
579 | 577 | ||
580 | 578 | ||
581 | } | 579 | } |
582 | 580 | ||
583 | showMaximized(); | 581 | showMaximized(); |
584 | raise(); | 582 | raise(); |
585 | } | 583 | } |
586 | 584 | ||
587 | QPixmap MainWindow::loadPixmap( QString name ) | 585 | QPixmap MainWindow::loadPixmap( QString name ) |
588 | { | 586 | { |
589 | return SmallIcon( name ); | 587 | return SmallIcon( name ); |
590 | 588 | ||
591 | } | 589 | } |
592 | void MainWindow::initActions() | 590 | void MainWindow::initActions() |
593 | { | 591 | { |
594 | //KOPrefs::instance()->mShowFullMenu | 592 | //KOPrefs::instance()->mShowFullMenu |
595 | iconToolBar->clear(); | 593 | iconToolBar->clear(); |
596 | KOPrefs *p = KOPrefs::instance(); | 594 | KOPrefs *p = KOPrefs::instance(); |
597 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 595 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
598 | 596 | ||
599 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 597 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
600 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 598 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
601 | QPopupMenu *importMenu = new QPopupMenu( this ); | 599 | QPopupMenu *importMenu = new QPopupMenu( this ); |
602 | QPopupMenu *importMenu_X = new QPopupMenu( this ); | 600 | QPopupMenu *importMenu_X = new QPopupMenu( this ); |
603 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); | 601 | QPopupMenu *exportMenu_X = new QPopupMenu( this ); |
604 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); | 602 | QPopupMenu *beamMenu_X = new QPopupMenu( this ); |
605 | selectFilterMenu = new QPopupMenu( this ); | 603 | selectFilterMenu = new QPopupMenu( this ); |
606 | selectFilterMenu->setCheckable( true ); | 604 | selectFilterMenu->setCheckable( true ); |
607 | syncMenu = new QPopupMenu( this ); | 605 | syncMenu = new QPopupMenu( this ); |
608 | configureAgendaMenu = new QPopupMenu( this ); | 606 | configureAgendaMenu = new QPopupMenu( this ); |
609 | configureToolBarMenu = new QPopupMenu( this ); | 607 | configureToolBarMenu = new QPopupMenu( this ); |
610 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 608 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
611 | QIconSet icon; | 609 | QIconSet icon; |
612 | int pixWid = 22, pixHei = 22; | 610 | int pixWid = 22, pixHei = 22; |
613 | QString pathString = ""; | 611 | QString pathString = ""; |
614 | if ( !p->mToolBarMiniIcons ) { | 612 | if ( !p->mToolBarMiniIcons ) { |
615 | if ( QApplication::desktop()->width() < 480 ) { | 613 | if ( QApplication::desktop()->width() < 480 ) { |
616 | pathString += "icons16/"; | 614 | pathString += "icons16/"; |
617 | pixWid = 18; pixHei = 16; | 615 | pixWid = 18; pixHei = 16; |
618 | } | 616 | } |
619 | } else { | 617 | } else { |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index f2a6c60..45ed04d 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,175 +1,166 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qmenubar.h> | 8 | #include <qmenubar.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 10 | #include <qregexp.h> |
11 | 11 | ||
12 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
13 | #include "simplealarmclient.h" | ||
14 | #include <ksyncmanager.h> | 13 | #include <ksyncmanager.h> |
15 | #ifndef DESKTOP_VERSION | 14 | #ifndef DESKTOP_VERSION |
16 | #include <qcopchannel_qws.h> | 15 | #include <qcopchannel_qws.h> |
17 | #endif | 16 | #endif |
18 | class QAction; | 17 | class QAction; |
19 | class CalendarView; | 18 | class CalendarView; |
20 | class KSyncProfile; | 19 | class KSyncProfile; |
21 | #ifdef DESKTOP_VERSION | 20 | #ifdef DESKTOP_VERSION |
22 | 21 | ||
23 | #define QPEToolBar QToolBar | 22 | #define QPEToolBar QToolBar |
24 | #define QPEMenuBar QMenuBar | 23 | #define QPEMenuBar QMenuBar |
25 | #endif | 24 | #endif |
26 | class QPEToolBar; | 25 | class QPEToolBar; |
27 | class QPEMenuBar; | 26 | class QPEMenuBar; |
28 | 27 | ||
29 | 28 | ||
30 | namespace KCal { | 29 | namespace KCal { |
31 | class CalendarLocal; | 30 | class CalendarLocal; |
32 | } | 31 | } |
33 | 32 | ||
34 | class KOMenuBar : public QMenuBar | ||
35 | { | ||
36 | public: | ||
37 | KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} | ||
38 | QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} | ||
39 | }; | ||
40 | |||
41 | using namespace KCal; | 33 | using namespace KCal; |
42 | 34 | ||
43 | class MainWindow : public QMainWindow | 35 | class MainWindow : public QMainWindow |
44 | { | 36 | { |
45 | Q_OBJECT | 37 | Q_OBJECT |
46 | public: | 38 | public: |
47 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 39 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
48 | ~MainWindow(); | 40 | ~MainWindow(); |
49 | bool beamReceiveEnabled(); | 41 | bool beamReceiveEnabled(); |
50 | static QString defaultFileName(); | 42 | static QString defaultFileName(); |
51 | static QString syncFileName(); | 43 | static QString syncFileName(); |
52 | static QString resourcePath(); | 44 | static QString resourcePath(); |
53 | public slots: | 45 | public slots: |
54 | void setCaption ( const QString & ); | 46 | void setCaption ( const QString & ); |
55 | void updateWeekNum(const KCal::DateList &); | 47 | void updateWeekNum(const KCal::DateList &); |
56 | void updateWeek(QDate); | 48 | void updateWeek(QDate); |
57 | void updateFilterToolbar(); | 49 | void updateFilterToolbar(); |
58 | virtual void showMaximized (); | 50 | virtual void showMaximized (); |
59 | void configureAgenda( int ); | 51 | void configureAgenda( int ); |
60 | void recieve( const QCString& msg, const QByteArray& data ); | 52 | void recieve( const QCString& msg, const QByteArray& data ); |
61 | protected slots: | 53 | protected slots: |
62 | void setCaptionToDates(); | 54 | void setCaptionToDates(); |
63 | void weekAction(); | 55 | void weekAction(); |
64 | void about(); | 56 | void about(); |
65 | void licence(); | 57 | void licence(); |
66 | void faq(); | 58 | void faq(); |
67 | void usertrans(); | 59 | void usertrans(); |
68 | void features(); | 60 | void features(); |
69 | void synchowto(); | 61 | void synchowto(); |
70 | void storagehowto(); | 62 | void storagehowto(); |
71 | void timetrackinghowto(); | 63 | void timetrackinghowto(); |
72 | void kdesynchowto(); | 64 | void kdesynchowto(); |
73 | void multisynchowto(); | 65 | void multisynchowto(); |
74 | void whatsNew(); | 66 | void whatsNew(); |
75 | void keyBindings(); | 67 | void keyBindings(); |
76 | void aboutAutoSaving();; | 68 | void aboutAutoSaving();; |
77 | void aboutKnownBugs(); | 69 | void aboutKnownBugs(); |
78 | 70 | ||
79 | void processIncidenceSelection( Incidence * ); | 71 | void processIncidenceSelection( Incidence * ); |
80 | 72 | ||
81 | void importQtopia(); | 73 | void importQtopia(); |
82 | void importBday(); | 74 | void importBday(); |
83 | void importOL(); | 75 | void importOL(); |
84 | void importIcal(); | 76 | void importIcal(); |
85 | void importFile( QString, bool ); | 77 | void importFile( QString, bool ); |
86 | void quickImportIcal(); | 78 | void quickImportIcal(); |
87 | 79 | ||
88 | void slotModifiedChanged( bool ); | 80 | void slotModifiedChanged( bool ); |
89 | 81 | ||
90 | void save(); | 82 | void save(); |
91 | void saveStopTimer(); | 83 | void saveStopTimer(); |
92 | void configureToolBar( int ); | 84 | void configureToolBar( int ); |
93 | void printSel(); | 85 | void printSel(); |
94 | void printCal(); | 86 | void printCal(); |
95 | void saveCalendar(); | 87 | void saveCalendar(); |
96 | void loadCalendar(); | 88 | void loadCalendar(); |
97 | void exportVCalendar(); | 89 | void exportVCalendar(); |
98 | void fillFilterMenu(); | 90 | void fillFilterMenu(); |
99 | void fillFilterMenuTB(); | 91 | void fillFilterMenuTB(); |
100 | void selectFilter( int ); | 92 | void selectFilter( int ); |
101 | void fillFilterMenuPopup(); | 93 | void fillFilterMenuPopup(); |
102 | void selectFilterPopup( int ); | 94 | void selectFilterPopup( int ); |
103 | void exportToPhone( int ); | 95 | void exportToPhone( int ); |
104 | void toggleBeamReceive(); | 96 | void toggleBeamReceive(); |
105 | void disableBR(bool); | 97 | void disableBR(bool); |
106 | signals: | 98 | signals: |
107 | void selectWeek ( int ); | 99 | void selectWeek ( int ); |
108 | private slots: | 100 | private slots: |
109 | void showConfigureAgenda(); | 101 | void showConfigureAgenda(); |
110 | void getFile( bool ); | 102 | void getFile( bool ); |
111 | void syncFileRequest(); | 103 | void syncFileRequest(); |
112 | 104 | ||
113 | protected: | 105 | protected: |
114 | void hideEvent ( QHideEvent * ); | 106 | void hideEvent ( QHideEvent * ); |
115 | QString sentSyncFile(); | 107 | QString sentSyncFile(); |
116 | void displayText( QString, QString); | 108 | void displayText( QString, QString); |
117 | void enableIncidenceActions( bool ); | 109 | void enableIncidenceActions( bool ); |
118 | 110 | ||
119 | private: | 111 | private: |
120 | bool mBRdisabled; | 112 | bool mBRdisabled; |
121 | #ifndef DESKTOP_VERSION | 113 | #ifndef DESKTOP_VERSION |
122 | QCopChannel* infrared; | 114 | QCopChannel* infrared; |
123 | #endif | 115 | #endif |
124 | QAction* brAction; | 116 | QAction* brAction; |
125 | KSyncManager* mSyncManager; | 117 | KSyncManager* mSyncManager; |
126 | bool mClosed; | 118 | bool mClosed; |
127 | void saveOnClose(); | 119 | void saveOnClose(); |
128 | bool mFlagKeyPressed; | 120 | bool mFlagKeyPressed; |
129 | bool mBlockAtStartup; | 121 | bool mBlockAtStartup; |
130 | QPEToolBar *iconToolBar; | 122 | QPEToolBar *iconToolBar; |
131 | QPEToolBar *viewToolBar; | 123 | QPEToolBar *viewToolBar; |
132 | QPEToolBar *navigatorToolBar; | 124 | QPEToolBar *navigatorToolBar; |
133 | QPEToolBar *filterToolBar; | 125 | QPEToolBar *filterToolBar; |
134 | QPEMenuBar *filterMenubar; | 126 | QPEMenuBar *filterMenubar; |
135 | QPopupMenu * filterPopupMenu; | 127 | QPopupMenu * filterPopupMenu; |
136 | void initActions(); | 128 | void initActions(); |
137 | void setDefaultPreferences(); | 129 | void setDefaultPreferences(); |
138 | void resizeEvent( QResizeEvent* e); | 130 | void resizeEvent( QResizeEvent* e); |
139 | void keyPressEvent ( QKeyEvent * ) ; | 131 | void keyPressEvent ( QKeyEvent * ) ; |
140 | void keyReleaseEvent ( QKeyEvent * ) ; | 132 | void keyReleaseEvent ( QKeyEvent * ) ; |
141 | QPopupMenu *configureToolBarMenu; | 133 | QPopupMenu *configureToolBarMenu; |
142 | QPopupMenu *selectFilterMenu; | 134 | QPopupMenu *selectFilterMenu; |
143 | QPopupMenu *selectFilterMenuTB; | 135 | QPopupMenu *selectFilterMenuTB; |
144 | QPopupMenu *configureAgendaMenu, *syncMenu; | 136 | QPopupMenu *configureAgendaMenu, *syncMenu; |
145 | CalendarLocal *mCalendar; | 137 | CalendarLocal *mCalendar; |
146 | CalendarView *mView; | 138 | CalendarView *mView; |
147 | QAction *mNewSubTodoAction; | 139 | QAction *mNewSubTodoAction; |
148 | QAction *mWeekAction; | 140 | QAction *mWeekAction; |
149 | QFont mWeekFont; | 141 | QFont mWeekFont; |
150 | QPixmap mWeekPixmap; | 142 | QPixmap mWeekPixmap; |
151 | QColor mWeekBgColor; | 143 | QColor mWeekBgColor; |
152 | 144 | ||
153 | QAction *mShowAction; | 145 | QAction *mShowAction; |
154 | QAction *mEditAction; | 146 | QAction *mEditAction; |
155 | QAction *mDeleteAction; | 147 | QAction *mDeleteAction; |
156 | QAction *mCloneAction; | 148 | QAction *mCloneAction; |
157 | QAction *mMoveAction; | 149 | QAction *mMoveAction; |
158 | QAction *mBeamAction; | 150 | QAction *mBeamAction; |
159 | QAction *mCancelAction; | 151 | QAction *mCancelAction; |
160 | 152 | ||
161 | QAction *mToggleNav; | 153 | QAction *mToggleNav; |
162 | QAction *mToggleFilter; | 154 | QAction *mToggleFilter; |
163 | QAction *mToggleAllday; | 155 | QAction *mToggleAllday; |
164 | QAction *actionFilterMenuTB; | 156 | QAction *actionFilterMenuTB; |
165 | 157 | ||
166 | void closeEvent( QCloseEvent* ce ); | 158 | void closeEvent( QCloseEvent* ce ); |
167 | SimpleAlarmClient mAlarmClient; | ||
168 | QTimer mSaveTimer; | 159 | QTimer mSaveTimer; |
169 | //bool mBlockSaveFlag; | 160 | //bool mBlockSaveFlag; |
170 | bool mCalendarModifiedFlag; | 161 | bool mCalendarModifiedFlag; |
171 | QPixmap loadPixmap( QString ); | 162 | QPixmap loadPixmap( QString ); |
172 | }; | 163 | }; |
173 | 164 | ||
174 | 165 | ||
175 | #endif | 166 | #endif |
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 7a945e3..de65b53 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -256,211 +256,210 @@ void SearchDialog::updateView() | |||
256 | st += "*"; | 256 | st += "*"; |
257 | re.setPattern(st); | 257 | re.setPattern(st); |
258 | if (re.isValid()) { | 258 | if (re.isValid()) { |
259 | search(re); | 259 | search(re); |
260 | } else { | 260 | } else { |
261 | mMatchedEvents.clear(); | 261 | mMatchedEvents.clear(); |
262 | mMatchedTodos.clear(); | 262 | mMatchedTodos.clear(); |
263 | mMatchedJournals.clear(); | 263 | mMatchedJournals.clear(); |
264 | } | 264 | } |
265 | listView->setStartDate( mStartDate->date() ); | 265 | listView->setStartDate( mStartDate->date() ); |
266 | listView->showEvents(mMatchedEvents); | 266 | listView->showEvents(mMatchedEvents); |
267 | listView->addTodos(mMatchedTodos); | 267 | listView->addTodos(mMatchedTodos); |
268 | listView->addJournals(mMatchedJournals); | 268 | listView->addJournals(mMatchedJournals); |
269 | } | 269 | } |
270 | 270 | ||
271 | void SearchDialog::search(const QRegExp &re) | 271 | void SearchDialog::search(const QRegExp &re) |
272 | { | 272 | { |
273 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), | 273 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), |
274 | mEndDate->date(), | 274 | mEndDate->date(), |
275 | false /*mInclusiveCheck->isChecked()*/ ); | 275 | false /*mInclusiveCheck->isChecked()*/ ); |
276 | 276 | ||
277 | mMatchedEvents.clear(); | 277 | mMatchedEvents.clear(); |
278 | if ( mSearchEvent->isChecked() ) { | 278 | if ( mSearchEvent->isChecked() ) { |
279 | Event *ev; | 279 | Event *ev; |
280 | for(ev=events.first();ev;ev=events.next()) { | 280 | for(ev=events.first();ev;ev=events.next()) { |
281 | if (mSummaryCheck->isChecked()) { | 281 | if (mSummaryCheck->isChecked()) { |
282 | #if QT_VERSION >= 0x030000 | 282 | #if QT_VERSION >= 0x030000 |
283 | if (re.search(ev->summary()) != -1) | 283 | if (re.search(ev->summary()) != -1) |
284 | #else | 284 | #else |
285 | if (re.match(ev->summary()) != -1) | 285 | if (re.match(ev->summary()) != -1) |
286 | #endif | 286 | #endif |
287 | { | 287 | { |
288 | mMatchedEvents.append(ev); | 288 | mMatchedEvents.append(ev); |
289 | continue; | 289 | continue; |
290 | } | 290 | } |
291 | #if QT_VERSION >= 0x030000 | 291 | #if QT_VERSION >= 0x030000 |
292 | if (re.search(ev->location()) != -1) | 292 | if (re.search(ev->location()) != -1) |
293 | #else | 293 | #else |
294 | if (re.match(ev->location()) != -1) | 294 | if (re.match(ev->location()) != -1) |
295 | #endif | 295 | #endif |
296 | { | 296 | { |
297 | mMatchedEvents.append(ev); | 297 | mMatchedEvents.append(ev); |
298 | continue; | 298 | continue; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | if (mDescriptionCheck->isChecked()) { | 301 | if (mDescriptionCheck->isChecked()) { |
302 | #if QT_VERSION >= 0x030000 | 302 | #if QT_VERSION >= 0x030000 |
303 | if (re.search(ev->description()) != -1) | 303 | if (re.search(ev->description()) != -1) |
304 | #else | 304 | #else |
305 | if (re.match(ev->description()) != -1) | 305 | if (re.match(ev->description()) != -1) |
306 | #endif | 306 | #endif |
307 | { | 307 | { |
308 | mMatchedEvents.append(ev); | 308 | mMatchedEvents.append(ev); |
309 | continue; | 309 | continue; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | if (mCategoryCheck->isChecked()) { | 312 | if (mCategoryCheck->isChecked()) { |
313 | #if QT_VERSION >= 0x030000 | 313 | #if QT_VERSION >= 0x030000 |
314 | if (re.search(ev->categoriesStr()) != -1) | 314 | if (re.search(ev->categoriesStr()) != -1) |
315 | #else | 315 | #else |
316 | if (re.match(ev->categoriesStr()) != -1) | 316 | if (re.match(ev->categoriesStr()) != -1) |
317 | #endif | 317 | #endif |
318 | { | 318 | { |
319 | mMatchedEvents.append(ev); | 319 | mMatchedEvents.append(ev); |
320 | continue; | 320 | continue; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 323 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
324 | QPtrList<Attendee> tmpAList = ev->attendees(); | 324 | QPtrList<Attendee> tmpAList = ev->attendees(); |
325 | Attendee *a; | 325 | Attendee *a; |
326 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 326 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
327 | if (mSearchAName->isChecked()) { | 327 | if (mSearchAName->isChecked()) { |
328 | #if QT_VERSION >= 0x030000 | 328 | #if QT_VERSION >= 0x030000 |
329 | if (re.search(a->name()) != -1) | 329 | if (re.search(a->name()) != -1) |
330 | #else | 330 | #else |
331 | if (re.match(a->name()) != -1) | 331 | if (re.match(a->name()) != -1) |
332 | #endif | 332 | #endif |
333 | { | 333 | { |
334 | mMatchedEvents.append(ev); | 334 | mMatchedEvents.append(ev); |
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | if (mSearchAEmail->isChecked()) { | 338 | if (mSearchAEmail->isChecked()) { |
339 | #if QT_VERSION >= 0x030000 | 339 | #if QT_VERSION >= 0x030000 |
340 | if (re.search(a->email()) != -1) | 340 | if (re.search(a->email()) != -1) |
341 | #else | 341 | #else |
342 | if (re.match(a->email()) != -1) | 342 | if (re.match(a->email()) != -1) |
343 | #endif | 343 | #endif |
344 | { | 344 | { |
345 | mMatchedEvents.append(ev); | 345 | mMatchedEvents.append(ev); |
346 | break; | 346 | break; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | } | 349 | } |
350 | } | 350 | } |
351 | } | 351 | } |
352 | } | 352 | } |
353 | QPtrList<Todo> todos = mCalendar->todos( ); | 353 | QPtrList<Todo> todos = mCalendar->todos( ); |
354 | mMatchedTodos.clear(); | 354 | mMatchedTodos.clear(); |
355 | if ( mSearchTodo->isChecked() ) { | 355 | if ( mSearchTodo->isChecked() ) { |
356 | Todo *tod; | 356 | Todo *tod; |
357 | for(tod=todos.first();tod;tod=todos.next()) { | 357 | for(tod=todos.first();tod;tod=todos.next()) { |
358 | if (mSummaryCheck->isChecked()) { | 358 | if (mSummaryCheck->isChecked()) { |
359 | #if QT_VERSION >= 0x030000 | 359 | #if QT_VERSION >= 0x030000 |
360 | if (re.search(tod->summary()) != -1) | 360 | if (re.search(tod->summary()) != -1) |
361 | #else | 361 | #else |
362 | if (re.match(tod->summary()) != -1) | 362 | if (re.match(tod->summary()) != -1) |
363 | #endif | 363 | #endif |
364 | { | 364 | { |
365 | mMatchedTodos.append(tod); | 365 | mMatchedTodos.append(tod); |
366 | continue; | 366 | continue; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | if (mDescriptionCheck->isChecked()) { | 369 | if (mDescriptionCheck->isChecked()) { |
370 | #if QT_VERSION >= 0x030000 | 370 | #if QT_VERSION >= 0x030000 |
371 | if (re.search(tod->description()) != -1) | 371 | if (re.search(tod->description()) != -1) |
372 | #else | 372 | #else |
373 | if (re.match(tod->description()) != -1) | 373 | if (re.match(tod->description()) != -1) |
374 | #endif | 374 | #endif |
375 | { | 375 | { |
376 | mMatchedTodos.append(tod); | 376 | mMatchedTodos.append(tod); |
377 | continue; | 377 | continue; |
378 | } | 378 | } |
379 | } | 379 | } |
380 | if (mCategoryCheck->isChecked()) { | 380 | if (mCategoryCheck->isChecked()) { |
381 | #if QT_VERSION >= 0x030000 | 381 | #if QT_VERSION >= 0x030000 |
382 | if (re.search(tod->categoriesStr()) != -1) | 382 | if (re.search(tod->categoriesStr()) != -1) |
383 | #else | 383 | #else |
384 | if (re.match(tod->categoriesStr()) != -1) | 384 | if (re.match(tod->categoriesStr()) != -1) |
385 | #endif | 385 | #endif |
386 | { | 386 | { |
387 | mMatchedTodos.append(tod); | 387 | mMatchedTodos.append(tod); |
388 | continue; | 388 | continue; |
389 | } | 389 | } |
390 | } | 390 | } |
391 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 391 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
392 | QPtrList<Attendee> tmpAList = tod->attendees(); | 392 | QPtrList<Attendee> tmpAList = tod->attendees(); |
393 | Attendee *a; | 393 | Attendee *a; |
394 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 394 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
395 | if (mSearchAName->isChecked()) { | 395 | if (mSearchAName->isChecked()) { |
396 | #if QT_VERSION >= 0x030000 | 396 | #if QT_VERSION >= 0x030000 |
397 | if (re.search(a->name()) != -1) | 397 | if (re.search(a->name()) != -1) |
398 | #else | 398 | #else |
399 | if (re.match(a->name()) != -1) | 399 | if (re.match(a->name()) != -1) |
400 | #endif | 400 | #endif |
401 | { | 401 | { |
402 | mMatchedTodos.append(tod); | 402 | mMatchedTodos.append(tod); |
403 | break; | 403 | break; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | if (mSearchAEmail->isChecked()) { | 406 | if (mSearchAEmail->isChecked()) { |
407 | #if QT_VERSION >= 0x030000 | 407 | #if QT_VERSION >= 0x030000 |
408 | if (re.search(a->email()) != -1) | 408 | if (re.search(a->email()) != -1) |
409 | #else | 409 | #else |
410 | if (re.match(a->email()) != -1) | 410 | if (re.match(a->email()) != -1) |
411 | #endif | 411 | #endif |
412 | { | 412 | { |
413 | mMatchedTodos.append(tod); | 413 | mMatchedTodos.append(tod); |
414 | break; | 414 | break; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | mMatchedJournals.clear(); | 421 | mMatchedJournals.clear(); |
422 | if (mSearchJournal->isChecked() ) { | 422 | if (mSearchJournal->isChecked() ) { |
423 | QPtrList<Journal> journals = mCalendar->journals( ); | 423 | QPtrList<Journal> journals = mCalendar->journals( ); |
424 | Journal* journ; | 424 | Journal* journ; |
425 | 425 | ||
426 | for(journ=journals.first();journ;journ=journals.next()) { | 426 | for(journ=journals.first();journ;journ=journals.next()) { |
427 | if ( journ->dtStart().date() <= mEndDate->date() | 427 | if ( journ->dtStart().date() <= mEndDate->date() |
428 | &&journ->dtStart().date() >= mStartDate->date()) { | 428 | &&journ->dtStart().date() >= mStartDate->date()) { |
429 | #if QT_VERSION >= 0x030000 | 429 | #if QT_VERSION >= 0x030000 |
430 | if (re.search(journ->description()) != -1) | 430 | if (re.search(journ->description()) != -1) |
431 | #else | 431 | #else |
432 | if (re.match(journ->description()) != -1) | 432 | if (re.match(journ->description()) != -1) |
433 | #endif | 433 | #endif |
434 | { | 434 | { |
435 | mMatchedJournals.append(journ); | 435 | mMatchedJournals.append(journ); |
436 | continue; | 436 | continue; |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
442 | } | 442 | } |
443 | 443 | ||
444 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 444 | void SearchDialog::keyPressEvent ( QKeyEvent *e) |
445 | { | 445 | { |
446 | switch ( e->key() ) { | 446 | switch ( e->key() ) { |
447 | case Qt::Key_Escape: | 447 | case Qt::Key_Escape: |
448 | hide(); | 448 | close(); |
449 | break; | 449 | break; |
450 | case Qt::Key_F: | 450 | case Qt::Key_F: |
451 | if ( e->state() == Qt::ControlButton ) { | 451 | if ( e->state() == Qt::ControlButton ) { |
452 | qDebug("full "); | ||
453 | 452 | ||
454 | } | 453 | } |
455 | break; | 454 | break; |
456 | case Qt::Key_Return: | 455 | case Qt::Key_Return: |
457 | case Qt::Key_Enter: | 456 | case Qt::Key_Enter: |
458 | doSearch(); | 457 | doSearch(); |
459 | break; | 458 | break; |
460 | 459 | ||
461 | default: | 460 | default: |
462 | e->ignore(); | 461 | e->ignore(); |
463 | } | 462 | } |
464 | } | 463 | } |
465 | 464 | ||
466 | //mMatchedJournals; | 465 | //mMatchedJournals; |