author | zautrix <zautrix> | 2005-03-22 22:55:32 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-22 22:55:32 (UTC) |
commit | aa6d19015bc91ae3af021d766d37a473e125278f (patch) (unidiff) | |
tree | f7b1d6b45a3997013318107ca02fa63b4b76913e | |
parent | 53ac6d1f931c50d89a44d9d46daceb7ed9d4ddc6 (diff) | |
download | kdepimpi-aa6d19015bc91ae3af021d766d37a473e125278f.zip kdepimpi-aa6d19015bc91ae3af021d766d37a473e125278f.tar.gz kdepimpi-aa6d19015bc91ae3af021d766d37a473e125278f.tar.bz2 |
fixes
-rw-r--r-- | kmicromail/opiemail.cpp | 1 | ||||
-rw-r--r-- | kmicromail/viewmailbase.cpp | 9 | ||||
-rw-r--r-- | kmicromail/viewmailbase.h | 5 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 34 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 4 |
5 files changed, 38 insertions, 15 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index b701446..4436ad6 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,247 +1,248 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | 49 | mCurrentComposer = 0; |
50 | settings = new Settings(); | 50 | settings = new Settings(); |
51 | tb = 0; | 51 | tb = 0; |
52 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
53 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
56 | folderView->setFocus(); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | OpieMail::~OpieMail() | 59 | OpieMail::~OpieMail() |
59 | { | 60 | { |
60 | if (settings) delete settings; | 61 | if (settings) delete settings; |
61 | if ( tb ) | 62 | if ( tb ) |
62 | delete tb; | 63 | delete tb; |
63 | } | 64 | } |
64 | 65 | ||
65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 66 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
66 | { | 67 | { |
67 | 68 | ||
68 | } | 69 | } |
69 | #include <stdlib.h> | 70 | #include <stdlib.h> |
70 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 71 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
71 | { | 72 | { |
72 | // copied from old mail2 | 73 | // copied from old mail2 |
73 | static int ii = 0; | 74 | static int ii = 0; |
74 | //qDebug("QCOP CALL ############################# %d ", ii); | 75 | //qDebug("QCOP CALL ############################# %d ", ii); |
75 | //QString mess ( msg ); | 76 | //QString mess ( msg ); |
76 | //qDebug("Message = %s ",mess.latin1()); | 77 | //qDebug("Message = %s ",mess.latin1()); |
77 | ++ii; | 78 | ++ii; |
78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 79 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
79 | 80 | ||
80 | mPendingEmail = QString::null; | 81 | mPendingEmail = QString::null; |
81 | mPendingName = QString::null; | 82 | mPendingName = QString::null; |
82 | if (msg == "writeMail(QString,QString)") | 83 | if (msg == "writeMail(QString,QString)") |
83 | { | 84 | { |
84 | //qDebug("writeMail(QString,QString) "); | 85 | //qDebug("writeMail(QString,QString) "); |
85 | QDataStream stream(data,IO_ReadOnly); | 86 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName >> mPendingEmail; | 87 | stream >> mPendingName >> mPendingEmail; |
87 | // removing the whitespaces at beginning and end is needed! | 88 | // removing the whitespaces at beginning and end is needed! |
88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
89 | } | 90 | } |
90 | else if (msg == "newMail()") | 91 | else if (msg == "newMail()") |
91 | { | 92 | { |
92 | //qDebug("slotComposeMail() "); | 93 | //qDebug("slotComposeMail() "); |
93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 94 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
94 | // and a QCOP call does not like a processevents in his execution | 95 | // and a QCOP call does not like a processevents in his execution |
95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 96 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 97 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
97 | // slotComposeMail(); | 98 | // slotComposeMail(); |
98 | } | 99 | } |
99 | else if (msg == "newMail(QString)") | 100 | else if (msg == "newMail(QString)") |
100 | { | 101 | { |
101 | //qDebug(" newMail(QString)"); | 102 | //qDebug(" newMail(QString)"); |
102 | QDataStream stream(data,IO_ReadOnly); | 103 | QDataStream stream(data,IO_ReadOnly); |
103 | stream >> mPendingName; | 104 | stream >> mPendingName; |
104 | // the format is | 105 | // the format is |
105 | // NAME <EMAIL>:SUBJECT | 106 | // NAME <EMAIL>:SUBJECT |
106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 107 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
107 | } else { | 108 | } else { |
108 | mPendingData = data; | 109 | mPendingData = data; |
109 | mPendingMessage = msg; | 110 | mPendingMessage = msg; |
110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 111 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
111 | } | 112 | } |
112 | 113 | ||
113 | //qDebug("END OpieMail::message "); | 114 | //qDebug("END OpieMail::message "); |
114 | } | 115 | } |
115 | void OpieMail::slotExtAppHandler() | 116 | void OpieMail::slotExtAppHandler() |
116 | { | 117 | { |
117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 118 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
118 | } | 119 | } |
119 | void OpieMail::slotwriteMail2(const QString& namemail ) | 120 | void OpieMail::slotwriteMail2(const QString& namemail ) |
120 | { | 121 | { |
121 | //qDebug("OpieMail::slotwriteMail2 "); | 122 | //qDebug("OpieMail::slotwriteMail2 "); |
122 | //qApp->processEvents(); | 123 | //qApp->processEvents(); |
123 | ComposeMail compose( settings, this, 0, true ); | 124 | ComposeMail compose( settings, this, 0, true ); |
124 | if ( !namemail.isEmpty() ) { | 125 | if ( !namemail.isEmpty() ) { |
125 | QString to = namemail; | 126 | QString to = namemail; |
126 | if ( namemail.find( " <") > 1 ) { | 127 | if ( namemail.find( " <") > 1 ) { |
127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 128 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
128 | } else | 129 | } else |
129 | if ( namemail.find( "<") > 1 ) { | 130 | if ( namemail.find( "<") > 1 ) { |
130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 131 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
131 | } | 132 | } |
132 | int sub = to.find( ">:"); | 133 | int sub = to.find( ">:"); |
133 | if ( sub > 0 ) { | 134 | if ( sub > 0 ) { |
134 | compose.setTo( to.left(sub+1) ); | 135 | compose.setTo( to.left(sub+1) ); |
135 | compose.setSubject( to.mid(sub+2) ); | 136 | compose.setSubject( to.mid(sub+2) ); |
136 | } else | 137 | } else |
137 | compose.setTo( to ); | 138 | compose.setTo( to ); |
138 | } | 139 | } |
139 | compose.slotAdjustColumns(); | 140 | compose.slotAdjustColumns(); |
140 | #ifndef DESKTOP_VERSION | 141 | #ifndef DESKTOP_VERSION |
141 | compose.showMaximized(); | 142 | compose.showMaximized(); |
142 | #endif | 143 | #endif |
143 | mCurrentComposer = &compose; | 144 | mCurrentComposer = &compose; |
144 | compose.exec(); | 145 | compose.exec(); |
145 | mCurrentComposer = 0; | 146 | mCurrentComposer = 0; |
146 | folderView->refreshOutgoing(); | 147 | folderView->refreshOutgoing(); |
147 | raise(); | 148 | raise(); |
148 | //qDebug("retttich "); | 149 | //qDebug("retttich "); |
149 | } | 150 | } |
150 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 151 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
151 | { | 152 | { |
152 | // qDebug("OpieMail::slotwriteMail "); | 153 | // qDebug("OpieMail::slotwriteMail "); |
153 | ComposeMail compose( settings, this, 0, true ); | 154 | ComposeMail compose( settings, this, 0, true ); |
154 | if (!email.isEmpty()) | 155 | if (!email.isEmpty()) |
155 | { | 156 | { |
156 | if (!name.isEmpty()) | 157 | if (!name.isEmpty()) |
157 | { | 158 | { |
158 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 159 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
159 | } | 160 | } |
160 | else | 161 | else |
161 | { | 162 | { |
162 | compose.setTo(email); | 163 | compose.setTo(email); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | compose.slotAdjustColumns(); | 166 | compose.slotAdjustColumns(); |
166 | #ifndef DESKTOP_VERSION | 167 | #ifndef DESKTOP_VERSION |
167 | compose.showMaximized(); | 168 | compose.showMaximized(); |
168 | #endif | 169 | #endif |
169 | 170 | ||
170 | mCurrentComposer = &compose; | 171 | mCurrentComposer = &compose; |
171 | compose.exec(); | 172 | compose.exec(); |
172 | mCurrentComposer = 0; | 173 | mCurrentComposer = 0; |
173 | folderView->refreshOutgoing(); | 174 | folderView->refreshOutgoing(); |
174 | raise(); | 175 | raise(); |
175 | } | 176 | } |
176 | 177 | ||
177 | void OpieMail::slotComposeMail() | 178 | void OpieMail::slotComposeMail() |
178 | { | 179 | { |
179 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 180 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
180 | slotwriteMail2( QString () ); | 181 | slotwriteMail2( QString () ); |
181 | else { | 182 | else { |
182 | if ( mPendingEmail == QString::null ) | 183 | if ( mPendingEmail == QString::null ) |
183 | slotwriteMail2( mPendingName ); | 184 | slotwriteMail2( mPendingName ); |
184 | else | 185 | else |
185 | slotwriteMail( mPendingName, mPendingEmail ); | 186 | slotwriteMail( mPendingName, mPendingEmail ); |
186 | } | 187 | } |
187 | //slotwriteMail(0l,0l); | 188 | //slotwriteMail(0l,0l); |
188 | } | 189 | } |
189 | 190 | ||
190 | void OpieMail::slotSendQueued() | 191 | void OpieMail::slotSendQueued() |
191 | { | 192 | { |
192 | SMTPaccount *smtp = 0; | 193 | SMTPaccount *smtp = 0; |
193 | 194 | ||
194 | QList<Account> list = settings->getAccounts(); | 195 | QList<Account> list = settings->getAccounts(); |
195 | QList<SMTPaccount> smtpList; | 196 | QList<SMTPaccount> smtpList; |
196 | smtpList.setAutoDelete(false); | 197 | smtpList.setAutoDelete(false); |
197 | Account *it; | 198 | Account *it; |
198 | for ( it = list.first(); it; it = list.next() ) | 199 | for ( it = list.first(); it; it = list.next() ) |
199 | { | 200 | { |
200 | if ( it->getType() == MAILLIB::A_SMTP ) | 201 | if ( it->getType() == MAILLIB::A_SMTP ) |
201 | { | 202 | { |
202 | smtp = static_cast<SMTPaccount *>(it); | 203 | smtp = static_cast<SMTPaccount *>(it); |
203 | smtpList.append(smtp); | 204 | smtpList.append(smtp); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | if (smtpList.count()==0) | 207 | if (smtpList.count()==0) |
207 | { | 208 | { |
208 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); | 209 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); |
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 212 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
212 | return; | 213 | return; |
213 | if (smtpList.count()==1) | 214 | if (smtpList.count()==1) |
214 | { | 215 | { |
215 | smtp = smtpList.at(0); | 216 | smtp = smtpList.at(0); |
216 | } | 217 | } |
217 | else | 218 | else |
218 | { | 219 | { |
219 | smtp = 0; | 220 | smtp = 0; |
220 | selectsmtp selsmtp; | 221 | selectsmtp selsmtp; |
221 | selsmtp.setSelectionlist(&smtpList); | 222 | selsmtp.setSelectionlist(&smtpList); |
222 | selsmtp.resize( selsmtp.sizeHint() ); | 223 | selsmtp.resize( selsmtp.sizeHint() ); |
223 | if ( selsmtp.exec() == QDialog::Accepted ) | 224 | if ( selsmtp.exec() == QDialog::Accepted ) |
224 | { | 225 | { |
225 | smtp = selsmtp.selected_smtp(); | 226 | smtp = selsmtp.selected_smtp(); |
226 | } | 227 | } |
227 | } | 228 | } |
228 | if (smtp) | 229 | if (smtp) |
229 | { | 230 | { |
230 | 231 | ||
231 | Global::statusMessage("Sending mails...!"); | 232 | Global::statusMessage("Sending mails...!"); |
232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 233 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
233 | if ( wrap->flushOutbox() ) | 234 | if ( wrap->flushOutbox() ) |
234 | { | 235 | { |
235 | Global::statusMessage("Mails sent!"); | 236 | Global::statusMessage("Mails sent!"); |
236 | } | 237 | } |
237 | delete wrap; | 238 | delete wrap; |
238 | } | 239 | } |
239 | folderView->refreshOutgoing(); | 240 | folderView->refreshOutgoing(); |
240 | } | 241 | } |
241 | 242 | ||
242 | void OpieMail::slotSearchMails() | 243 | void OpieMail::slotSearchMails() |
243 | { | 244 | { |
244 | qDebug("OpieMail::slotSearchMails():not implemented "); | 245 | qDebug("OpieMail::slotSearchMails():not implemented "); |
245 | } | 246 | } |
246 | 247 | ||
247 | void OpieMail::slotEditSettings() | 248 | void OpieMail::slotEditSettings() |
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp index 3a41ba0..3bb964e 100644 --- a/kmicromail/viewmailbase.cpp +++ b/kmicromail/viewmailbase.cpp | |||
@@ -1,106 +1,109 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include <qtextbrowser.h> | 2 | #include <qtextbrowser.h> |
3 | #include <qlistview.h> | 3 | #include <qlistview.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qvbox.h> | 6 | #include <qvbox.h> |
7 | #include <qapplication.h> | ||
7 | 8 | ||
8 | #include <qtoolbar.h> | 9 | #include <qtoolbar.h> |
9 | #include <qmenubar.h> | 10 | #include <qmenubar.h> |
10 | #include <kiconloader.h> | 11 | #include <kiconloader.h> |
11 | //#include <qpe/resource.h> | 12 | //#include <qpe/resource.h> |
12 | #include <klocale.h> | 13 | #include <klocale.h> |
13 | 14 | ||
14 | #include "viewmailbase.h" | 15 | #include "viewmailbase.h" |
15 | //#include "opendiag.h" | 16 | //#include "opendiag.h" |
16 | 17 | ||
17 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 18 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
18 | : QMainWindow(parent, name, fl) | 19 | : QMainWindow(parent, name, fl) |
19 | { | 20 | { |
20 | 21 | ||
21 | setToolBarsMovable(false); | 22 | setToolBarsMovable(false); |
22 | 23 | ||
23 | toolbar = new QToolBar(this); | 24 | toolbar = new QToolBar(this); |
24 | menubar = new QMenuBar( toolbar ); | 25 | menubar = new QMenuBar( toolbar ); |
25 | mailmenu = new QPopupMenu( menubar ); | 26 | mailmenu = new QPopupMenu( menubar ); |
26 | menubar->insertItem( i18n( "Mail" ), mailmenu ); | 27 | menubar->insertItem( i18n( "Mail" ), mailmenu ); |
27 | 28 | ||
28 | toolbar->setHorizontalStretchable(true); | 29 | toolbar->setHorizontalStretchable(true); |
29 | addToolBar(toolbar); | 30 | addToolBar(toolbar); |
30 | 31 | ||
31 | viewSource = new QAction(i18n("View Source"), 0, 0, this); | 32 | viewSource = new QAction(i18n("View Source"), 0, 0, this); |
32 | viewSource->addTo(mailmenu); | 33 | viewSource->addTo(mailmenu); |
33 | 34 | ||
34 | downloadMail= new QAction(i18n("Download Mail"),SmallIcon("add"), 0, 0, this); | 35 | downloadMail= new QAction(i18n("Download Mail"),SmallIcon("add"), 0, 0, this); |
35 | downloadMail->addTo(toolbar); | 36 | downloadMail->addTo(toolbar); |
36 | downloadMail->addTo(mailmenu); | 37 | downloadMail->addTo(mailmenu); |
37 | 38 | ||
38 | 39 | ||
39 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); | 40 | reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); |
40 | reply->addTo(toolbar); | 41 | reply->addTo(toolbar); |
41 | reply->addTo(mailmenu); | 42 | reply->addTo(mailmenu); |
42 | 43 | ||
43 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); | 44 | forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); |
44 | forward->addTo(toolbar); | 45 | forward->addTo(toolbar); |
45 | forward->addTo(mailmenu); | 46 | forward->addTo(mailmenu); |
46 | 47 | ||
47 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); | 48 | attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); |
48 | attachbutton->addTo(toolbar); | 49 | attachbutton->addTo(toolbar); |
49 | attachbutton->addTo(mailmenu); | 50 | attachbutton->addTo(mailmenu); |
50 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 51 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
51 | 52 | ||
52 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); | 53 | showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); |
53 | showHtml->addTo( toolbar ); | 54 | showHtml->addTo( toolbar ); |
54 | showHtml->addTo( mailmenu ); | 55 | showHtml->addTo( mailmenu ); |
55 | 56 | ||
56 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); | 57 | deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); |
57 | deleteMail->addTo(toolbar); | 58 | deleteMail->addTo(toolbar); |
58 | deleteMail->addTo(mailmenu); | 59 | deleteMail->addTo(mailmenu); |
59 | 60 | ||
60 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this); | 61 | nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this); |
61 | QLabel *spacer = new QLabel(toolbar); | 62 | QLabel *spacer = new QLabel(toolbar); |
62 | nextMail->addTo(toolbar); | 63 | nextMail->addTo(toolbar); |
63 | nextMail->addTo(mailmenu); | 64 | nextMail->addTo(mailmenu); |
64 | 65 | ||
65 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 66 | closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
66 | //QLabel *spacer = new QLabel(toolbar); | 67 | //QLabel *spacer = new QLabel(toolbar); |
67 | spacer->setBackgroundMode(QWidget::PaletteButton); | 68 | spacer->setBackgroundMode(QWidget::PaletteButton); |
68 | toolbar->setStretchableWidget(spacer); | 69 | toolbar->setStretchableWidget(spacer); |
69 | closeMail->addTo(toolbar); | 70 | closeMail->addTo(toolbar); |
70 | closeMail->addTo(mailmenu); | 71 | closeMail->addTo(mailmenu); |
71 | QVBox *view = new QVBox(this); | 72 | QVBox *view = new QVBox(this); |
72 | setCentralWidget(view); | 73 | setCentralWidget(view); |
73 | 74 | ||
74 | attachments = new QListView(view); | 75 | attachments = new QListView(view); |
75 | attachments->setMinimumHeight(90); | 76 | int fixh = 100; |
76 | attachments->setMaximumHeight(90); | 77 | if ( QApplication::desktop()->width() > 320 ) |
78 | fixh = 200; | ||
79 | attachments->setFixedHeight(fixh); | ||
77 | attachments->setAllColumnsShowFocus(true); | 80 | attachments->setAllColumnsShowFocus(true); |
78 | attachments->addColumn("Mime Type", 60); | 81 | attachments->addColumn("Mime Type", fixh-30); |
79 | attachments->addColumn(i18n("Description"), 100); | 82 | attachments->addColumn(i18n("Description"), 100); |
80 | attachments->addColumn(i18n("Filename"), 80); | 83 | attachments->addColumn(i18n("Filename"), 80); |
81 | attachments->addColumn(i18n("Size"), 80); | 84 | attachments->addColumn(i18n("Size"), 80); |
82 | attachments->setSorting(-1); | 85 | attachments->setSorting(-1); |
83 | attachments->hide(); | 86 | attachments->hide(); |
84 | 87 | ||
85 | browser = new QTextBrowser(view); | 88 | browser = new QTextBrowser(view); |
86 | 89 | ||
87 | //openDiag = new OpenDiag(view); | 90 | //openDiag = new OpenDiag(view); |
88 | //openDiag->hide(); | 91 | //openDiag->hide(); |
89 | 92 | ||
90 | } | 93 | } |
91 | 94 | ||
92 | void ViewMailBase::slotChangeAttachview(bool state) | 95 | void ViewMailBase::slotChangeAttachview(bool state) |
93 | { | 96 | { |
94 | if (state) attachments->show(); | 97 | if (state) attachments->show(); |
95 | else attachments->hide(); | 98 | else attachments->hide(); |
96 | } | 99 | } |
97 | 100 | ||
98 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 101 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
99 | { | 102 | { |
100 | if( e->key()==Qt::Key_Escape ) { | 103 | if( e->key()==Qt::Key_Escape ) { |
101 | close(); | 104 | close(); |
102 | e->accept(); | 105 | e->accept(); |
103 | return; | 106 | return; |
104 | } | 107 | } |
105 | QWidget::keyPressEvent(e); | 108 | QWidget::keyPressEvent(e); |
106 | } | 109 | } |
diff --git a/kmicromail/viewmailbase.h b/kmicromail/viewmailbase.h index 7ad1eec..7c075eb 100644 --- a/kmicromail/viewmailbase.h +++ b/kmicromail/viewmailbase.h | |||
@@ -1,39 +1,44 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #ifndef VIEWMAILBASE_H | 2 | #ifndef VIEWMAILBASE_H |
3 | #define VIEWMAILBASE_H | 3 | #define VIEWMAILBASE_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | 6 | ||
7 | #ifndef DESKTOP_VERSION | ||
8 | #include <qpe/qpemenubar.h> | ||
9 | #define QMenuBar QPEMenuBar | ||
10 | #endif | ||
11 | |||
7 | class QAction; | 12 | class QAction; |
8 | class OpenDiag; | 13 | class OpenDiag; |
9 | class QListView; | 14 | class QListView; |
10 | class QToolBar; | 15 | class QToolBar; |
11 | class QTextBrowser; | 16 | class QTextBrowser; |
12 | class QMenuBar; | 17 | class QMenuBar; |
13 | class QPopupMenu; | 18 | class QPopupMenu; |
14 | 19 | ||
15 | class ViewMailBase : public QMainWindow | 20 | class ViewMailBase : public QMainWindow |
16 | { | 21 | { |
17 | Q_OBJECT | 22 | Q_OBJECT |
18 | 23 | ||
19 | public: | 24 | public: |
20 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 25 | ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
21 | 26 | ||
22 | protected: | 27 | protected: |
23 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail, *nextMail, *downloadMail, *viewSource; | 28 | QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml, *closeMail, *nextMail, *downloadMail, *viewSource; |
24 | QListView *attachments; | 29 | QListView *attachments; |
25 | QToolBar *toolbar; | 30 | QToolBar *toolbar; |
26 | QTextBrowser *browser; | 31 | QTextBrowser *browser; |
27 | OpenDiag *openDiag; | 32 | OpenDiag *openDiag; |
28 | QMenuBar *menubar; | 33 | QMenuBar *menubar; |
29 | QPopupMenu *mailmenu; | 34 | QPopupMenu *mailmenu; |
30 | 35 | ||
31 | protected slots: | 36 | protected slots: |
32 | void slotChangeAttachview(bool state); | 37 | void slotChangeAttachview(bool state); |
33 | virtual void keyPressEvent ( QKeyEvent * e ); | 38 | virtual void keyPressEvent ( QKeyEvent * e ); |
34 | 39 | ||
35 | 40 | ||
36 | }; | 41 | }; |
37 | 42 | ||
38 | #endif | 43 | #endif |
39 | 44 | ||
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 59618bf..d543aaf 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,643 +1,652 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
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 ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | hDays.resize ( NUMDAYS );; | ||
119 | eDays.resize ( NUMDAYS );; | ||
118 | days = new QDate[NUMDAYS]; | 120 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 121 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 122 | //events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 123 | mToolTip = new DynamicTip(this); |
122 | 124 | ||
123 | // set default values used for drawing the matrix | 125 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 126 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 127 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 128 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 129 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 130 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 131 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 132 | mSelEnd = mSelStart = NOSELECTION; |
131 | 133 | ||
132 | setAcceptDrops(true); | 134 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 135 | //setFont( QFont("Arial", 10) ); |
134 | 136 | ||
135 | mUpdateTimer = new QTimer( this ); | 137 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 138 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 139 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 140 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 141 | mDayChanged = false; |
140 | updateView(); | 142 | updateView(); |
141 | } | 143 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 144 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 145 | { |
144 | 146 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 147 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 148 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 149 | return QString(); |
148 | QDate mDate = days[tmp]; | 150 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 151 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 152 | Event *event; |
151 | QStringList mToolTip; | 153 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 154 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 155 | QString mToolTipText; |
154 | QString text; | 156 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 157 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 158 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 159 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 160 | QString time; |
159 | if ( event->doesRecur() ) { | 161 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 162 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 163 | prefix ="->" ;multiday = 1; |
162 | } | 164 | } |
163 | else { | 165 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 166 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 167 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 168 | prefix ="<-" ;multiday = 3; |
167 | } | 169 | } |
168 | } | 170 | } |
169 | } else { | 171 | } else { |
170 | if (mDate == event->dtStart().date()) { | 172 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 173 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 174 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 175 | prefix ="<-" ;multiday = 3; |
174 | } | 176 | } |
175 | } | 177 | } |
176 | if ( !event->doesFloat() ) { | 178 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 179 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 181 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 182 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 183 | ||
182 | } | 184 | } |
183 | text = time + event->summary(); | 185 | text = time + event->summary(); |
184 | mToolTipText += prefix + text; | 186 | mToolTipText += prefix + text; |
185 | } else { | 187 | } else { |
186 | if (event->doesFloat()) { | 188 | if (event->doesFloat()) { |
187 | text = event->summary(); | 189 | text = event->summary(); |
188 | mToolTipText += text; | 190 | mToolTipText += text; |
189 | } | 191 | } |
190 | else { | 192 | else { |
191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 193 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
192 | text += " " + event->summary(); | 194 | text += " " + event->summary(); |
193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 195 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
194 | } | 196 | } |
195 | } | 197 | } |
196 | if ( !event->location().isEmpty() ) | 198 | if ( !event->location().isEmpty() ) |
197 | mToolTipText += " (" + event->location() + ")"; | 199 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 200 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 201 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 202 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 203 | #else |
202 | if ( mToolTipText.find ('<') >= 0 ) { | 204 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 205 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 206 | } |
205 | if ( mToolTipText.find ('>') >= 0 ) { | 207 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 208 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 209 | } |
208 | #endif | 210 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 211 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
210 | mToolTip.append( mToolTipText ); | 212 | mToolTip.append( mToolTipText ); |
211 | } | 213 | } |
212 | mToolTip.sort(); | 214 | mToolTip.sort(); |
213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 215 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
214 | } | 216 | } |
215 | void KODayMatrix::setCalendar( Calendar *cal ) | 217 | void KODayMatrix::setCalendar( Calendar *cal ) |
216 | { | 218 | { |
217 | mCalendar = cal; | 219 | mCalendar = cal; |
218 | 220 | ||
219 | setAcceptDrops( mCalendar ); | 221 | setAcceptDrops( mCalendar ); |
220 | 222 | ||
221 | updateEvents(); | 223 | updateEvents(); |
222 | } | 224 | } |
223 | 225 | ||
224 | QColor KODayMatrix::getShadedColor(QColor color) | 226 | QColor KODayMatrix::getShadedColor(QColor color) |
225 | { | 227 | { |
226 | QColor shaded; | 228 | QColor shaded; |
227 | int h=0; | 229 | int h=0; |
228 | int s=0; | 230 | int s=0; |
229 | int v=0; | 231 | int v=0; |
230 | color.hsv(&h,&s,&v); | 232 | color.hsv(&h,&s,&v); |
231 | s = s/4; | 233 | s = s/4; |
232 | v = 192+v/4; | 234 | v = 192+v/4; |
233 | shaded.setHsv(h,s,v); | 235 | shaded.setHsv(h,s,v); |
234 | 236 | ||
235 | return shaded; | 237 | return shaded; |
236 | } | 238 | } |
237 | 239 | ||
238 | KODayMatrix::~KODayMatrix() | 240 | KODayMatrix::~KODayMatrix() |
239 | { | 241 | { |
240 | // delete mKODaymatrixWhatsThis; | 242 | // delete mKODaymatrixWhatsThis; |
241 | delete [] days; | 243 | delete [] days; |
242 | delete [] daylbls; | 244 | delete [] daylbls; |
243 | delete [] events; | 245 | //delete [] events; |
244 | delete mToolTip; | 246 | delete mToolTip; |
245 | } | 247 | } |
246 | 248 | ||
247 | /* | 249 | /* |
248 | void KODayMatrix::setStartDate(QDate start) | 250 | void KODayMatrix::setStartDate(QDate start) |
249 | { | 251 | { |
250 | updateView(start); | 252 | updateView(start); |
251 | } | 253 | } |
252 | */ | 254 | */ |
253 | 255 | ||
254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 256 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
255 | { | 257 | { |
256 | 258 | ||
257 | if (mSelStart == NOSELECTION) { | 259 | if (mSelStart == NOSELECTION) { |
258 | return; | 260 | return; |
259 | } | 261 | } |
260 | 262 | ||
261 | //cope with selection being out of matrix limits at top (< 0) | 263 | //cope with selection being out of matrix limits at top (< 0) |
262 | int i0 = mSelStart; | 264 | int i0 = mSelStart; |
263 | if (i0 < 0) { | 265 | if (i0 < 0) { |
264 | for (int i = i0; i < 0; i++) { | 266 | for (int i = i0; i < 0; i++) { |
265 | selDays.append(days[0].addDays(i)); | 267 | selDays.append(days[0].addDays(i)); |
266 | } | 268 | } |
267 | i0 = 0; | 269 | i0 = 0; |
268 | } | 270 | } |
269 | 271 | ||
270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 272 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
271 | if (mSelEnd > NUMDAYS-1) { | 273 | if (mSelEnd > NUMDAYS-1) { |
272 | for (int i = i0; i <= NUMDAYS-1; i++) { | 274 | for (int i = i0; i <= NUMDAYS-1; i++) { |
273 | selDays.append(days[i]); | 275 | selDays.append(days[i]); |
274 | } | 276 | } |
275 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 277 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
276 | selDays.append(days[0].addDays(i)); | 278 | selDays.append(days[0].addDays(i)); |
277 | } | 279 | } |
278 | 280 | ||
279 | // apply normal routine to selection being entirely within matrix limits | 281 | // apply normal routine to selection being entirely within matrix limits |
280 | } else { | 282 | } else { |
281 | for (int i = i0; i <= mSelEnd; i++) { | 283 | for (int i = i0; i <= mSelEnd; i++) { |
282 | selDays.append(days[i]); | 284 | selDays.append(days[i]); |
283 | } | 285 | } |
284 | } | 286 | } |
285 | } | 287 | } |
286 | 288 | ||
287 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 289 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
288 | { | 290 | { |
289 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 291 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
290 | mSelStart = startdate.daysTo(start); | 292 | mSelStart = startdate.daysTo(start); |
291 | if ( mSelStart < 0 ) | 293 | if ( mSelStart < 0 ) |
292 | mSelStart = 0; | 294 | mSelStart = 0; |
293 | mSelEnd = startdate.daysTo(end); | 295 | mSelEnd = startdate.daysTo(end); |
294 | if ( mSelEnd > NUMDAYS-1 ) | 296 | if ( mSelEnd > NUMDAYS-1 ) |
295 | mSelEnd = NUMDAYS-1; | 297 | mSelEnd = NUMDAYS-1; |
296 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 298 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
297 | clearSelection(); | 299 | clearSelection(); |
298 | if ( noSel ) | 300 | if ( noSel ) |
299 | return false; | 301 | return false; |
300 | } | 302 | } |
301 | 303 | ||
302 | return true; | 304 | return true; |
303 | } | 305 | } |
304 | void KODayMatrix::clearSelection() | 306 | void KODayMatrix::clearSelection() |
305 | { | 307 | { |
306 | mSelEnd = mSelStart = NOSELECTION; | 308 | mSelEnd = mSelStart = NOSELECTION; |
307 | } | 309 | } |
308 | 310 | ||
309 | 311 | ||
310 | void KODayMatrix::recalculateToday() | 312 | void KODayMatrix::recalculateToday() |
311 | { | 313 | { |
312 | today = -1; | 314 | today = -1; |
313 | for (int i=0; i<NUMDAYS; i++) { | 315 | for (int i=0; i<NUMDAYS; i++) { |
314 | events[i] = 0; | 316 | //events[i] = 0; |
315 | days[i] = startdate.addDays(i); | 317 | days[i] = startdate.addDays(i); |
316 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 318 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
317 | 319 | ||
318 | // if today is in the currently displayed month, hilight today | 320 | // if today is in the currently displayed month, hilight today |
319 | if (days[i].year() == QDate::currentDate().year() && | 321 | if (days[i].year() == QDate::currentDate().year() && |
320 | days[i].month() == QDate::currentDate().month() && | 322 | days[i].month() == QDate::currentDate().month() && |
321 | days[i].day() == QDate::currentDate().day()) { | 323 | days[i].day() == QDate::currentDate().day()) { |
322 | today = i; | 324 | today = i; |
323 | } | 325 | } |
324 | } | 326 | } |
325 | // qDebug(QString("Today is visible at %1.").arg(today)); | 327 | // qDebug(QString("Today is visible at %1.").arg(today)); |
326 | } | 328 | } |
327 | 329 | ||
328 | void KODayMatrix::updateView() | 330 | void KODayMatrix::updateView() |
329 | { | 331 | { |
330 | updateView(startdate); | 332 | updateView(startdate); |
331 | } | 333 | } |
332 | void KODayMatrix::repaintViewTimed() | 334 | void KODayMatrix::repaintViewTimed() |
333 | { | 335 | { |
334 | mRepaintTimer->stop(); | 336 | mRepaintTimer->stop(); |
335 | repaint(false); | 337 | repaint(false); |
336 | } | 338 | } |
337 | void KODayMatrix::updateViewTimed() | 339 | void KODayMatrix::updateViewTimed() |
338 | { | 340 | { |
339 | mUpdateTimer->stop(); | 341 | mUpdateTimer->stop(); |
340 | if ( !mCalendar ) { | 342 | if ( !mCalendar ) { |
341 | qDebug("NOT CAL "); | 343 | qDebug("NOT CAL "); |
342 | return; | 344 | return; |
343 | } | 345 | } |
344 | //qDebug("KODayMatrix::updateViewTimed "); | 346 | //qDebug("KODayMatrix::updateViewTimed "); |
345 | for(int i = 0; i < NUMDAYS; i++) { | 347 | for(int i = 0; i < NUMDAYS; i++) { |
346 | // if events are set for the day then remember to draw it bold | 348 | // if events are set for the day then remember to draw it bold |
347 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 349 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
348 | Event *event; | 350 | Event *event; |
349 | int numEvents = eventlist.count(); | 351 | int numEvents = eventlist.count(); |
350 | QString holiStr = ""; | 352 | QString holiStr = ""; |
351 | bDays.clearBit(i); | 353 | bDays.clearBit(i); |
354 | hDays.clearBit(i); | ||
355 | eDays.clearBit(i); | ||
352 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 356 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
353 | ushort recurType = event->recurrence()->doesRecur(); | 357 | ushort recurType = event->recurrence()->doesRecur(); |
354 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 358 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
355 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 359 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
356 | numEvents--; | 360 | numEvents--; |
357 | } | 361 | } |
358 | if ( event->isHoliday()) { | 362 | if ( event->isHoliday()) { |
363 | hDays.setBit(i); | ||
359 | if ( !holiStr.isEmpty() ) | 364 | if ( !holiStr.isEmpty() ) |
360 | holiStr += "\n"; | 365 | holiStr += "\n"; |
361 | holiStr += event->summary(); | 366 | holiStr += event->summary(); |
362 | if ( !event->location().isEmpty() ) | 367 | if ( !event->location().isEmpty() ) |
363 | holiStr += " (" + event->location() + ")"; | 368 | holiStr += " (" + event->location() + ")"; |
364 | } | 369 | } |
365 | if ( event->isBirthday()) { | 370 | if ( event->isBirthday()) { |
366 | if ( !holiStr.isEmpty() ) | 371 | if ( !holiStr.isEmpty() ) |
367 | holiStr += "\n"; | 372 | holiStr += "\n"; |
368 | holiStr += i18n("Birthday") + ": "+event->summary(); | 373 | holiStr += i18n("Birthday") + ": "+event->summary(); |
369 | if ( !event->location().isEmpty() ) | 374 | if ( !event->location().isEmpty() ) |
370 | holiStr += " (" + event->location() + ")"; | 375 | holiStr += " (" + event->location() + ")"; |
371 | bDays.setBit(i); | 376 | bDays.setBit(i); |
372 | } | 377 | } |
373 | } | 378 | } |
374 | events[i] = numEvents; | 379 | if ( numEvents ) |
380 | eDays.setBit(i); | ||
375 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 381 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
376 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 382 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
377 | !holiStr.isEmpty()) { | 383 | !holiStr.isEmpty()) { |
378 | mHolidays[i] = holiStr; | 384 | mHolidays[i] = holiStr; |
379 | } else { | 385 | } else { |
380 | mHolidays[i] = QString::null; | 386 | mHolidays[i] = QString::null; |
381 | } | 387 | } |
382 | } | 388 | } |
383 | if ( ! mPendingUpdateBeforeRepaint ) | 389 | if ( ! mPendingUpdateBeforeRepaint ) |
384 | repaint(false); | 390 | repaint(false); |
385 | } | 391 | } |
386 | void KODayMatrix::updateView(QDate actdate) | 392 | void KODayMatrix::updateView(QDate actdate) |
387 | { | 393 | { |
388 | 394 | ||
389 | if ( ! actdate.isValid() ) { | 395 | if ( ! actdate.isValid() ) { |
390 | //qDebug("date not valid "); | 396 | //qDebug("date not valid "); |
391 | return; | 397 | return; |
392 | } | 398 | } |
393 | mDayChanged = false; | 399 | mDayChanged = false; |
394 | //flag to indicate if the starting day of the matrix has changed by this call | 400 | //flag to indicate if the starting day of the matrix has changed by this call |
395 | //mDayChanged = false; | 401 | //mDayChanged = false; |
396 | // if a new startdate is to be set then apply Cornelius's calculation | 402 | // if a new startdate is to be set then apply Cornelius's calculation |
397 | // of the first day to be shown | 403 | // of the first day to be shown |
398 | if (actdate != startdate) { | 404 | if (actdate != startdate) { |
399 | // reset index of selection according to shift of starting date from startdate to actdate | 405 | // reset index of selection according to shift of starting date from startdate to actdate |
400 | if (mSelStart != NOSELECTION) { | 406 | if (mSelStart != NOSELECTION) { |
401 | int tmp = actdate.daysTo(startdate); | 407 | int tmp = actdate.daysTo(startdate); |
402 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 408 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
403 | // shift selection if new one would be visible at least partly ! | 409 | // shift selection if new one would be visible at least partly ! |
404 | 410 | ||
405 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 411 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
406 | // nested if is required for next X display pushed from a different month - correction required | 412 | // nested if is required for next X display pushed from a different month - correction required |
407 | // otherwise, for month forward and backward, it must be avoided | 413 | // otherwise, for month forward and backward, it must be avoided |
408 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 414 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
409 | mSelStart = mSelStart + tmp; | 415 | mSelStart = mSelStart + tmp; |
410 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 416 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
411 | mSelEnd = mSelEnd + tmp; | 417 | mSelEnd = mSelEnd + tmp; |
412 | } | 418 | } |
413 | } | 419 | } |
414 | startdate = actdate; | 420 | startdate = actdate; |
415 | mDayChanged = true; | 421 | mDayChanged = true; |
416 | recalculateToday(); | 422 | recalculateToday(); |
417 | } | 423 | } |
418 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 424 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
419 | if ( !isVisible() ) { | 425 | if ( !isVisible() ) { |
420 | mPendingUpdateBeforeRepaint = true; | 426 | mPendingUpdateBeforeRepaint = true; |
421 | } else { | 427 | } else { |
422 | #ifdef DESKTOP_VERSION | 428 | #ifdef DESKTOP_VERSION |
423 | //mRepaintTimer->start( 100 ); | 429 | //mRepaintTimer->start( 100 ); |
424 | //updateViewTimed(); | 430 | //updateViewTimed(); |
425 | mUpdateTimer->start( 20 ); | 431 | mUpdateTimer->start( 20 ); |
426 | #else | 432 | #else |
427 | mRepaintTimer->start( 350 ); | 433 | mRepaintTimer->start( 350 ); |
428 | mUpdateTimer->start( 1200 ); | 434 | mUpdateTimer->start( 1200 ); |
429 | #endif | 435 | #endif |
430 | } | 436 | } |
431 | } | 437 | } |
432 | void KODayMatrix::updateEvents() | 438 | void KODayMatrix::updateEvents() |
433 | { | 439 | { |
434 | if ( !mCalendar ) return; | 440 | if ( !mCalendar ) return; |
435 | 441 | ||
436 | for( int i = 0; i < NUMDAYS; i++ ) { | 442 | for( int i = 0; i < NUMDAYS; i++ ) { |
437 | // if events are set for the day then remember to draw it bold | 443 | // if events are set for the day then remember to draw it bold |
438 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 444 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
439 | int numEvents = eventlist.count(); | 445 | int numEvents = eventlist.count(); |
440 | Event *event; | 446 | Event *event; |
441 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 447 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
442 | ushort recurType = event->doesRecur(); | 448 | ushort recurType = event->doesRecur(); |
443 | 449 | ||
444 | if ( ( recurType == Recurrence::rDaily && | 450 | if ( ( recurType == Recurrence::rDaily && |
445 | !KOPrefs::instance()->mDailyRecur ) || | 451 | !KOPrefs::instance()->mDailyRecur ) || |
446 | ( recurType == Recurrence::rWeekly && | 452 | ( recurType == Recurrence::rWeekly && |
447 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 453 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
448 | numEvents--; | 454 | numEvents--; |
449 | } | 455 | } |
450 | } | 456 | } |
451 | events[ i ] = numEvents; | 457 | if ( numEvents ) |
458 | eDays.setBit(i); | ||
459 | else | ||
460 | eDays.clearBit(i); | ||
452 | } | 461 | } |
453 | } | 462 | } |
454 | 463 | ||
455 | const QDate& KODayMatrix::getDate(int offset) | 464 | const QDate& KODayMatrix::getDate(int offset) |
456 | { | 465 | { |
457 | if (offset < 0 || offset > NUMDAYS-1) { | 466 | if (offset < 0 || offset > NUMDAYS-1) { |
458 | qDebug("Wrong offset2 %d", offset); | 467 | qDebug("Wrong offset2 %d", offset); |
459 | return days[0]; | 468 | return days[0]; |
460 | } | 469 | } |
461 | return days[offset]; | 470 | return days[offset]; |
462 | } | 471 | } |
463 | 472 | ||
464 | QString KODayMatrix::getHolidayLabel(int offset) | 473 | QString KODayMatrix::getHolidayLabel(int offset) |
465 | { | 474 | { |
466 | if (offset < 0 || offset > NUMDAYS-1) { | 475 | if (offset < 0 || offset > NUMDAYS-1) { |
467 | qDebug("Wrong offset1 %d", offset); | 476 | qDebug("Wrong offset1 %d", offset); |
468 | return QString(); | 477 | return QString(); |
469 | } | 478 | } |
470 | return mHolidays[offset]; | 479 | return mHolidays[offset]; |
471 | } | 480 | } |
472 | 481 | ||
473 | int KODayMatrix::getDayIndexFrom(int x, int y) | 482 | int KODayMatrix::getDayIndexFrom(int x, int y) |
474 | { | 483 | { |
475 | int colModulo = (width()-2) % 7; | 484 | int colModulo = (width()-2) % 7; |
476 | int rowModulo = (height()-2) % 6; | 485 | int rowModulo = (height()-2) % 6; |
477 | #if 0 | 486 | #if 0 |
478 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 487 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
479 | 6 - x/daysize.width() : x/daysize.width()); | 488 | 6 - x/daysize.width() : x/daysize.width()); |
480 | #endif | 489 | #endif |
481 | int xVal = (x-colModulo/2-2)/daysize.width(); | 490 | int xVal = (x-colModulo/2-2)/daysize.width(); |
482 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 491 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
483 | 492 | ||
484 | 493 | ||
485 | return 7*(yVal) + xVal; | 494 | return 7*(yVal) + xVal; |
486 | 495 | ||
487 | } | 496 | } |
488 | 497 | ||
489 | // ---------------------------------------------------------------------------- | 498 | // ---------------------------------------------------------------------------- |
490 | // M O U S E E V E N T H A N D L I N G | 499 | // M O U S E E V E N T H A N D L I N G |
491 | // ---------------------------------------------------------------------------- | 500 | // ---------------------------------------------------------------------------- |
492 | 501 | ||
493 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 502 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
494 | { | 503 | { |
495 | 504 | ||
496 | if ( e->button() == LeftButton ) | 505 | if ( e->button() == LeftButton ) |
497 | mouseDown = true; | 506 | mouseDown = true; |
498 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 507 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
499 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 508 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
500 | mSelInit = mSelStart; | 509 | mSelInit = mSelStart; |
501 | mSelEnd = mSelStart; | 510 | mSelEnd = mSelStart; |
502 | repaint(false); | 511 | repaint(false); |
503 | } | 512 | } |
504 | 513 | ||
505 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 514 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
506 | { | 515 | { |
507 | if ( e->button() == LeftButton ) | 516 | if ( e->button() == LeftButton ) |
508 | if ( ! mouseDown ) { | 517 | if ( ! mouseDown ) { |
509 | return; | 518 | return; |
510 | } | 519 | } |
511 | else | 520 | else |
512 | mouseDown = false; | 521 | mouseDown = false; |
513 | int tmp = getDayIndexFrom(e->x(), e->y()); | 522 | int tmp = getDayIndexFrom(e->x(), e->y()); |
514 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 523 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
515 | 524 | ||
516 | if (mSelInit > tmp) { | 525 | if (mSelInit > tmp) { |
517 | mSelEnd = mSelInit; | 526 | mSelEnd = mSelInit; |
518 | if (tmp != mSelStart) { | 527 | if (tmp != mSelStart) { |
519 | mSelStart = tmp; | 528 | mSelStart = tmp; |
520 | repaint(false); | 529 | repaint(false); |
521 | } | 530 | } |
522 | } else { | 531 | } else { |
523 | mSelStart = mSelInit; | 532 | mSelStart = mSelInit; |
524 | 533 | ||
525 | //repaint only if selection has changed | 534 | //repaint only if selection has changed |
526 | if (tmp != mSelEnd) { | 535 | if (tmp != mSelEnd) { |
527 | mSelEnd = tmp; | 536 | mSelEnd = tmp; |
528 | repaint(false); | 537 | repaint(false); |
529 | } | 538 | } |
530 | } | 539 | } |
531 | 540 | ||
532 | DateList daylist; | 541 | DateList daylist; |
533 | if ( mSelStart < 0 ) | 542 | if ( mSelStart < 0 ) |
534 | mSelStart = 0; | 543 | mSelStart = 0; |
535 | for (int i = mSelStart; i <= mSelEnd; i++) { | 544 | for (int i = mSelStart; i <= mSelEnd; i++) { |
536 | daylist.append(days[i]); | 545 | daylist.append(days[i]); |
537 | } | 546 | } |
538 | emit selected((const DateList)daylist); | 547 | emit selected((const DateList)daylist); |
539 | 548 | ||
540 | } | 549 | } |
541 | 550 | ||
542 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 551 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
543 | { | 552 | { |
544 | if ( ! mouseDown ) { | 553 | if ( ! mouseDown ) { |
545 | return; | 554 | return; |
546 | } | 555 | } |
547 | int tmp = getDayIndexFrom(e->x(), e->y()); | 556 | int tmp = getDayIndexFrom(e->x(), e->y()); |
548 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 557 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
549 | 558 | ||
550 | if (mSelInit > tmp) { | 559 | if (mSelInit > tmp) { |
551 | mSelEnd = mSelInit; | 560 | mSelEnd = mSelInit; |
552 | if (tmp != mSelStart) { | 561 | if (tmp != mSelStart) { |
553 | mSelStart = tmp; | 562 | mSelStart = tmp; |
554 | repaint(false); | 563 | repaint(false); |
555 | } | 564 | } |
556 | } else { | 565 | } else { |
557 | mSelStart = mSelInit; | 566 | mSelStart = mSelInit; |
558 | 567 | ||
559 | //repaint only if selection has changed | 568 | //repaint only if selection has changed |
560 | if (tmp != mSelEnd) { | 569 | if (tmp != mSelEnd) { |
561 | mSelEnd = tmp; | 570 | mSelEnd = tmp; |
562 | repaint(false); | 571 | repaint(false); |
563 | } | 572 | } |
564 | } | 573 | } |
565 | } | 574 | } |
566 | 575 | ||
567 | // ---------------------------------------------------------------------------- | 576 | // ---------------------------------------------------------------------------- |
568 | // D R A G ' N D R O P H A N D L I N G | 577 | // D R A G ' N D R O P H A N D L I N G |
569 | // ---------------------------------------------------------------------------- | 578 | // ---------------------------------------------------------------------------- |
570 | 579 | ||
571 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 580 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
572 | { | 581 | { |
573 | #ifndef KORG_NODND | 582 | #ifndef KORG_NODND |
574 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 583 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
575 | e->ignore(); | 584 | e->ignore(); |
576 | return; | 585 | return; |
577 | } | 586 | } |
578 | 587 | ||
579 | // some visual feedback | 588 | // some visual feedback |
580 | // oldPalette = palette(); | 589 | // oldPalette = palette(); |
581 | // setPalette(my_HilitePalette); | 590 | // setPalette(my_HilitePalette); |
582 | // update(); | 591 | // update(); |
583 | #endif | 592 | #endif |
584 | } | 593 | } |
585 | 594 | ||
586 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 595 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
587 | { | 596 | { |
588 | #ifndef KORG_NODND | 597 | #ifndef KORG_NODND |
589 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 598 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
590 | e->ignore(); | 599 | e->ignore(); |
591 | return; | 600 | return; |
592 | } | 601 | } |
593 | 602 | ||
594 | e->accept(); | 603 | e->accept(); |
595 | #endif | 604 | #endif |
596 | } | 605 | } |
597 | 606 | ||
598 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 607 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
599 | { | 608 | { |
600 | #ifndef KORG_NODND | 609 | #ifndef KORG_NODND |
601 | // setPalette(oldPalette); | 610 | // setPalette(oldPalette); |
602 | // update(); | 611 | // update(); |
603 | #endif | 612 | #endif |
604 | } | 613 | } |
605 | 614 | ||
606 | void KODayMatrix::dropEvent(QDropEvent *e) | 615 | void KODayMatrix::dropEvent(QDropEvent *e) |
607 | { | 616 | { |
608 | #ifndef KORG_NODND | 617 | #ifndef KORG_NODND |
609 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 618 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
610 | 619 | ||
611 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 620 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
612 | e->ignore(); | 621 | e->ignore(); |
613 | return; | 622 | return; |
614 | } | 623 | } |
615 | 624 | ||
616 | DndFactory factory( mCalendar ); | 625 | DndFactory factory( mCalendar ); |
617 | Event *event = factory.createDrop(e); | 626 | Event *event = factory.createDrop(e); |
618 | 627 | ||
619 | if (event) { | 628 | if (event) { |
620 | e->acceptAction(); | 629 | e->acceptAction(); |
621 | 630 | ||
622 | Event *existingEvent = mCalendar->event(event->uid()); | 631 | Event *existingEvent = mCalendar->event(event->uid()); |
623 | 632 | ||
624 | if(existingEvent) { | 633 | if(existingEvent) { |
625 | // uniquify event | 634 | // uniquify event |
626 | event->recreate(); | 635 | event->recreate(); |
627 | /* | 636 | /* |
628 | KMessageBox::sorry(this, | 637 | KMessageBox::sorry(this, |
629 | i18n("Event already exists in this calendar."), | 638 | i18n("Event already exists in this calendar."), |
630 | i18n("Drop Event")); | 639 | i18n("Drop Event")); |
631 | delete event; | 640 | delete event; |
632 | return; | 641 | return; |
633 | */ | 642 | */ |
634 | } | 643 | } |
635 | // kdDebug() << "Drop new Event" << endl; | 644 | // kdDebug() << "Drop new Event" << endl; |
636 | // Adjust date | 645 | // Adjust date |
637 | QDateTime start = event->dtStart(); | 646 | QDateTime start = event->dtStart(); |
638 | QDateTime end = event->dtEnd(); | 647 | QDateTime end = event->dtEnd(); |
639 | int duration = start.daysTo(end); | 648 | int duration = start.daysTo(end); |
640 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 649 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
641 | 650 | ||
642 | start.setDate(days[idx]); | 651 | start.setDate(days[idx]); |
643 | end.setDate(days[idx].addDays(duration)); | 652 | end.setDate(days[idx].addDays(duration)); |
@@ -673,271 +682,274 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
673 | QPainter p(&myPix); | 682 | QPainter p(&myPix); |
674 | p.setFont(font()); | 683 | p.setFont(font()); |
675 | 684 | ||
676 | 685 | ||
677 | int dheight = daysize.height(); | 686 | int dheight = daysize.height(); |
678 | int dwidth = daysize.width(); | 687 | int dwidth = daysize.width(); |
679 | int row,col; | 688 | int row,col; |
680 | int selw, selh; | 689 | int selw, selh; |
681 | int xyOff = frameWidth(); | 690 | int xyOff = frameWidth(); |
682 | int colModulo = (width()-2) % 7; | 691 | int colModulo = (width()-2) % 7; |
683 | int rowModulo = (height()-2) % 6; | 692 | int rowModulo = (height()-2) % 6; |
684 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 693 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
685 | 694 | ||
686 | bool isRTL = KOGlobals::self()->reverseLayout(); | 695 | bool isRTL = KOGlobals::self()->reverseLayout(); |
687 | 696 | ||
688 | // draw background and topleft frame | 697 | // draw background and topleft frame |
689 | p.fillRect(0,0,width(),height(), mDefaultBackColor); | 698 | p.fillRect(0,0,width(),height(), mDefaultBackColor); |
690 | p.setPen(mDefaultTextColor); | 699 | p.setPen(mDefaultTextColor); |
691 | p.drawRect(0, 0, width(), height()); | 700 | p.drawRect(0, 0, width(), height()); |
692 | int mSelStartT = mSelStart; | 701 | int mSelStartT = mSelStart; |
693 | int mSelEndT = mSelEnd; | 702 | int mSelEndT = mSelEnd; |
694 | if ( mSelEndT >= NUMDAYS ) | 703 | if ( mSelEndT >= NUMDAYS ) |
695 | mSelEndT = NUMDAYS-1; | 704 | mSelEndT = NUMDAYS-1; |
696 | // draw selected days with highlighted background color | 705 | // draw selected days with highlighted background color |
697 | if (mSelStart != NOSELECTION) { | 706 | if (mSelStart != NOSELECTION) { |
698 | bool skip = false; | 707 | bool skip = false; |
699 | if ( ! mouseDown ) { | 708 | if ( ! mouseDown ) { |
700 | int mo = days[20].month(); | 709 | int mo = days[20].month(); |
701 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 710 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
702 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 711 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
703 | int startMo = days[mSelStartT].month(); | 712 | int startMo = days[mSelStartT].month(); |
704 | int endMo = days[mSelEndT].month(); | 713 | int endMo = days[mSelEndT].month(); |
705 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 714 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
706 | startMo = 1; | 715 | startMo = 1; |
707 | if ( endMo == 1 && mo == 12 ) | 716 | if ( endMo == 1 && mo == 12 ) |
708 | endMo = 12; | 717 | endMo = 12; |
709 | if ( mo == 12 && startMo == 1 ) | 718 | if ( mo == 12 && startMo == 1 ) |
710 | startMo = 13; | 719 | startMo = 13; |
711 | if ( (startMo > mo || endMo < mo) ) { | 720 | if ( (startMo > mo || endMo < mo) ) { |
712 | skip = true; | 721 | skip = true; |
713 | } else { | 722 | } else { |
714 | if ( days[mSelStartT].month() != mo ) { | 723 | if ( days[mSelStartT].month() != mo ) { |
715 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 724 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
716 | mSelStartT += add +1; | 725 | mSelStartT += add +1; |
717 | } | 726 | } |
718 | if ( days[mSelEndT].month() != mo ) { | 727 | if ( days[mSelEndT].month() != mo ) { |
719 | int sub = days[mSelEndT].day(); | 728 | int sub = days[mSelEndT].day(); |
720 | mSelEndT -= sub ; | 729 | mSelEndT -= sub ; |
721 | } | 730 | } |
722 | } | 731 | } |
723 | } | 732 | } |
724 | //qDebug("SKIP %d ", skip); | 733 | //qDebug("SKIP %d ", skip); |
725 | if ( ! skip ) { | 734 | if ( ! skip ) { |
726 | row = mSelStartT/7; | 735 | row = mSelStartT/7; |
727 | col = mSelStartT -row*7; | 736 | col = mSelStartT -row*7; |
728 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 737 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
729 | int addCol = 0; | 738 | int addCol = 0; |
730 | int addRow = 0; | 739 | int addRow = 0; |
731 | int addRow2 = 0; | 740 | int addRow2 = 0; |
732 | int addCol2 = 0; | 741 | int addCol2 = 0; |
733 | if (row == mSelEndT/7) { | 742 | if (row == mSelEndT/7) { |
734 | if ( rowModulo ) { | 743 | if ( rowModulo ) { |
735 | if ( row >= 6 - rowModulo ) | 744 | if ( row >= 6 - rowModulo ) |
736 | addRow = row - 5 + rowModulo; | 745 | addRow = row - 5 + rowModulo; |
737 | } | 746 | } |
738 | if ( colModulo ) { | 747 | if ( colModulo ) { |
739 | int colt1 = mSelEndT%7; | 748 | int colt1 = mSelEndT%7; |
740 | //qDebug("colt1 %d ", colt1 ); | 749 | //qDebug("colt1 %d ", colt1 ); |
741 | if ( colt1 >= 7 - colModulo ) | 750 | if ( colt1 >= 7 - colModulo ) |
742 | addCol = colt1 - 7 + colModulo+1; | 751 | addCol = colt1 - 7 + colModulo+1; |
743 | int colt = mSelStartT%7; | 752 | int colt = mSelStartT%7; |
744 | if ( colt >= 7 - colModulo ) | 753 | if ( colt >= 7 - colModulo ) |
745 | addCol2 = colt - 7 + colModulo; | 754 | addCol2 = colt - 7 + colModulo; |
746 | addCol -= addCol2; | 755 | addCol -= addCol2; |
747 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 756 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
748 | } | 757 | } |
749 | // Single row selection | 758 | // Single row selection |
750 | if ( row == 0) | 759 | if ( row == 0) |
751 | addRow = 1; | 760 | addRow = 1; |
752 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 761 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
753 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 762 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
754 | } else { | 763 | } else { |
755 | // draw first row to the right | 764 | // draw first row to the right |
756 | if ( colModulo ) { | 765 | if ( colModulo ) { |
757 | if ( col >= 7 - colModulo ) | 766 | if ( col >= 7 - colModulo ) |
758 | addCol2 = col - 7 + colModulo; | 767 | addCol2 = col - 7 + colModulo; |
759 | } | 768 | } |
760 | if ( rowModulo ) { | 769 | if ( rowModulo ) { |
761 | if ( row >= 6 - rowModulo ) | 770 | if ( row >= 6 - rowModulo ) |
762 | addRow = row - 5 + rowModulo; | 771 | addRow = row - 5 + rowModulo; |
763 | } | 772 | } |
764 | if ( row == 0) | 773 | if ( row == 0) |
765 | addRow = 1; | 774 | addRow = 1; |
766 | int drawWid = width()-(col*dwidth+1+addCol2)-1; | 775 | int drawWid = width()-(col*dwidth+1+addCol2)-1; |
767 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, | 776 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, |
768 | dheight+1, selcol); | 777 | dheight+1, selcol); |
769 | // draw full block till last line | 778 | // draw full block till last line |
770 | selh = mSelEndT/7-row; | 779 | selh = mSelEndT/7-row; |
771 | addRow = 0; | 780 | addRow = 0; |
772 | if ( rowModulo ) { | 781 | if ( rowModulo ) { |
773 | if ( mSelEndT/7 >= 6 - rowModulo ) | 782 | if ( mSelEndT/7 >= 6 - rowModulo ) |
774 | addRow = mSelEndT/7 - 5 + rowModulo; | 783 | addRow = mSelEndT/7 - 5 + rowModulo; |
775 | } | 784 | } |
776 | if (selh > 1) { | 785 | if (selh > 1) { |
777 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 786 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
778 | } | 787 | } |
779 | // draw last block from left to mSelEndT | 788 | // draw last block from left to mSelEndT |
780 | selw = mSelEndT-7*(mSelEndT/7)+1; | 789 | selw = mSelEndT-7*(mSelEndT/7)+1; |
781 | //qDebug("esl %d ",selw ); | 790 | //qDebug("esl %d ",selw ); |
782 | int add = 0; | 791 | int add = 0; |
783 | if ( colModulo ) { | 792 | if ( colModulo ) { |
784 | add = 7 - colModulo; | 793 | add = 7 - colModulo; |
785 | if ( selw > add ) | 794 | if ( selw > add ) |
786 | add = selw - add; | 795 | add = selw - add; |
787 | else | 796 | else |
788 | add = 0; | 797 | add = 0; |
789 | } | 798 | } |
790 | //qDebug("add %d ", add); | 799 | //qDebug("add %d ", add); |
791 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 800 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
792 | selw*dwidth+add, dheight+1, selcol); | 801 | selw*dwidth+add, dheight+1, selcol); |
793 | } | 802 | } |
794 | } | 803 | } |
795 | } | 804 | } |
796 | 805 | ||
797 | // iterate over all days in the matrix and draw the day label in appropriate colors | 806 | // iterate over all days in the matrix and draw the day label in appropriate colors |
798 | QColor actcol = mDefaultTextColorShaded; | 807 | QColor actcol = mDefaultTextColorShaded; |
799 | p.setPen(actcol); | 808 | p.setPen(actcol); |
800 | QPen tmppen; | 809 | QPen tmppen; |
801 | for(int i = 0; i < NUMDAYS; i++) { | 810 | for(int i = 0; i < NUMDAYS; i++) { |
802 | row = i/7; | 811 | row = i/7; |
803 | col = isRTL ? 6-(i-row*7) : i-row*7; | 812 | col = isRTL ? 6-(i-row*7) : i-row*7; |
804 | 813 | ||
805 | // if it is the first day of a month switch color from normal to shaded and vice versa | 814 | // if it is the first day of a month switch color from normal to shaded and vice versa |
806 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 815 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
807 | if (actcol == mDefaultTextColorShaded) { | 816 | if (actcol == mDefaultTextColorShaded) { |
808 | actcol = mDefaultTextColor; | 817 | actcol = mDefaultTextColor; |
809 | } else { | 818 | } else { |
810 | actcol = mDefaultTextColorShaded; | 819 | actcol = mDefaultTextColorShaded; |
811 | } | 820 | } |
812 | p.setPen(actcol); | 821 | p.setPen(actcol); |
813 | } | 822 | } |
814 | if (actcol == mDefaultTextColorShaded) { | 823 | if (actcol == mDefaultTextColorShaded) { |
815 | if ( ! mouseDown ) { | 824 | if ( ! mouseDown ) { |
816 | continue; | 825 | continue; |
817 | } | 826 | } |
818 | } | 827 | } |
819 | //Reset pen color after selected days block | 828 | //Reset pen color after selected days block |
820 | if (i == mSelEndT+1) { | 829 | if (i == mSelEndT+1) { |
821 | p.setPen(actcol); | 830 | p.setPen(actcol); |
822 | } | 831 | } |
823 | 832 | ||
824 | // if today then draw rectangle around day | 833 | // if today then draw rectangle around day |
825 | if (today == i) { | 834 | if (today == i) { |
826 | tmppen = p.pen(); | 835 | tmppen = p.pen(); |
827 | QPen mTodayPen(p.pen()); | 836 | QPen mTodayPen(p.pen()); |
828 | if ( daysize.width() < 20 ) | 837 | if ( daysize.width() < 20 ) |
829 | mTodayPen.setWidth(1); | 838 | mTodayPen.setWidth(1); |
830 | else | 839 | else |
831 | mTodayPen.setWidth(mTodayMarginWidth); | 840 | mTodayPen.setWidth(mTodayMarginWidth); |
832 | //draw red rectangle for holidays | 841 | //draw red rectangle for holidays |
833 | if (!mHolidays[i].isNull()) { | 842 | if (!mHolidays[i].isNull()) { |
834 | if (actcol == mDefaultTextColor) { | 843 | if (actcol == mDefaultTextColor) { |
835 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 844 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
836 | } else { | 845 | } else { |
837 | mTodayPen.setColor(mHolidayColorShaded); | 846 | mTodayPen.setColor(mHolidayColorShaded); |
838 | } | 847 | } |
839 | } | 848 | } |
840 | //draw gray rectangle for today if in selection | 849 | //draw gray rectangle for today if in selection |
841 | if (i >= mSelStartT && i <= mSelEndT) { | 850 | if (i >= mSelStartT && i <= mSelEndT) { |
842 | QColor grey("grey"); | 851 | QColor grey("grey"); |
843 | mTodayPen.setColor(grey); | 852 | mTodayPen.setColor(grey); |
844 | } | 853 | } |
845 | p.setPen(mTodayPen); | 854 | p.setPen(mTodayPen); |
846 | 855 | ||
847 | 856 | ||
848 | int addCol = 0; | 857 | int addCol = 0; |
849 | int addRow = 0; | 858 | int addRow = 0; |
850 | if (rowModulo) { | 859 | if (rowModulo) { |
851 | if ( row >= 6 - rowModulo ) | 860 | if ( row >= 6 - rowModulo ) |
852 | addRow = row - 5 + rowModulo; | 861 | addRow = row - 5 + rowModulo; |
853 | } | 862 | } |
854 | if ( colModulo ) { | 863 | if ( colModulo ) { |
855 | if ( col >= 7 - colModulo ) | 864 | if ( col >= 7 - colModulo ) |
856 | addCol = col - 6 + colModulo-1; | 865 | addCol = col - 6 + colModulo-1; |
857 | } | 866 | } |
858 | 867 | ||
859 | addCol += 1; | 868 | addCol += 1; |
860 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 869 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
861 | p.setPen(tmppen); | 870 | p.setPen(tmppen); |
862 | } | 871 | } |
863 | 872 | ||
864 | // if any events are on that day then draw it using a bold font | 873 | // if any events are on that day then draw it using a bold font |
865 | if (events[i] > 0) { | 874 | if ( eDays.testBit(i) ) { |
866 | QFont myFont = font(); | 875 | QFont myFont = font(); |
867 | myFont.setBold(true); | 876 | myFont.setBold(true); |
868 | p.setFont(myFont); | 877 | p.setFont(myFont); |
869 | } | 878 | } |
870 | 879 | ||
871 | // if it is a holiday then use the default holiday color | 880 | // if it is a holiday then use the default holiday color |
872 | if (!mHolidays[i].isNull()) { | 881 | if ( !mHolidays[i].isNull()) { |
873 | if ( bDays.testBit(i) ) { | 882 | if ( bDays.testBit(i) ) { |
874 | p.setPen(Qt::green); | 883 | if ( hDays.testBit(i) ) |
884 | p.setPen(QColor(Qt::green)); | ||
885 | else | ||
886 | p.setPen(QColor(Qt::green).dark()); | ||
875 | } else { | 887 | } else { |
876 | if (actcol == mDefaultTextColor) { | 888 | if (actcol == mDefaultTextColor ) { |
877 | p.setPen(KOPrefs::instance()->mHolidayColor); | 889 | p.setPen(KOPrefs::instance()->mHolidayColor); |
878 | } else { | 890 | } else { |
879 | p.setPen(mHolidayColorShaded); | 891 | p.setPen(mHolidayColorShaded); |
880 | } | 892 | } |
881 | } | 893 | } |
882 | } | 894 | } |
883 | 895 | ||
884 | // draw selected days with special color | 896 | // draw selected days with special color |
885 | // DO NOT specially highlight holidays in selection ! | 897 | // DO NOT specially highlight holidays in selection ! |
886 | if (i >= mSelStartT && i <= mSelEndT) { | 898 | if (i >= mSelStartT && i <= mSelEndT) { |
887 | ;//p.setPen(mSelectedDaysColor); | 899 | ;//p.setPen(mSelectedDaysColor); |
888 | } | 900 | } |
889 | 901 | ||
890 | int addCol = 0; | 902 | int addCol = 0; |
891 | int addRow = 0; | 903 | int addRow = 0; |
892 | if ( colModulo ) { | 904 | if ( colModulo ) { |
893 | if ( col >= 7 - colModulo ) | 905 | if ( col >= 7 - colModulo ) |
894 | addCol = col - 7 + colModulo; | 906 | addCol = col - 7 + colModulo; |
895 | } | 907 | } |
896 | if ( rowModulo ) { | 908 | if ( rowModulo ) { |
897 | if ( row >= 6 - rowModulo ) | 909 | if ( row >= 6 - rowModulo ) |
898 | addRow = row - 5 + rowModulo; | 910 | addRow = row - 5 + rowModulo; |
899 | } | 911 | } |
900 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 912 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
901 | ++addCol;//++addCol; | 913 | ++addCol;//++addCol; |
902 | if ( row == 0) | 914 | if ( row == 0) |
903 | addRow = 1; | 915 | addRow = 1; |
904 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 916 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
905 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 917 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
906 | 918 | ||
907 | // reset color to actual color | 919 | // reset color to actual color |
908 | if (!mHolidays[i].isNull()) { | 920 | if (!mHolidays[i].isNull()) { |
909 | p.setPen(actcol); | 921 | p.setPen(actcol); |
910 | } | 922 | } |
911 | // reset bold font to plain font | 923 | // reset bold font to plain font |
912 | if (events[i] > 0) { | 924 | if ( eDays.testBit(i)) { |
913 | QFont myFont = font(); | 925 | QFont myFont = font(); |
914 | myFont.setBold(false); | 926 | myFont.setBold(false); |
915 | p.setFont(myFont); | 927 | p.setFont(myFont); |
916 | } | 928 | } |
917 | } | 929 | } |
918 | int off = 0;//xyOff; | 930 | int off = 0;//xyOff; |
919 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 931 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
920 | //qDebug("ffffffffff %d ", off); | 932 | //qDebug("ffffffffff %d ", off); |
921 | } | 933 | } |
922 | 934 | ||
923 | // ---------------------------------------------------------------------------- | 935 | // ---------------------------------------------------------------------------- |
924 | // R E SI Z E E V E N T H A N D L I N G | 936 | // R E SI Z E E V E N T H A N D L I N G |
925 | // ---------------------------------------------------------------------------- | 937 | // ---------------------------------------------------------------------------- |
926 | 938 | ||
927 | void KODayMatrix::resizeEvent(QResizeEvent *) | 939 | void KODayMatrix::resizeEvent(QResizeEvent *) |
928 | { | 940 | { |
929 | QRect sz = frameRect(); | 941 | QRect sz = frameRect(); |
930 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 942 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
931 | daysize.setWidth(sz.width() / 7); | 943 | daysize.setWidth(sz.width() / 7); |
932 | } | 944 | } |
933 | 945 | ||
934 | QSize KODayMatrix::sizeHint() const | 946 | QSize KODayMatrix::sizeHint() const |
935 | { | 947 | { |
936 | 948 | ||
937 | QFontMetrics fm ( font() ); | 949 | QFontMetrics fm ( font() ); |
938 | int wid = fm.width( "30") *7+3; | 950 | int wid = fm.width( "30") *7+3; |
939 | int hei = fm.height() * 6+3; | 951 | int hei = fm.height() * 6+3; |
940 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 952 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
941 | return QSize ( wid, hei ); | 953 | return QSize ( wid, hei ); |
942 | 954 | ||
943 | } | 955 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 2a1959c..38a7f92 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -41,284 +41,286 @@ class QDragLeaveEvent; | |||
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | class KODaymatrixWhatsThis; | 44 | class KODaymatrixWhatsThis; |
45 | 45 | ||
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * small helper class to dynamically show tooltips inside the day matrix. | 50 | * small helper class to dynamically show tooltips inside the day matrix. |
51 | * This class asks the day matrix object for a appropriate label which | 51 | * This class asks the day matrix object for a appropriate label which |
52 | * is in our special case the name of the holiday or null if this day is no holiday. | 52 | * is in our special case the name of the holiday or null if this day is no holiday. |
53 | */ | 53 | */ |
54 | class DynamicTip : public QToolTip | 54 | class DynamicTip : public QToolTip |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Constructor that expects a KODayMatrix object as parent. | 59 | * Constructor that expects a KODayMatrix object as parent. |
60 | * | 60 | * |
61 | * @param parent the parent KODayMatrix control. | 61 | * @param parent the parent KODayMatrix control. |
62 | */ | 62 | */ |
63 | DynamicTip(QWidget* parent ); | 63 | DynamicTip(QWidget* parent ); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Qt's callback to ask the object to provide an approrpiate text for the | 68 | * Qt's callback to ask the object to provide an approrpiate text for the |
69 | * tooltip to be shown. | 69 | * tooltip to be shown. |
70 | * | 70 | * |
71 | * @param pos coordinates of the mouse. | 71 | * @param pos coordinates of the mouse. |
72 | */ | 72 | */ |
73 | void maybeTip( const QPoint & pos); | 73 | void maybeTip( const QPoint & pos); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | 76 | ||
77 | /** the parent control this tooltip is designed for. */ | 77 | /** the parent control this tooltip is designed for. */ |
78 | KODayMatrix* matrix; | 78 | KODayMatrix* matrix; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
83 | * Cornelius thought this was a waste of memory and a lot of overhead. | 83 | * Cornelius thought this was a waste of memory and a lot of overhead. |
84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
85 | * that draws the labels and allows for dragging selection while maintaining nearly full | 85 | * that draws the labels and allows for dragging selection while maintaining nearly full |
86 | * compatibility in behaviour with its predecessor. | 86 | * compatibility in behaviour with its predecessor. |
87 | * | 87 | * |
88 | * The following functionality has been changed: | 88 | * The following functionality has been changed: |
89 | * | 89 | * |
90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
92 | * o no support for Ctrl+click to create groups of dates | 92 | * o no support for Ctrl+click to create groups of dates |
93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
94 | * user friendly.) | 94 | * user friendly.) |
95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
97 | * two distinct groups of date selections as in the old class) | 97 | * two distinct groups of date selections as in the old class) |
98 | * o now that you can select more then a week it can happen that not all selected days are | 98 | * o now that you can select more then a week it can happen that not all selected days are |
99 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 99 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
100 | * adjust the selection and leave some days undisplayed while scrolling through the months | 100 | * adjust the selection and leave some days undisplayed while scrolling through the months |
101 | * | 101 | * |
102 | * @short day matrix widget of the KDateNavigator | 102 | * @short day matrix widget of the KDateNavigator |
103 | * | 103 | * |
104 | * @author Eitzenberger Thomas | 104 | * @author Eitzenberger Thomas |
105 | */ | 105 | */ |
106 | class KODayMatrix: public QFrame { | 106 | class KODayMatrix: public QFrame { |
107 | 107 | ||
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | 109 | ||
110 | public: | 110 | public: |
111 | 111 | ||
112 | /** constructor to create a day matrix widget. | 112 | /** constructor to create a day matrix widget. |
113 | * | 113 | * |
114 | * @param parent widget that is the parent of the day matrix. Normally this should | 114 | * @param parent widget that is the parent of the day matrix. Normally this should |
115 | * be a KDateNavigator | 115 | * be a KDateNavigator |
116 | * @param calendar instance of a calendar on which all calculations are based | 116 | * @param calendar instance of a calendar on which all calculations are based |
117 | * @param date start date of the matrix (is expected to be already fixed). It is | 117 | * @param date start date of the matrix (is expected to be already fixed). It is |
118 | * assumed that this date is the first week day to be shown in the matrix. | 118 | * assumed that this date is the first week day to be shown in the matrix. |
119 | * @param name name of the widget | 119 | * @param name name of the widget |
120 | */ | 120 | */ |
121 | KODayMatrix( QWidget *parent, const char *name ); | 121 | KODayMatrix( QWidget *parent, const char *name ); |
122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
123 | 123 | ||
124 | /** destructor that deallocates all dynamically allocated private members. | 124 | /** destructor that deallocates all dynamically allocated private members. |
125 | */ | 125 | */ |
126 | ~KODayMatrix(); | 126 | ~KODayMatrix(); |
127 | 127 | ||
128 | /** updates the day matrix to start with the given date. Does all the necessary | 128 | /** updates the day matrix to start with the given date. Does all the necessary |
129 | * checks for holidays or events on a day and stores them for display later on. | 129 | * checks for holidays or events on a day and stores them for display later on. |
130 | * Does NOT update the view visually. Call repaint() for this. | 130 | * Does NOT update the view visually. Call repaint() for this. |
131 | * | 131 | * |
132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
133 | * date. | 133 | * date. |
134 | */ | 134 | */ |
135 | void updateView(QDate actdate); | 135 | void updateView(QDate actdate); |
136 | void updateEvents(); | 136 | void updateEvents(); |
137 | 137 | ||
138 | /** returns the QDate object associated with day indexed by the | 138 | /** returns the QDate object associated with day indexed by the |
139 | * supplied offset. | 139 | * supplied offset. |
140 | */ | 140 | */ |
141 | const QDate& getDate(int offset); | 141 | const QDate& getDate(int offset); |
142 | void setCalendar( Calendar * ); | 142 | void setCalendar( Calendar * ); |
143 | /** returns the official name of this holy day or 0 if there is no label | 143 | /** returns the official name of this holy day or 0 if there is no label |
144 | * for this day. | 144 | * for this day. |
145 | */ | 145 | */ |
146 | QString getHolidayLabel(int offset); | 146 | QString getHolidayLabel(int offset); |
147 | 147 | ||
148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
149 | * DateList. | 149 | * DateList. |
150 | */ | 150 | */ |
151 | void addSelectedDaysTo(DateList&); | 151 | void addSelectedDaysTo(DateList&); |
152 | 152 | ||
153 | /** sets the actual to be displayed selection in the day matrix starting from | 153 | /** sets the actual to be displayed selection in the day matrix starting from |
154 | * start and ending with end. Theview must be manually updated by calling | 154 | * start and ending with end. Theview must be manually updated by calling |
155 | * repaint. (?) | 155 | * repaint. (?) |
156 | */ | 156 | */ |
157 | bool setSelectedDaysFrom(const QDate& start, const QDate& end); | 157 | bool setSelectedDaysFrom(const QDate& start, const QDate& end); |
158 | void clearSelection(); | 158 | void clearSelection(); |
159 | 159 | ||
160 | /** Is today visible in the view? Keep this in sync with | 160 | /** Is today visible in the view? Keep this in sync with |
161 | * the values today (below) can take. | 161 | * the values today (below) can take. |
162 | */ | 162 | */ |
163 | bool isTodayVisible() const { return today>=0; } ; | 163 | bool isTodayVisible() const { return today>=0; } ; |
164 | 164 | ||
165 | /** If today is visible, then we can find out if today is | 165 | /** If today is visible, then we can find out if today is |
166 | * near the beginning or the end of the month. | 166 | * near the beginning or the end of the month. |
167 | * This is dependent on today remaining the index | 167 | * This is dependent on today remaining the index |
168 | * in the array of visible dates and going from | 168 | * in the array of visible dates and going from |
169 | * top left (0) to bottom right (41). | 169 | * top left (0) to bottom right (41). |
170 | */ | 170 | */ |
171 | bool isBeginningOfMonth() const { return today<=8; } ; | 171 | bool isBeginningOfMonth() const { return today<=8; } ; |
172 | bool isEndOfMonth() const { return today>=27; } ; | 172 | bool isEndOfMonth() const { return today>=27; } ; |
173 | QString getWhatsThisText( QPoint ) ; | 173 | QString getWhatsThisText( QPoint ) ; |
174 | QSize sizeHint() const; | 174 | QSize sizeHint() const; |
175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} | 175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} |
176 | public slots: | 176 | public slots: |
177 | /** Recalculates all the flags of the days in the matrix like holidays or events | 177 | /** Recalculates all the flags of the days in the matrix like holidays or events |
178 | * on a day (Actually calls above method with the actual startdate). | 178 | * on a day (Actually calls above method with the actual startdate). |
179 | */ | 179 | */ |
180 | void updateView(); | 180 | void updateView(); |
181 | void updateViewTimed(); | 181 | void updateViewTimed(); |
182 | void repaintViewTimed(); | 182 | void repaintViewTimed(); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Calculate which square in the matrix should be | 185 | * Calculate which square in the matrix should be |
186 | * hilighted to indicate it's today. | 186 | * hilighted to indicate it's today. |
187 | */ | 187 | */ |
188 | void recalculateToday(); | 188 | void recalculateToday(); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | void setStartDate(QDate); | 191 | void setStartDate(QDate); |
192 | */ | 192 | */ |
193 | 193 | ||
194 | signals: | 194 | signals: |
195 | 195 | ||
196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
197 | * inside the matrix | 197 | * inside the matrix |
198 | * | 198 | * |
199 | * @param daylist list of days that have been selected by the user | 199 | * @param daylist list of days that have been selected by the user |
200 | */ | 200 | */ |
201 | void selected( const KCal::DateList &daylist ); | 201 | void selected( const KCal::DateList &daylist ); |
202 | 202 | ||
203 | /** emitted if the user has dropped an event inside the matrix | 203 | /** emitted if the user has dropped an event inside the matrix |
204 | * | 204 | * |
205 | * @param event the dropped calendar event | 205 | * @param event the dropped calendar event |
206 | */ | 206 | */ |
207 | void eventDropped(Event *event); | 207 | void eventDropped(Event *event); |
208 | 208 | ||
209 | protected: | 209 | protected: |
210 | 210 | ||
211 | void paintEvent(QPaintEvent *ev); | 211 | void paintEvent(QPaintEvent *ev); |
212 | 212 | ||
213 | void mousePressEvent (QMouseEvent* e); | 213 | void mousePressEvent (QMouseEvent* e); |
214 | 214 | ||
215 | void mouseReleaseEvent (QMouseEvent* e); | 215 | void mouseReleaseEvent (QMouseEvent* e); |
216 | 216 | ||
217 | void mouseMoveEvent (QMouseEvent* e); | 217 | void mouseMoveEvent (QMouseEvent* e); |
218 | 218 | ||
219 | void dragEnterEvent(QDragEnterEvent *); | 219 | void dragEnterEvent(QDragEnterEvent *); |
220 | 220 | ||
221 | void dragMoveEvent(QDragMoveEvent *); | 221 | void dragMoveEvent(QDragMoveEvent *); |
222 | 222 | ||
223 | void dragLeaveEvent(QDragLeaveEvent *); | 223 | void dragLeaveEvent(QDragLeaveEvent *); |
224 | 224 | ||
225 | void dropEvent(QDropEvent *); | 225 | void dropEvent(QDropEvent *); |
226 | 226 | ||
227 | void resizeEvent(QResizeEvent *); | 227 | void resizeEvent(QResizeEvent *); |
228 | 228 | ||
229 | private: | 229 | private: |
230 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; | 230 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; |
231 | bool mouseDown; | 231 | bool mouseDown; |
232 | QBitArray bDays; | 232 | QBitArray bDays; |
233 | QBitArray hDays; | ||
234 | QBitArray eDays; | ||
233 | QPixmap myPix; | 235 | QPixmap myPix; |
234 | QTimer* mUpdateTimer; | 236 | QTimer* mUpdateTimer; |
235 | QTimer* mRepaintTimer; | 237 | QTimer* mRepaintTimer; |
236 | bool mDayChanged; | 238 | bool mDayChanged; |
237 | bool mPendingUpdateBeforeRepaint; | 239 | bool mPendingUpdateBeforeRepaint; |
238 | 240 | ||
239 | /** returns the index of the day located at the matrix's widget (x,y) position. | 241 | /** returns the index of the day located at the matrix's widget (x,y) position. |
240 | * | 242 | * |
241 | * @param x horizontal coordinate | 243 | * @param x horizontal coordinate |
242 | * @param y vertical coordinate | 244 | * @param y vertical coordinate |
243 | */ | 245 | */ |
244 | int getDayIndexFrom(int x, int y); | 246 | int getDayIndexFrom(int x, int y); |
245 | 247 | ||
246 | /** calculates a "shaded" color from the supplied color object. | 248 | /** calculates a "shaded" color from the supplied color object. |
247 | * (Copied from Cornelius's kdpdatebutton.cpp) | 249 | * (Copied from Cornelius's kdpdatebutton.cpp) |
248 | * | 250 | * |
249 | * @param color source based on which a shaded color should be calculated. | 251 | * @param color source based on which a shaded color should be calculated. |
250 | */ | 252 | */ |
251 | QColor getShadedColor(QColor color); | 253 | QColor getShadedColor(QColor color); |
252 | 254 | ||
253 | /** number of days to be displayed. For now there is no support for any other number then 42. | 255 | /** number of days to be displayed. For now there is no support for any other number then 42. |
254 | so change it at your own risk :o) */ | 256 | so change it at your own risk :o) */ |
255 | static const int NUMDAYS; | 257 | static const int NUMDAYS; |
256 | 258 | ||
257 | /** calendar instance to be queried for holidays, events, ... */ | 259 | /** calendar instance to be queried for holidays, events, ... */ |
258 | Calendar *mCalendar; | 260 | Calendar *mCalendar; |
259 | 261 | ||
260 | /** starting date of the matrix */ | 262 | /** starting date of the matrix */ |
261 | QDate startdate; | 263 | QDate startdate; |
262 | 264 | ||
263 | /** array of day labels to optimeize drawing performance. */ | 265 | /** array of day labels to optimeize drawing performance. */ |
264 | QString *daylbls; | 266 | QString *daylbls; |
265 | 267 | ||
266 | /** array of days displayed to reduce memory consumption by | 268 | /** array of days displayed to reduce memory consumption by |
267 | subsequently calling QDate::addDays(). */ | 269 | subsequently calling QDate::addDays(). */ |
268 | QDate *days; | 270 | QDate *days; |
269 | 271 | ||
270 | /** array of storing the number of events on a given day. | 272 | /** array of storing the number of events on a given day. |
271 | * used for drawing a bold font if there is at least one event on that day. | 273 | * used for drawing a bold font if there is at least one event on that day. |
272 | */ | 274 | */ |
273 | int *events; | 275 | //int *events; |
274 | 276 | ||
275 | /** stores holiday names of the days shown in the matrix. */ | 277 | /** stores holiday names of the days shown in the matrix. */ |
276 | QMap<int,QString> mHolidays; | 278 | QMap<int,QString> mHolidays; |
277 | 279 | ||
278 | /** indey of today or -1 if today is not visible in the matrix. */ | 280 | /** indey of today or -1 if today is not visible in the matrix. */ |
279 | int today; | 281 | int today; |
280 | 282 | ||
281 | /** index of day where dragged selection was initiated. | 283 | /** index of day where dragged selection was initiated. |
282 | used to detect "negative" timely selections */ | 284 | used to detect "negative" timely selections */ |
283 | int mSelInit; | 285 | int mSelInit; |
284 | 286 | ||
285 | /** if mSelStart has this value it indicates that there is no | 287 | /** if mSelStart has this value it indicates that there is no |
286 | actual selection in the matrix. */ | 288 | actual selection in the matrix. */ |
287 | static const int NOSELECTION; | 289 | static const int NOSELECTION; |
288 | 290 | ||
289 | /** index of first selected day. */ | 291 | /** index of first selected day. */ |
290 | int mSelStart; | 292 | int mSelStart; |
291 | 293 | ||
292 | /** index of last selected day. */ | 294 | /** index of last selected day. */ |
293 | int mSelEnd; | 295 | int mSelEnd; |
294 | 296 | ||
295 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 297 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
296 | DynamicTip* mToolTip; | 298 | DynamicTip* mToolTip; |
297 | 299 | ||
298 | 300 | ||
299 | /** default background colour of the matrix. */ | 301 | /** default background colour of the matrix. */ |
300 | QColor mDefaultBackColor; | 302 | QColor mDefaultBackColor; |
301 | 303 | ||
302 | /** default text color of the matrix. */ | 304 | /** default text color of the matrix. */ |
303 | QColor mDefaultTextColor; | 305 | QColor mDefaultTextColor; |
304 | 306 | ||
305 | /** default text color for days not in the actual month. */ | 307 | /** default text color for days not in the actual month. */ |
306 | QColor mDefaultTextColorShaded; | 308 | QColor mDefaultTextColorShaded; |
307 | 309 | ||
308 | /** default text color for holidays not in the actual month. */ | 310 | /** default text color for holidays not in the actual month. */ |
309 | QColor mHolidayColorShaded; | 311 | QColor mHolidayColorShaded; |
310 | 312 | ||
311 | /** text color for selected days. */ | 313 | /** text color for selected days. */ |
312 | QColor mSelectedDaysColor; | 314 | QColor mSelectedDaysColor; |
313 | 315 | ||
314 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 316 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
315 | int mTodayMarginWidth; | 317 | int mTodayMarginWidth; |
316 | 318 | ||
317 | /** stores actual size of each day in the widget so that I dont need to ask this data | 319 | /** stores actual size of each day in the widget so that I dont need to ask this data |
318 | * on every repaint. | 320 | * on every repaint. |
319 | */ | 321 | */ |
320 | QRect daysize; | 322 | QRect daysize; |
321 | 323 | ||
322 | }; | 324 | }; |
323 | 325 | ||
324 | #endif | 326 | #endif |