-rw-r--r-- | bin/kdepim/korganizer/1leftrightarrow.png | bin | 0 -> 148 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/1updownarrow.png | bin | 0 -> 164 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/3leftarrow.png | bin | 0 -> 151 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/3leftarrowB.png | bin | 0 -> 668 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/3rightarrow.png | bin | 0 -> 147 bytes | |||
-rw-r--r-- | bin/kdepim/korganizer/3rightarrowB.png | bin | 0 -> 673 bytes | |||
-rw-r--r-- | bin/kdepim/pwmanager/icons22/decrypted.png | bin | 1117 -> 988 bytes | |||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 4 |
9 files changed, 5 insertions, 1 deletions
diff --git a/bin/kdepim/korganizer/1leftrightarrow.png b/bin/kdepim/korganizer/1leftrightarrow.png new file mode 100644 index 0000000..867f1f0 --- a/dev/null +++ b/bin/kdepim/korganizer/1leftrightarrow.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/1updownarrow.png b/bin/kdepim/korganizer/1updownarrow.png new file mode 100644 index 0000000..8171ec1 --- a/dev/null +++ b/bin/kdepim/korganizer/1updownarrow.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/3leftarrow.png b/bin/kdepim/korganizer/3leftarrow.png new file mode 100644 index 0000000..32ceec1 --- a/dev/null +++ b/bin/kdepim/korganizer/3leftarrow.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/3leftarrowB.png b/bin/kdepim/korganizer/3leftarrowB.png new file mode 100644 index 0000000..5f8fc82 --- a/dev/null +++ b/bin/kdepim/korganizer/3leftarrowB.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/3rightarrow.png b/bin/kdepim/korganizer/3rightarrow.png new file mode 100644 index 0000000..a1db245 --- a/dev/null +++ b/bin/kdepim/korganizer/3rightarrow.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/korganizer/3rightarrowB.png b/bin/kdepim/korganizer/3rightarrowB.png new file mode 100644 index 0000000..7fc4b0c --- a/dev/null +++ b/bin/kdepim/korganizer/3rightarrowB.png | |||
Binary files differ | |||
diff --git a/bin/kdepim/pwmanager/icons22/decrypted.png b/bin/kdepim/pwmanager/icons22/decrypted.png index ea770ea..de67872 100644 --- a/bin/kdepim/pwmanager/icons22/decrypted.png +++ b/bin/kdepim/pwmanager/icons22/decrypted.png | |||
Binary files differ | |||
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index b9c7dec..8001c8f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1161 +1,1163 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | QString fullTime; | 128 | QString fullTime; |
129 | int tW = fm.width("24:00i"); | 129 | int tW = fm.width("24:00i"); |
130 | int timeHeight = fm.height(); | 130 | int timeHeight = fm.height(); |
131 | timeHeight -= (timeHeight/4-2); | 131 | timeHeight -= (timeHeight/4-2); |
132 | int borderWidth = 2; | 132 | int borderWidth = 2; |
133 | QFont nFont = p->font(); | 133 | QFont nFont = p->font(); |
134 | QFont sFont = nFont; | 134 | QFont sFont = nFont; |
135 | sFont.setPointSize( sFont.pointSize()/2+2 ); | 135 | sFont.setPointSize( sFont.pointSize()/2+2 ); |
136 | if (!KGlobal::locale()->use12Clock()) | 136 | if (!KGlobal::locale()->use12Clock()) |
137 | suffix = "00"; | 137 | suffix = "00"; |
138 | else | ||
139 | borderWidth = 0; | ||
138 | QFontMetrics fmS( sFont ); | 140 | QFontMetrics fmS( sFont ); |
139 | int sHei = fmS.height(); | 141 | int sHei = fmS.height(); |
140 | if ( timeHeight > mCellHeight ) { | 142 | if ( timeHeight > mCellHeight ) { |
141 | timeHeight = mCellHeight-1; | 143 | timeHeight = mCellHeight-1; |
142 | sHei -= 2; | 144 | sHei -= 2; |
143 | } | 145 | } |
144 | 146 | ||
145 | while (y < cy + ch) { | 147 | while (y < cy + ch) { |
146 | p->drawLine(cx,y,cx+tW,y); | 148 | p->drawLine(cx,y,cx+tW,y); |
147 | hour.setNum(cell); | 149 | hour.setNum(cell); |
148 | 150 | ||
149 | // handle 24h and am/pm time formats | 151 | // handle 24h and am/pm time formats |
150 | if (KGlobal::locale()->use12Clock()) { | 152 | if (KGlobal::locale()->use12Clock()) { |
151 | if (cell > 11) suffix = "pm"; | 153 | if (cell > 11) suffix = "pm"; |
152 | else | 154 | else |
153 | suffix = "am"; | 155 | suffix = "am"; |
154 | if (cell == 0) hour.setNum(12); | 156 | if (cell == 0) hour.setNum(12); |
155 | if (cell > 12) hour.setNum(cell - 12); | 157 | if (cell > 12) hour.setNum(cell - 12); |
156 | } | 158 | } |
157 | 159 | ||
158 | // create string in format of "XX:XX" or "XXpm/am" | 160 | // create string in format of "XX:XX" or "XXpm/am" |
159 | fullTime = hour;// + suffix; | 161 | fullTime = hour;// + suffix; |
160 | 162 | ||
161 | // center and draw the time label | 163 | // center and draw the time label |
162 | int timeWidth = fm.width(fullTime+"i"); | 164 | int timeWidth = fm.width(fullTime+"i"); |
163 | int tw2 = fm.width(suffix); | 165 | int tw2 = fm.width(suffix); |
164 | int offset = this->width() - timeWidth - tw2; | 166 | int offset = this->width() - timeWidth - tw2; |
165 | p->setFont( nFont ); | 167 | p->setFont( nFont ); |
166 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); | 168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); |
167 | p->setFont( sFont ); | 169 | p->setFont( sFont ); |
168 | offset += timeWidth; | 170 | offset += timeWidth; |
169 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
170 | 172 | ||
171 | // increment indices | 173 | // increment indices |
172 | y += mCellHeight; | 174 | y += mCellHeight; |
173 | cell++; | 175 | cell++; |
174 | } | 176 | } |
175 | } | 177 | } |
176 | 178 | ||
177 | /** | 179 | /** |
178 | Calculates the minimum width. | 180 | Calculates the minimum width. |
179 | */ | 181 | */ |
180 | int TimeLabels::minimumWidth() const | 182 | int TimeLabels::minimumWidth() const |
181 | { | 183 | { |
182 | return mMiniWidth; | 184 | return mMiniWidth; |
183 | } | 185 | } |
184 | 186 | ||
185 | /** updates widget's internal state */ | 187 | /** updates widget's internal state */ |
186 | void TimeLabels::updateConfig() | 188 | void TimeLabels::updateConfig() |
187 | { | 189 | { |
188 | // set the font | 190 | // set the font |
189 | // config->setGroup("Fonts"); | 191 | // config->setGroup("Fonts"); |
190 | // QFont font = config->readFontEntry("TimeBar Font"); | 192 | // QFont font = config->readFontEntry("TimeBar Font"); |
191 | setFont(KOPrefs::instance()->mTimeBarFont); | 193 | setFont(KOPrefs::instance()->mTimeBarFont); |
192 | mMiniWidth = fontMetrics().width("88:88") + 2 ; | 194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; |
193 | // update geometry restrictions based on new settings | 195 | // update geometry restrictions based on new settings |
194 | setFixedWidth(minimumWidth()); | 196 | setFixedWidth(minimumWidth()); |
195 | 197 | ||
196 | // update HourSize | 198 | // update HourSize |
197 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 199 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
198 | resizeContents(50,mRows * mCellHeight); | 200 | resizeContents(50,mRows * mCellHeight); |
199 | } | 201 | } |
200 | 202 | ||
201 | /** update time label positions */ | 203 | /** update time label positions */ |
202 | void TimeLabels::positionChanged() | 204 | void TimeLabels::positionChanged() |
203 | { | 205 | { |
204 | int adjustment = mAgenda->contentsY(); | 206 | int adjustment = mAgenda->contentsY(); |
205 | setContentsPos(0, adjustment); | 207 | setContentsPos(0, adjustment); |
206 | } | 208 | } |
207 | 209 | ||
208 | /** */ | 210 | /** */ |
209 | void TimeLabels::setAgenda(KOAgenda* agenda) | 211 | void TimeLabels::setAgenda(KOAgenda* agenda) |
210 | { | 212 | { |
211 | mAgenda = agenda; | 213 | mAgenda = agenda; |
212 | } | 214 | } |
213 | 215 | ||
214 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 216 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
215 | { | 217 | { |
216 | mMouseDownY = e->pos().y(); | 218 | mMouseDownY = e->pos().y(); |
217 | mOrgCap = topLevelWidget()->caption(); | 219 | mOrgCap = topLevelWidget()->caption(); |
218 | } | 220 | } |
219 | 221 | ||
220 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 222 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
221 | { | 223 | { |
222 | int diff = mMouseDownY - e->pos().y(); | 224 | int diff = mMouseDownY - e->pos().y(); |
223 | if ( diff < 10 && diff > -10 ) | 225 | if ( diff < 10 && diff > -10 ) |
224 | return; | 226 | return; |
225 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 227 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
226 | if ( tSize < 4 ) | 228 | if ( tSize < 4 ) |
227 | tSize = 4; | 229 | tSize = 4; |
228 | if ( tSize > 22 ) | 230 | if ( tSize > 22 ) |
229 | tSize = 22; | 231 | tSize = 22; |
230 | tSize = (tSize-2)/2; | 232 | tSize = (tSize-2)/2; |
231 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 233 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
232 | 234 | ||
233 | } | 235 | } |
234 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 236 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
235 | { | 237 | { |
236 | topLevelWidget()->setCaption( mOrgCap ); | 238 | topLevelWidget()->setCaption( mOrgCap ); |
237 | int diff = mMouseDownY - e->pos().y(); | 239 | int diff = mMouseDownY - e->pos().y(); |
238 | if ( diff < 10 && diff > -10 ) | 240 | if ( diff < 10 && diff > -10 ) |
239 | return; | 241 | return; |
240 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 242 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
241 | if ( tSize < 4 ) | 243 | if ( tSize < 4 ) |
242 | tSize = 4; | 244 | tSize = 4; |
243 | if ( tSize > 22 ) | 245 | if ( tSize > 22 ) |
244 | tSize = 22; | 246 | tSize = 22; |
245 | tSize = (tSize/2)*2; | 247 | tSize = (tSize/2)*2; |
246 | if ( tSize == KOPrefs::instance()->mHourSize ) | 248 | if ( tSize == KOPrefs::instance()->mHourSize ) |
247 | return; | 249 | return; |
248 | KOPrefs::instance()->mHourSize = tSize; | 250 | KOPrefs::instance()->mHourSize = tSize; |
249 | emit scaleChanged(); | 251 | emit scaleChanged(); |
250 | } | 252 | } |
251 | 253 | ||
252 | /** This is called in response to repaint() */ | 254 | /** This is called in response to repaint() */ |
253 | void TimeLabels::paintEvent(QPaintEvent*) | 255 | void TimeLabels::paintEvent(QPaintEvent*) |
254 | { | 256 | { |
255 | 257 | ||
256 | // kdDebug() << "paintevent..." << endl; | 258 | // kdDebug() << "paintevent..." << endl; |
257 | // this is another hack! | 259 | // this is another hack! |
258 | // QPainter painter(this); | 260 | // QPainter painter(this); |
259 | //QString c | 261 | //QString c |
260 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 262 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
261 | } | 263 | } |
262 | 264 | ||
263 | //////////////////////////////////////////////////////////////////////////// | 265 | //////////////////////////////////////////////////////////////////////////// |
264 | 266 | ||
265 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 267 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
266 | : QFrame(parent,name) | 268 | : QFrame(parent,name) |
267 | { | 269 | { |
268 | mColumns = 1; | 270 | mColumns = 1; |
269 | mTopBox = 0; | 271 | mTopBox = 0; |
270 | mLocation = loc; | 272 | mLocation = loc; |
271 | mTopLayout = 0; | 273 | mTopLayout = 0; |
272 | mPaintWidget = 0; | 274 | mPaintWidget = 0; |
273 | mXOffset = 0; | 275 | mXOffset = 0; |
274 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 276 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
275 | else mPixmap = SmallIcon("1downarrow"); | 277 | else mPixmap = SmallIcon("1downarrow"); |
276 | mEnabled.resize(mColumns); | 278 | mEnabled.resize(mColumns); |
277 | mEnabled.fill( false ); | 279 | mEnabled.fill( false ); |
278 | setMinimumHeight(mPixmap.height()); | 280 | setMinimumHeight(mPixmap.height()); |
279 | } | 281 | } |
280 | 282 | ||
281 | EventIndicator::~EventIndicator() | 283 | EventIndicator::~EventIndicator() |
282 | { | 284 | { |
283 | } | 285 | } |
284 | 286 | ||
285 | void EventIndicator::drawContents(QPainter *p) | 287 | void EventIndicator::drawContents(QPainter *p) |
286 | { | 288 | { |
287 | 289 | ||
288 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 290 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
289 | KDGanttSplitterHandle* han = 0; | 291 | KDGanttSplitterHandle* han = 0; |
290 | if ( mPaintWidget ) | 292 | if ( mPaintWidget ) |
291 | han = mPaintWidget->firstHandle(); | 293 | han = mPaintWidget->firstHandle(); |
292 | if ( ! han ) { | 294 | if ( ! han ) { |
293 | int i; | 295 | int i; |
294 | for(i=0;i<mColumns;++i) { | 296 | for(i=0;i<mColumns;++i) { |
295 | if (mEnabled[i]) { | 297 | if (mEnabled[i]) { |
296 | int cellWidth = contentsRect().right()/mColumns; | 298 | int cellWidth = contentsRect().right()/mColumns; |
297 | int xOffset = KOGlobals::self()->reverseLayout() ? | 299 | int xOffset = KOGlobals::self()->reverseLayout() ? |
298 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 300 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
299 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 301 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
300 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 302 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
301 | } | 303 | } |
302 | } | 304 | } |
303 | } else { | 305 | } else { |
304 | han->repaint(); | 306 | han->repaint(); |
305 | //mPaintWidget->setBackgroundColor( red ); | 307 | //mPaintWidget->setBackgroundColor( red ); |
306 | 308 | ||
307 | QPainter pa( han ); | 309 | QPainter pa( han ); |
308 | int i; | 310 | int i; |
309 | bool setColor = false; | 311 | bool setColor = false; |
310 | for(i=0;i<mColumns;++i) { | 312 | for(i=0;i<mColumns;++i) { |
311 | if (mEnabled[i]) { | 313 | if (mEnabled[i]) { |
312 | setColor = true; | 314 | setColor = true; |
313 | 315 | ||
314 | int cellWidth = contentsRect().right()/mColumns; | 316 | int cellWidth = contentsRect().right()/mColumns; |
315 | int xOffset = KOGlobals::self()->reverseLayout() ? | 317 | int xOffset = KOGlobals::self()->reverseLayout() ? |
316 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 318 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
317 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 319 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
318 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 320 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
319 | //qDebug("222draw pix %d ",xOffset ); | 321 | //qDebug("222draw pix %d ",xOffset ); |
320 | 322 | ||
321 | } | 323 | } |
322 | 324 | ||
323 | } | 325 | } |
324 | pa.end(); | 326 | pa.end(); |
325 | 327 | ||
326 | } | 328 | } |
327 | } | 329 | } |
328 | 330 | ||
329 | void EventIndicator::setXOffset( int x ) | 331 | void EventIndicator::setXOffset( int x ) |
330 | { | 332 | { |
331 | mXOffset = x; | 333 | mXOffset = x; |
332 | } | 334 | } |
333 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 335 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
334 | { | 336 | { |
335 | mPaintWidget = w; | 337 | mPaintWidget = w; |
336 | setMaximumHeight(0); | 338 | setMaximumHeight(0); |
337 | setMinimumHeight(0); | 339 | setMinimumHeight(0); |
338 | } | 340 | } |
339 | void EventIndicator::changeColumns(int columns) | 341 | void EventIndicator::changeColumns(int columns) |
340 | { | 342 | { |
341 | mColumns = columns; | 343 | mColumns = columns; |
342 | mEnabled.resize(mColumns); | 344 | mEnabled.resize(mColumns); |
343 | 345 | ||
344 | update(); | 346 | update(); |
345 | } | 347 | } |
346 | 348 | ||
347 | void EventIndicator::enableColumn(int column, bool enable) | 349 | void EventIndicator::enableColumn(int column, bool enable) |
348 | { | 350 | { |
349 | mEnabled[column] = enable; | 351 | mEnabled[column] = enable; |
350 | } | 352 | } |
351 | 353 | ||
352 | 354 | ||
353 | //////////////////////////////////////////////////////////////////////////// | 355 | //////////////////////////////////////////////////////////////////////////// |
354 | //////////////////////////////////////////////////////////////////////////// | 356 | //////////////////////////////////////////////////////////////////////////// |
355 | //////////////////////////////////////////////////////////////////////////// | 357 | //////////////////////////////////////////////////////////////////////////// |
356 | 358 | ||
357 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 359 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
358 | KOEventView (cal,parent,name) | 360 | KOEventView (cal,parent,name) |
359 | { | 361 | { |
360 | mBlockUpdating = true; | 362 | mBlockUpdating = true; |
361 | mStartHour = 8; | 363 | mStartHour = 8; |
362 | mSelectedDates.append(QDate::currentDate()); | 364 | mSelectedDates.append(QDate::currentDate()); |
363 | 365 | ||
364 | mLayoutDayLabels = 0; | 366 | mLayoutDayLabels = 0; |
365 | mDayLabelsFrame = 0; | 367 | mDayLabelsFrame = 0; |
366 | mDayLabels = 0; | 368 | mDayLabels = 0; |
367 | bool isRTL = KOGlobals::self()->reverseLayout(); | 369 | bool isRTL = KOGlobals::self()->reverseLayout(); |
368 | 370 | ||
369 | if ( KOPrefs::instance()->mVerticalScreen ) { | 371 | if ( KOPrefs::instance()->mVerticalScreen ) { |
370 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 372 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
371 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 373 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
372 | } else { | 374 | } else { |
373 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 375 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
374 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 376 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
375 | } | 377 | } |
376 | 378 | ||
377 | QBoxLayout *topLayout = new QVBoxLayout(this); | 379 | QBoxLayout *topLayout = new QVBoxLayout(this); |
378 | 380 | ||
379 | // Create day name labels for agenda columns | 381 | // Create day name labels for agenda columns |
380 | // Create agenda splitter | 382 | // Create agenda splitter |
381 | 383 | ||
382 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 384 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
383 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 385 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
384 | topLayout->addWidget( mSplitterAgenda ); | 386 | topLayout->addWidget( mSplitterAgenda ); |
385 | mAllDayFrame = new QHBox(mSplitterAgenda); | 387 | mAllDayFrame = new QHBox(mSplitterAgenda); |
386 | mAllDayFrame->setFocusPolicy(NoFocus); | 388 | mAllDayFrame->setFocusPolicy(NoFocus); |
387 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 389 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
388 | agendaFrame->setFocusPolicy(NoFocus); | 390 | agendaFrame->setFocusPolicy(NoFocus); |
389 | 391 | ||
390 | // Create all-day agenda widget | 392 | // Create all-day agenda widget |
391 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 393 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
392 | 394 | ||
393 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 395 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
394 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 396 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
395 | int widebut = mExpandButton->sizeHint().width(); | 397 | int widebut = mExpandButton->sizeHint().width(); |
396 | if ( QApplication::desktop()->width() < 480 ) | 398 | if ( QApplication::desktop()->width() < 480 ) |
397 | widebut = widebut*2; | 399 | widebut = widebut*2; |
398 | else | 400 | else |
399 | widebut = (widebut*3) / 2; | 401 | widebut = (widebut*3) / 2; |
400 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 402 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
401 | // QSizePolicy::Fixed ) ); | 403 | // QSizePolicy::Fixed ) ); |
402 | mExpandButton->setFixedSize( widebut, widebut); | 404 | mExpandButton->setFixedSize( widebut, widebut); |
403 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 405 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
404 | mExpandButton->setFocusPolicy(NoFocus); | 406 | mExpandButton->setFocusPolicy(NoFocus); |
405 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 407 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
406 | mAllDayAgenda->setFocusPolicy(NoFocus); | 408 | mAllDayAgenda->setFocusPolicy(NoFocus); |
407 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 409 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
408 | 410 | ||
409 | // Create event context menu for all day agenda | 411 | // Create event context menu for all day agenda |
410 | mAllDayAgendaPopup = eventPopup(); | 412 | mAllDayAgendaPopup = eventPopup(); |
411 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 413 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
412 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 414 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
413 | 415 | ||
414 | // Create agenda frame | 416 | // Create agenda frame |
415 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 417 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
416 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 418 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
417 | 419 | ||
418 | // create event indicator bars | 420 | // create event indicator bars |
419 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 421 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
420 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
421 | // FIX | 423 | // FIX |
422 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 424 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
423 | #endif | 425 | #endif |
424 | mDayLabelsFrame = new QHBox(agendaFrame); | 426 | mDayLabelsFrame = new QHBox(agendaFrame); |
425 | //topLayout->addWidget(mDayLabelsFrame); | 427 | //topLayout->addWidget(mDayLabelsFrame); |
426 | mDayLabels = new QFrame (mDayLabelsFrame); | 428 | mDayLabels = new QFrame (mDayLabelsFrame); |
427 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 429 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
428 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 430 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
429 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 431 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
430 | 432 | ||
431 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 433 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
432 | agendaFrame); | 434 | agendaFrame); |
433 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 435 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
434 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 436 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
435 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 437 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
436 | 438 | ||
437 | // Create time labels | 439 | // Create time labels |
438 | mTimeLabels = new TimeLabels(24,agendaFrame); | 440 | mTimeLabels = new TimeLabels(24,agendaFrame); |
439 | agendaLayout->addWidget(mTimeLabels,2,0); | 441 | agendaLayout->addWidget(mTimeLabels,2,0); |
440 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 442 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
441 | this,SLOT(updateConfig())); | 443 | this,SLOT(updateConfig())); |
442 | 444 | ||
443 | // Create agenda | 445 | // Create agenda |
444 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 446 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
445 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 447 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
446 | agendaLayout->setColStretch(1,1); | 448 | agendaLayout->setColStretch(1,1); |
447 | mAgenda->setFocusPolicy(NoFocus); | 449 | mAgenda->setFocusPolicy(NoFocus); |
448 | // Create event context menu for agenda | 450 | // Create event context menu for agenda |
449 | mAgendaPopup = eventPopup(); | 451 | mAgendaPopup = eventPopup(); |
450 | 452 | ||
451 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 453 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
452 | i18n("Toggle Alarm"),mAgenda, | 454 | i18n("Toggle Alarm"),mAgenda, |
453 | SLOT(popupAlarm()),true); | 455 | SLOT(popupAlarm()),true); |
454 | 456 | ||
455 | 457 | ||
456 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 458 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
457 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 459 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
458 | 460 | ||
459 | // make connections between dependent widgets | 461 | // make connections between dependent widgets |
460 | mTimeLabels->setAgenda(mAgenda); | 462 | mTimeLabels->setAgenda(mAgenda); |
461 | 463 | ||
462 | // Update widgets to reflect user preferences | 464 | // Update widgets to reflect user preferences |
463 | // updateConfig(); | 465 | // updateConfig(); |
464 | 466 | ||
465 | // createDayLabels(); | 467 | // createDayLabels(); |
466 | 468 | ||
467 | // these blank widgets make the All Day Event box line up with the agenda | 469 | // these blank widgets make the All Day Event box line up with the agenda |
468 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 470 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
469 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 471 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
470 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 472 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
471 | 473 | ||
472 | // Scrolling | 474 | // Scrolling |
473 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 475 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
474 | mTimeLabels, SLOT(positionChanged())); | 476 | mTimeLabels, SLOT(positionChanged())); |
475 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 477 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
476 | SLOT(setContentsPos(int))); | 478 | SLOT(setContentsPos(int))); |
477 | 479 | ||
478 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 480 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
479 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 481 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
480 | 482 | ||
481 | // Create/Show/Edit/Delete Event | 483 | // Create/Show/Edit/Delete Event |
482 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 484 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
483 | SLOT(newEvent(int,int))); | 485 | SLOT(newEvent(int,int))); |
484 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 486 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
485 | SLOT(newTodo(int,int))); | 487 | SLOT(newTodo(int,int))); |
486 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 488 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
487 | SLOT(newEvent(int,int,int,int))); | 489 | SLOT(newEvent(int,int,int,int))); |
488 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 490 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
489 | SLOT(newEventAllDay(int,int))); | 491 | SLOT(newEventAllDay(int,int))); |
490 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 492 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
491 | SLOT(newTodoAllDay(int,int))); | 493 | SLOT(newTodoAllDay(int,int))); |
492 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 494 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
493 | SLOT(newEventAllDay(int,int))); | 495 | SLOT(newEventAllDay(int,int))); |
494 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 496 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
495 | SLOT(newTimeSpanSelected(int,int,int,int))); | 497 | SLOT(newTimeSpanSelected(int,int,int,int))); |
496 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 498 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
497 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 499 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
498 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 500 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
499 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 501 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
500 | 502 | ||
501 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 503 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
502 | SIGNAL(editIncidenceSignal(Incidence *))); | 504 | SIGNAL(editIncidenceSignal(Incidence *))); |
503 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 505 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
504 | SIGNAL(editIncidenceSignal(Incidence *))); | 506 | SIGNAL(editIncidenceSignal(Incidence *))); |
505 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 507 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
506 | SIGNAL(showIncidenceSignal(Incidence *))); | 508 | SIGNAL(showIncidenceSignal(Incidence *))); |
507 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 509 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
508 | SIGNAL(showIncidenceSignal(Incidence *))); | 510 | SIGNAL(showIncidenceSignal(Incidence *))); |
509 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 511 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
510 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 512 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
511 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 513 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
512 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 514 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
513 | 515 | ||
514 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 516 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
515 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 517 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
516 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 518 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
517 | SLOT(updateEventDates(KOAgendaItem *, int))); | 519 | SLOT(updateEventDates(KOAgendaItem *, int))); |
518 | 520 | ||
519 | // event indicator update | 521 | // event indicator update |
520 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 522 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
521 | SLOT(updateEventIndicatorTop(int))); | 523 | SLOT(updateEventIndicatorTop(int))); |
522 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 524 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
523 | SLOT(updateEventIndicatorBottom(int))); | 525 | SLOT(updateEventIndicatorBottom(int))); |
524 | // drag signals | 526 | // drag signals |
525 | /* | 527 | /* |
526 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 528 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
527 | SLOT(startDrag(Event *))); | 529 | SLOT(startDrag(Event *))); |
528 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 530 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
529 | SLOT(startDrag(Event *))); | 531 | SLOT(startDrag(Event *))); |
530 | */ | 532 | */ |
531 | // synchronize selections | 533 | // synchronize selections |
532 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 534 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
533 | mAllDayAgenda, SLOT( deselectItem() ) ); | 535 | mAllDayAgenda, SLOT( deselectItem() ) ); |
534 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 536 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
535 | mAgenda, SLOT( deselectItem() ) ); | 537 | mAgenda, SLOT( deselectItem() ) ); |
536 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 538 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
537 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 539 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
538 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 540 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
539 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 541 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
540 | connect( mAgenda, SIGNAL( resizedSignal() ), | 542 | connect( mAgenda, SIGNAL( resizedSignal() ), |
541 | SLOT( updateConfig( ) ) ); | 543 | SLOT( updateConfig( ) ) ); |
542 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 544 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
543 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 545 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
544 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 546 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
545 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 547 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
546 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 548 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
547 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 549 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
548 | 550 | ||
549 | 551 | ||
550 | } | 552 | } |
551 | 553 | ||
552 | void KOAgendaView::toggleAllDay() | 554 | void KOAgendaView::toggleAllDay() |
553 | { | 555 | { |
554 | if ( mSplitterAgenda->firstHandle() ) | 556 | if ( mSplitterAgenda->firstHandle() ) |
555 | mSplitterAgenda->firstHandle()->toggle(); | 557 | mSplitterAgenda->firstHandle()->toggle(); |
556 | } | 558 | } |
557 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 559 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
558 | { | 560 | { |
559 | calendar()->addIncidence( inc ); | 561 | calendar()->addIncidence( inc ); |
560 | 562 | ||
561 | if ( incOld ) { | 563 | if ( incOld ) { |
562 | if ( incOld->type() == "Todo" ) | 564 | if ( incOld->type() == "Todo" ) |
563 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 565 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
564 | else | 566 | else |
565 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 567 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
566 | } | 568 | } |
567 | 569 | ||
568 | } | 570 | } |
569 | 571 | ||
570 | KOAgendaView::~KOAgendaView() | 572 | KOAgendaView::~KOAgendaView() |
571 | { | 573 | { |
572 | delete mAgendaPopup; | 574 | delete mAgendaPopup; |
573 | delete mAllDayAgendaPopup; | 575 | delete mAllDayAgendaPopup; |
574 | delete KOAgendaItem::paintPix(); | 576 | delete KOAgendaItem::paintPix(); |
575 | delete KOAgendaItem::paintPixSel(); | 577 | delete KOAgendaItem::paintPixSel(); |
576 | } | 578 | } |
577 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 579 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
578 | { | 580 | { |
579 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 581 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
580 | bool uc = false; | 582 | bool uc = false; |
581 | int ow = e->oldSize().width(); | 583 | int ow = e->oldSize().width(); |
582 | int oh = e->oldSize().height(); | 584 | int oh = e->oldSize().height(); |
583 | int w = e->size().width(); | 585 | int w = e->size().width(); |
584 | int h = e->size().height(); | 586 | int h = e->size().height(); |
585 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 587 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
586 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 588 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
587 | uc = true; | 589 | uc = true; |
588 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 590 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
589 | } | 591 | } |
590 | mUpcomingWidth = e->size().width() ; | 592 | mUpcomingWidth = e->size().width() ; |
591 | if ( mBlockUpdating || uc ) { | 593 | if ( mBlockUpdating || uc ) { |
592 | mBlockUpdating = false; | 594 | mBlockUpdating = false; |
593 | //mAgenda->setMinimumSize(800 , 600 ); | 595 | //mAgenda->setMinimumSize(800 , 600 ); |
594 | //qDebug("mAgenda->resize+++++++++++++++ "); | 596 | //qDebug("mAgenda->resize+++++++++++++++ "); |
595 | updateConfig(); | 597 | updateConfig(); |
596 | //qDebug("KOAgendaView::Updating now possible "); | 598 | //qDebug("KOAgendaView::Updating now possible "); |
597 | } else | 599 | } else |
598 | createDayLabels(); | 600 | createDayLabels(); |
599 | //qDebug("resizeEvent end "); | 601 | //qDebug("resizeEvent end "); |
600 | 602 | ||
601 | } | 603 | } |
602 | void KOAgendaView::slotDaylabelClicked( int num ) | 604 | void KOAgendaView::slotDaylabelClicked( int num ) |
603 | { | 605 | { |
604 | 606 | ||
605 | QDate firstDate = mSelectedDates.first(); | 607 | QDate firstDate = mSelectedDates.first(); |
606 | if ( num == -1 ) | 608 | if ( num == -1 ) |
607 | emit showDateView( 6, firstDate ); | 609 | emit showDateView( 6, firstDate ); |
608 | else if (num >= 0 ) { | 610 | else if (num >= 0 ) { |
609 | if ( mSelectedDates.count() == 1) | 611 | if ( mSelectedDates.count() == 1) |
610 | emit showDateView( 9, firstDate.addDays( num ) ); | 612 | emit showDateView( 9, firstDate.addDays( num ) ); |
611 | else | 613 | else |
612 | emit showDateView( 3, firstDate.addDays( num ) ); | 614 | emit showDateView( 3, firstDate.addDays( num ) ); |
613 | } | 615 | } |
614 | else | 616 | else |
615 | showDateView( 10, firstDate.addDays(1) ); | 617 | showDateView( 10, firstDate.addDays(1) ); |
616 | } | 618 | } |
617 | 619 | ||
618 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 620 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
619 | { | 621 | { |
620 | 622 | ||
621 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 623 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
622 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 624 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
623 | mDayLabelsList.append( dayLabel ); | 625 | mDayLabelsList.append( dayLabel ); |
624 | mLayoutDayLabels->addWidget(dayLabel); | 626 | mLayoutDayLabels->addWidget(dayLabel); |
625 | return dayLabel ; | 627 | return dayLabel ; |
626 | } | 628 | } |
627 | 629 | ||
628 | void KOAgendaView::createDayLabels() | 630 | void KOAgendaView::createDayLabels() |
629 | { | 631 | { |
630 | 632 | ||
631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 633 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 634 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
633 | return; | 635 | return; |
634 | 636 | ||
635 | } | 637 | } |
636 | int newHight; | 638 | int newHight; |
637 | 639 | ||
638 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 640 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
639 | // It would remove some flickering and gain speed (since this is called by | 641 | // It would remove some flickering and gain speed (since this is called by |
640 | // each updateView() call) | 642 | // each updateView() call) |
641 | 643 | ||
642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 644 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 645 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
644 | if ( maxWid < 0 ) | 646 | if ( maxWid < 0 ) |
645 | maxWid = 20; | 647 | maxWid = 20; |
646 | 648 | ||
647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 649 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
648 | QFontMetrics fm ( dlf ); | 650 | QFontMetrics fm ( dlf ); |
649 | int selCount = mSelectedDates.count(); | 651 | int selCount = mSelectedDates.count(); |
650 | QString dayTest = "Mon 20"; | 652 | QString dayTest = "Mon 20"; |
651 | //QString dayTest = "Mon 20"; | 653 | //QString dayTest = "Mon 20"; |
652 | int wid = fm.width( dayTest ); | 654 | int wid = fm.width( dayTest ); |
653 | //maxWid -= ( selCount * 3 ); //working for QLabels | 655 | //maxWid -= ( selCount * 3 ); //working for QLabels |
654 | maxWid -= ( selCount * 3 ); //working for QPushButton | 656 | maxWid -= ( selCount * 3 ); //working for QPushButton |
655 | if ( maxWid < 0 ) | 657 | if ( maxWid < 0 ) |
656 | maxWid = 20; | 658 | maxWid = 20; |
657 | int needWid = wid * selCount; | 659 | int needWid = wid * selCount; |
658 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 660 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
659 | //if ( needWid > maxWid ) | 661 | //if ( needWid > maxWid ) |
660 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 662 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
661 | while ( needWid > maxWid ) { | 663 | while ( needWid > maxWid ) { |
662 | dayTest = dayTest.left( dayTest.length() - 1 ); | 664 | dayTest = dayTest.left( dayTest.length() - 1 ); |
663 | wid = fm.width( dayTest ); | 665 | wid = fm.width( dayTest ); |
664 | needWid = wid * selCount; | 666 | needWid = wid * selCount; |
665 | } | 667 | } |
666 | int maxLen = dayTest.length(); | 668 | int maxLen = dayTest.length(); |
667 | int fontPoint = dlf.pointSize(); | 669 | int fontPoint = dlf.pointSize(); |
668 | if ( maxLen < 2 ) { | 670 | if ( maxLen < 2 ) { |
669 | int fontPoint = dlf.pointSize(); | 671 | int fontPoint = dlf.pointSize(); |
670 | while ( fontPoint > 4 ) { | 672 | while ( fontPoint > 4 ) { |
671 | --fontPoint; | 673 | --fontPoint; |
672 | dlf.setPointSize( fontPoint ); | 674 | dlf.setPointSize( fontPoint ); |
673 | QFontMetrics f( dlf ); | 675 | QFontMetrics f( dlf ); |
674 | wid = f.width( "30" ); | 676 | wid = f.width( "30" ); |
675 | needWid = wid * selCount; | 677 | needWid = wid * selCount; |
676 | if ( needWid < maxWid ) | 678 | if ( needWid < maxWid ) |
677 | break; | 679 | break; |
678 | } | 680 | } |
679 | maxLen = 2; | 681 | maxLen = 2; |
680 | } | 682 | } |
681 | //qDebug("Max len %d ", dayTest.length() ); | 683 | //qDebug("Max len %d ", dayTest.length() ); |
682 | 684 | ||
683 | QFontMetrics tempF( dlf ); | 685 | QFontMetrics tempF( dlf ); |
684 | newHight = tempF.height(); | 686 | newHight = tempF.height(); |
685 | mDayLabels->setFont( dlf ); | 687 | mDayLabels->setFont( dlf ); |
686 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 688 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
687 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 689 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
688 | //mLayoutDayLabels->addSpacing( 2 ); | 690 | //mLayoutDayLabels->addSpacing( 2 ); |
689 | // QFont lFont = dlf; | 691 | // QFont lFont = dlf; |
690 | bool appendLabels = false; | 692 | bool appendLabels = false; |
691 | KOAgendaButton *dayLabel; | 693 | KOAgendaButton *dayLabel; |
692 | dayLabel = mDayLabelsList.first(); | 694 | dayLabel = mDayLabelsList.first(); |
693 | if ( !dayLabel ) { | 695 | if ( !dayLabel ) { |
694 | appendLabels = true; | 696 | appendLabels = true; |
695 | dayLabel = getNewDaylabel(); | 697 | dayLabel = getNewDaylabel(); |
696 | } | 698 | } |
697 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 699 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
698 | dayLabel->setFont( dlf ); | 700 | dayLabel->setFont( dlf ); |
699 | dayLabel->setNum( -1 ); | 701 | dayLabel->setNum( -1 ); |
700 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 702 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
701 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 703 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
702 | dayLabel->show(); | 704 | dayLabel->show(); |
703 | DateList::ConstIterator dit; | 705 | DateList::ConstIterator dit; |
704 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 706 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
705 | int counter = -1; | 707 | int counter = -1; |
706 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 708 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
707 | ++counter; | 709 | ++counter; |
708 | QDate date = *dit; | 710 | QDate date = *dit; |
709 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 711 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
710 | if ( ! appendLabels ) { | 712 | if ( ! appendLabels ) { |
711 | dayLabel = mDayLabelsList.next(); | 713 | dayLabel = mDayLabelsList.next(); |
712 | if ( !dayLabel ) | 714 | if ( !dayLabel ) |
713 | appendLabels = true; | 715 | appendLabels = true; |
714 | } | 716 | } |
715 | if ( appendLabels ) { | 717 | if ( appendLabels ) { |
716 | dayLabel = getNewDaylabel(); | 718 | dayLabel = getNewDaylabel(); |
717 | } | 719 | } |
718 | dayLabel->setMinimumWidth( 1 ); | 720 | dayLabel->setMinimumWidth( 1 ); |
719 | dayLabel->setMaximumWidth( 10240 ); | 721 | dayLabel->setMaximumWidth( 10240 ); |
720 | dayLabel->setFont( dlf ); | 722 | dayLabel->setFont( dlf ); |
721 | dayLabel->show(); | 723 | dayLabel->show(); |
722 | dayLabel->setNum( counter ); | 724 | dayLabel->setNum( counter ); |
723 | QString str; | 725 | QString str; |
724 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 726 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
725 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 727 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
726 | switch ( maxLen ) { | 728 | switch ( maxLen ) { |
727 | case 2: | 729 | case 2: |
728 | str = QString::number( date.day() ); | 730 | str = QString::number( date.day() ); |
729 | break; | 731 | break; |
730 | 732 | ||
731 | case 3: | 733 | case 3: |
732 | str = dayName.left( 1 ) +QString::number( date.day()); | 734 | str = dayName.left( 1 ) +QString::number( date.day()); |
733 | 735 | ||
734 | break; | 736 | break; |
735 | case 4: | 737 | case 4: |
736 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 738 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
737 | 739 | ||
738 | break; | 740 | break; |
739 | case 5: | 741 | case 5: |
740 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 742 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
741 | 743 | ||
742 | break; | 744 | break; |
743 | case 6: | 745 | case 6: |
744 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 746 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
745 | break; | 747 | break; |
746 | 748 | ||
747 | default: | 749 | default: |
748 | break; | 750 | break; |
749 | } | 751 | } |
750 | if ( oneday ) { | 752 | if ( oneday ) { |
751 | QString addString; | 753 | QString addString; |
752 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 754 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
753 | addString = i18n("Today"); | 755 | addString = i18n("Today"); |
754 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 756 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
755 | addString = i18n("Tomorrow"); | 757 | addString = i18n("Tomorrow"); |
756 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 758 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
757 | addString = i18n("Yesterday"); | 759 | addString = i18n("Yesterday"); |
758 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 760 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
759 | addString = i18n("Day before yesterday"); | 761 | addString = i18n("Day before yesterday"); |
760 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
761 | addString = i18n("Day after tomorrow"); | 763 | addString = i18n("Day after tomorrow"); |
762 | if ( !addString.isEmpty() ) { | 764 | if ( !addString.isEmpty() ) { |
763 | str = addString+", " + str; | 765 | str = addString+", " + str; |
764 | } | 766 | } |
765 | } | 767 | } |
766 | dayLabel->setText(str); | 768 | dayLabel->setText(str); |
767 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 769 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
768 | if (date == QDate::currentDate()) { | 770 | if (date == QDate::currentDate()) { |
769 | QFont bFont = dlf; | 771 | QFont bFont = dlf; |
770 | bFont.setBold( true ); | 772 | bFont.setBold( true ); |
771 | dayLabel->setFont(bFont); | 773 | dayLabel->setFont(bFont); |
772 | } | 774 | } |
773 | //dayLayout->addWidget(dayLabel); | 775 | //dayLayout->addWidget(dayLabel); |
774 | 776 | ||
775 | #ifndef KORG_NOPLUGINS | 777 | #ifndef KORG_NOPLUGINS |
776 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 778 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
777 | CalendarDecoration *it; | 779 | CalendarDecoration *it; |
778 | for(it = cds.first(); it; it = cds.next()) { | 780 | for(it = cds.first(); it; it = cds.next()) { |
779 | QString text = it->shortText( date ); | 781 | QString text = it->shortText( date ); |
780 | if ( !text.isEmpty() ) { | 782 | if ( !text.isEmpty() ) { |
781 | QLabel *label = new QLabel(text,mDayLabels); | 783 | QLabel *label = new QLabel(text,mDayLabels); |
782 | label->setAlignment(AlignCenter); | 784 | label->setAlignment(AlignCenter); |
783 | dayLayout->addWidget(label); | 785 | dayLayout->addWidget(label); |
784 | } | 786 | } |
785 | } | 787 | } |
786 | 788 | ||
787 | for(it = cds.first(); it; it = cds.next()) { | 789 | for(it = cds.first(); it; it = cds.next()) { |
788 | QWidget *wid = it->smallWidget(mDayLabels,date); | 790 | QWidget *wid = it->smallWidget(mDayLabels,date); |
789 | if ( wid ) { | 791 | if ( wid ) { |
790 | // wid->setHeight(20); | 792 | // wid->setHeight(20); |
791 | dayLayout->addWidget(wid); | 793 | dayLayout->addWidget(wid); |
792 | } | 794 | } |
793 | } | 795 | } |
794 | #endif | 796 | #endif |
795 | } | 797 | } |
796 | if ( ! appendLabels ) { | 798 | if ( ! appendLabels ) { |
797 | dayLabel = mDayLabelsList.next(); | 799 | dayLabel = mDayLabelsList.next(); |
798 | if ( !dayLabel ) | 800 | if ( !dayLabel ) |
799 | appendLabels = true; | 801 | appendLabels = true; |
800 | } | 802 | } |
801 | if ( appendLabels ) { | 803 | if ( appendLabels ) { |
802 | dayLabel = getNewDaylabel(); | 804 | dayLabel = getNewDaylabel(); |
803 | } | 805 | } |
804 | //dayLabel->hide();//test only | 806 | //dayLabel->hide();//test only |
805 | 807 | ||
806 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 808 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
807 | if ( offset < 0 ) offset = 0; | 809 | if ( offset < 0 ) offset = 0; |
808 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 810 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
809 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 811 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
810 | dayLabel->setFont( dlf ); | 812 | dayLabel->setFont( dlf ); |
811 | dayLabel->show(); | 813 | dayLabel->show(); |
812 | dayLabel->setNum( -2 ); | 814 | dayLabel->setNum( -2 ); |
813 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 815 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
814 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 816 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
815 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 817 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
816 | if ( !appendLabels ) { | 818 | if ( !appendLabels ) { |
817 | dayLabel = mDayLabelsList.next(); | 819 | dayLabel = mDayLabelsList.next(); |
818 | while ( dayLabel ) { | 820 | while ( dayLabel ) { |
819 | //qDebug("!dayLabel %d",dayLabel ); | 821 | //qDebug("!dayLabel %d",dayLabel ); |
820 | dayLabel->hide(); | 822 | dayLabel->hide(); |
821 | dayLabel = mDayLabelsList.next(); | 823 | dayLabel = mDayLabelsList.next(); |
822 | } | 824 | } |
823 | } | 825 | } |
824 | //mDayLabelsFrame->show(); | 826 | //mDayLabelsFrame->show(); |
825 | //mDayLabels->show(); | 827 | //mDayLabels->show(); |
826 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 828 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
827 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 829 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
828 | mDayLabelsFrame->setFixedHeight( newHight ); | 830 | mDayLabelsFrame->setFixedHeight( newHight ); |
829 | } | 831 | } |
830 | 832 | ||
831 | int KOAgendaView::maxDatesHint() | 833 | int KOAgendaView::maxDatesHint() |
832 | { | 834 | { |
833 | // Not sure about the max number of events, so return 0 for now. | 835 | // Not sure about the max number of events, so return 0 for now. |
834 | return 0; | 836 | return 0; |
835 | } | 837 | } |
836 | 838 | ||
837 | int KOAgendaView::currentDateCount() | 839 | int KOAgendaView::currentDateCount() |
838 | { | 840 | { |
839 | return mSelectedDates.count(); | 841 | return mSelectedDates.count(); |
840 | } | 842 | } |
841 | 843 | ||
842 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 844 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
843 | { | 845 | { |
844 | QPtrList<Incidence> selected; | 846 | QPtrList<Incidence> selected; |
845 | Incidence *incidence; | 847 | Incidence *incidence; |
846 | 848 | ||
847 | incidence = mAgenda->selectedIncidence(); | 849 | incidence = mAgenda->selectedIncidence(); |
848 | if (incidence) selected.append(incidence); | 850 | if (incidence) selected.append(incidence); |
849 | 851 | ||
850 | incidence = mAllDayAgenda->selectedIncidence(); | 852 | incidence = mAllDayAgenda->selectedIncidence(); |
851 | if (incidence) selected.append(incidence); | 853 | if (incidence) selected.append(incidence); |
852 | 854 | ||
853 | return selected; | 855 | return selected; |
854 | } | 856 | } |
855 | 857 | ||
856 | DateList KOAgendaView::selectedDates() | 858 | DateList KOAgendaView::selectedDates() |
857 | { | 859 | { |
858 | DateList selected; | 860 | DateList selected; |
859 | QDate qd; | 861 | QDate qd; |
860 | 862 | ||
861 | qd = mAgenda->selectedIncidenceDate(); | 863 | qd = mAgenda->selectedIncidenceDate(); |
862 | if (qd.isValid()) selected.append(qd); | 864 | if (qd.isValid()) selected.append(qd); |
863 | 865 | ||
864 | qd = mAllDayAgenda->selectedIncidenceDate(); | 866 | qd = mAllDayAgenda->selectedIncidenceDate(); |
865 | if (qd.isValid()) selected.append(qd); | 867 | if (qd.isValid()) selected.append(qd); |
866 | 868 | ||
867 | return selected; | 869 | return selected; |
868 | } | 870 | } |
869 | 871 | ||
870 | 872 | ||
871 | void KOAgendaView::updateView() | 873 | void KOAgendaView::updateView() |
872 | { | 874 | { |
873 | if ( mBlockUpdating ) | 875 | if ( mBlockUpdating ) |
874 | return; | 876 | return; |
875 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 877 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
876 | fillAgenda(); | 878 | fillAgenda(); |
877 | 879 | ||
878 | } | 880 | } |
879 | 881 | ||
880 | 882 | ||
881 | /* | 883 | /* |
882 | Update configuration settings for the agenda view. This method is not | 884 | Update configuration settings for the agenda view. This method is not |
883 | complete. | 885 | complete. |
884 | */ | 886 | */ |
885 | void KOAgendaView::updateConfig() | 887 | void KOAgendaView::updateConfig() |
886 | { | 888 | { |
887 | if ( mBlockUpdating ) | 889 | if ( mBlockUpdating ) |
888 | return; | 890 | return; |
889 | 891 | ||
890 | // update config for children | 892 | // update config for children |
891 | mTimeLabels->updateConfig(); | 893 | mTimeLabels->updateConfig(); |
892 | mAgenda->storePosition(); | 894 | mAgenda->storePosition(); |
893 | mAgenda->updateConfig(); | 895 | mAgenda->updateConfig(); |
894 | mAllDayAgenda->updateConfig(); | 896 | mAllDayAgenda->updateConfig(); |
895 | // widget synchronization | 897 | // widget synchronization |
896 | //TODO: find a better way, maybe signal/slot | 898 | //TODO: find a better way, maybe signal/slot |
897 | mTimeLabels->positionChanged(); | 899 | mTimeLabels->positionChanged(); |
898 | 900 | ||
899 | // for some reason, this needs to be called explicitly | 901 | // for some reason, this needs to be called explicitly |
900 | mTimeLabels->repaint(); | 902 | mTimeLabels->repaint(); |
901 | 903 | ||
902 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 904 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
903 | 905 | ||
904 | // ToolTips displaying summary of events | 906 | // ToolTips displaying summary of events |
905 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 907 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
906 | ->mEnableToolTips); | 908 | ->mEnableToolTips); |
907 | 909 | ||
908 | //setHolidayMasks(); | 910 | //setHolidayMasks(); |
909 | 911 | ||
910 | //createDayLabels(); called by via updateView(); | 912 | //createDayLabels(); called by via updateView(); |
911 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 913 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
912 | updateView(); | 914 | updateView(); |
913 | mAgenda->restorePosition(); | 915 | mAgenda->restorePosition(); |
914 | } | 916 | } |
915 | 917 | ||
916 | 918 | ||
917 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 919 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
918 | { | 920 | { |
919 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 921 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
920 | //qDebug("KOAgendaView::updateEventDates "); | 922 | //qDebug("KOAgendaView::updateEventDates "); |
921 | QDateTime startDt,endDt; | 923 | QDateTime startDt,endDt; |
922 | QDate startDate; | 924 | QDate startDate; |
923 | int lenInSecs; | 925 | int lenInSecs; |
924 | // if ( type == KOAgenda::RESIZETOP ) | 926 | // if ( type == KOAgenda::RESIZETOP ) |
925 | // qDebug("RESIZETOP "); | 927 | // qDebug("RESIZETOP "); |
926 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 928 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
927 | // qDebug("RESIZEBOTTOM "); | 929 | // qDebug("RESIZEBOTTOM "); |
928 | // if ( type == KOAgenda::MOVE ) | 930 | // if ( type == KOAgenda::MOVE ) |
929 | // qDebug("MOVE "); | 931 | // qDebug("MOVE "); |
930 | if ( item->incidence()->type() == "Event" ) { | 932 | if ( item->incidence()->type() == "Event" ) { |
931 | startDt =item->incidence()->dtStart(); | 933 | startDt =item->incidence()->dtStart(); |
932 | endDt = item->incidence()->dtEnd(); | 934 | endDt = item->incidence()->dtEnd(); |
933 | lenInSecs = startDt.secsTo( endDt ); | 935 | lenInSecs = startDt.secsTo( endDt ); |
934 | } | 936 | } |
935 | 937 | ||
936 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 938 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
937 | 939 | ||
938 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 940 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
939 | startDate = mSelectedDates[item->mLastMoveXPos]; | 941 | startDate = mSelectedDates[item->mLastMoveXPos]; |
940 | } else { | 942 | } else { |
941 | if (item->cellX() < 0) { | 943 | if (item->cellX() < 0) { |
942 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 944 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
943 | } else { | 945 | } else { |
944 | startDate = mSelectedDates[item->cellX()]; | 946 | startDate = mSelectedDates[item->cellX()]; |
945 | } | 947 | } |
946 | } | 948 | } |
947 | startDt.setDate(startDate); | 949 | startDt.setDate(startDate); |
948 | 950 | ||
949 | if (item->incidence()->doesFloat()) { | 951 | if (item->incidence()->doesFloat()) { |
950 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 952 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
951 | } else { | 953 | } else { |
952 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 954 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
953 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 955 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
954 | if ( item->incidence()->type() == "Event" ) { | 956 | if ( item->incidence()->type() == "Event" ) { |
955 | if ( type == KOAgenda::MOVE ) { | 957 | if ( type == KOAgenda::MOVE ) { |
956 | endDt = startDt.addSecs(lenInSecs); | 958 | endDt = startDt.addSecs(lenInSecs); |
957 | 959 | ||
958 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 960 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
959 | if (item->lastMultiItem()) { | 961 | if (item->lastMultiItem()) { |
960 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 962 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
961 | endDt.setDate(startDate. | 963 | endDt.setDate(startDate. |
962 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 964 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
963 | } else { | 965 | } else { |
964 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 966 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
965 | endDt.setDate(startDate); | 967 | endDt.setDate(startDate); |
966 | } | 968 | } |
967 | } | 969 | } |
968 | } else { | 970 | } else { |
969 | // todo | 971 | // todo |
970 | if (item->lastMultiItem()) { | 972 | if (item->lastMultiItem()) { |
971 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 973 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
972 | endDt.setDate(startDate. | 974 | endDt.setDate(startDate. |
973 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 975 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
974 | } else { | 976 | } else { |
975 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 977 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
976 | if ( item->cellYBottom() > 0 ) | 978 | if ( item->cellYBottom() > 0 ) |
977 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 979 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
978 | else | 980 | else |
979 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 981 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
980 | endDt.setDate(startDate); | 982 | endDt.setDate(startDate); |
981 | } | 983 | } |
982 | } | 984 | } |
983 | } | 985 | } |
984 | if ( item->incidence()->type() == "Event" ) { | 986 | if ( item->incidence()->type() == "Event" ) { |
985 | item->incidence()->setDtStart(startDt); | 987 | item->incidence()->setDtStart(startDt); |
986 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 988 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
987 | } else if ( item->incidence()->type() == "Todo" ) { | 989 | } else if ( item->incidence()->type() == "Todo" ) { |
988 | Todo* to = static_cast<Todo*>(item->incidence()); | 990 | Todo* to = static_cast<Todo*>(item->incidence()); |
989 | 991 | ||
990 | to->setDtDue(endDt); | 992 | to->setDtDue(endDt); |
991 | if ( to->hasStartDate() ) { | 993 | if ( to->hasStartDate() ) { |
992 | if (to->dtStart() >= to->dtDue() ) | 994 | if (to->dtStart() >= to->dtDue() ) |
993 | to->setDtStart(to->dtDue().addDays( -2 )); | 995 | to->setDtStart(to->dtDue().addDays( -2 )); |
994 | } | 996 | } |
995 | 997 | ||
996 | } | 998 | } |
997 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 999 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
998 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1000 | item->incidence()->setRevision(item->incidence()->revision()+1); |
999 | item->setItemDate(startDt.date()); | 1001 | item->setItemDate(startDt.date()); |
1000 | //item->updateItem(); | 1002 | //item->updateItem(); |
1001 | if ( item->incidence()->type() == "Todo" ) { | 1003 | if ( item->incidence()->type() == "Todo" ) { |
1002 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1004 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1003 | 1005 | ||
1004 | } | 1006 | } |
1005 | else | 1007 | else |
1006 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1008 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1007 | item->updateItem(); | 1009 | item->updateItem(); |
1008 | } | 1010 | } |
1009 | 1011 | ||
1010 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1012 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1011 | { | 1013 | { |
1012 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1014 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1013 | 1015 | ||
1014 | mSelectedDates.clear(); | 1016 | mSelectedDates.clear(); |
1015 | // qDebug("KOAgendaView::showDates "); | 1017 | // qDebug("KOAgendaView::showDates "); |
1016 | QDate d = start; | 1018 | QDate d = start; |
1017 | while (d <= end) { | 1019 | while (d <= end) { |
1018 | mSelectedDates.append(d); | 1020 | mSelectedDates.append(d); |
1019 | d = d.addDays( 1 ); | 1021 | d = d.addDays( 1 ); |
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | // and update the view | 1024 | // and update the view |
1023 | fillAgenda(); | 1025 | fillAgenda(); |
1024 | } | 1026 | } |
1025 | 1027 | ||
1026 | 1028 | ||
1027 | void KOAgendaView::showEvents(QPtrList<Event>) | 1029 | void KOAgendaView::showEvents(QPtrList<Event>) |
1028 | { | 1030 | { |
1029 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1031 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1030 | } | 1032 | } |
1031 | 1033 | ||
1032 | void KOAgendaView::changeEventDisplay(Event *, int) | 1034 | void KOAgendaView::changeEventDisplay(Event *, int) |
1033 | { | 1035 | { |
1034 | // qDebug("KOAgendaView::changeEventDisplay "); | 1036 | // qDebug("KOAgendaView::changeEventDisplay "); |
1035 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1037 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1036 | // this should be re-written to be MUCH smarter. Right now we | 1038 | // this should be re-written to be MUCH smarter. Right now we |
1037 | // are just playing dumb. | 1039 | // are just playing dumb. |
1038 | fillAgenda(); | 1040 | fillAgenda(); |
1039 | } | 1041 | } |
1040 | 1042 | ||
1041 | void KOAgendaView::fillAgenda(const QDate &) | 1043 | void KOAgendaView::fillAgenda(const QDate &) |
1042 | { | 1044 | { |
1043 | // qDebug("KOAgendaView::fillAgenda "); | 1045 | // qDebug("KOAgendaView::fillAgenda "); |
1044 | fillAgenda(); | 1046 | fillAgenda(); |
1045 | } | 1047 | } |
1046 | 1048 | ||
1047 | void KOAgendaView::fillAgenda() | 1049 | void KOAgendaView::fillAgenda() |
1048 | { | 1050 | { |
1049 | if ( globalFlagBlockStartup ) | 1051 | if ( globalFlagBlockStartup ) |
1050 | return; | 1052 | return; |
1051 | if ( globalFlagBlockAgenda == 1 ) | 1053 | if ( globalFlagBlockAgenda == 1 ) |
1052 | return; | 1054 | return; |
1053 | //if ( globalFlagBlockAgenda == 2 ) | 1055 | //if ( globalFlagBlockAgenda == 2 ) |
1054 | //globalFlagBlockAgenda = 0; | 1056 | //globalFlagBlockAgenda = 0; |
1055 | // globalFlagBlockPainting = false; | 1057 | // globalFlagBlockPainting = false; |
1056 | if ( globalFlagBlockAgenda == 0 ) | 1058 | if ( globalFlagBlockAgenda == 0 ) |
1057 | globalFlagBlockAgenda = 1; | 1059 | globalFlagBlockAgenda = 1; |
1058 | // clearView(); | 1060 | // clearView(); |
1059 | //qDebug("fillAgenda()++++ "); | 1061 | //qDebug("fillAgenda()++++ "); |
1060 | globalFlagBlockAgendaItemPaint = 1; | 1062 | globalFlagBlockAgendaItemPaint = 1; |
1061 | 1063 | ||
1062 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1064 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1063 | mAgenda->changeColumns(mSelectedDates.count()); | 1065 | mAgenda->changeColumns(mSelectedDates.count()); |
1064 | qApp->processEvents(); | 1066 | qApp->processEvents(); |
1065 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1067 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1066 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1068 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1067 | setHolidayMasks(); | 1069 | setHolidayMasks(); |
1068 | 1070 | ||
1069 | //mAgenda->hideUnused(); | 1071 | //mAgenda->hideUnused(); |
1070 | //mAllDayAgenda->hideUnused(); | 1072 | //mAllDayAgenda->hideUnused(); |
1071 | 1073 | ||
1072 | // mAgenda->blockNextRepaint( false ); | 1074 | // mAgenda->blockNextRepaint( false ); |
1073 | // mAgenda->viewport()->repaint(); | 1075 | // mAgenda->viewport()->repaint(); |
1074 | // mAgenda->blockNextRepaint( true ); | 1076 | // mAgenda->blockNextRepaint( true ); |
1075 | mMinY.resize(mSelectedDates.count()); | 1077 | mMinY.resize(mSelectedDates.count()); |
1076 | mMaxY.resize(mSelectedDates.count()); | 1078 | mMaxY.resize(mSelectedDates.count()); |
1077 | 1079 | ||
1078 | QPtrList<Event> dayEvents; | 1080 | QPtrList<Event> dayEvents; |
1079 | 1081 | ||
1080 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1082 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1081 | // Therefore, gtodoset all of them. | 1083 | // Therefore, gtodoset all of them. |
1082 | QPtrList<Todo> todos = calendar()->todos(); | 1084 | QPtrList<Todo> todos = calendar()->todos(); |
1083 | 1085 | ||
1084 | mAgenda->setDateList(mSelectedDates); | 1086 | mAgenda->setDateList(mSelectedDates); |
1085 | 1087 | ||
1086 | QDate today = QDate::currentDate(); | 1088 | QDate today = QDate::currentDate(); |
1087 | 1089 | ||
1088 | DateList::ConstIterator dit; | 1090 | DateList::ConstIterator dit; |
1089 | int curCol = 0; | 1091 | int curCol = 0; |
1090 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1092 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1091 | QDate currentDate = *dit; | 1093 | QDate currentDate = *dit; |
1092 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1094 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1093 | // << endl; | 1095 | // << endl; |
1094 | 1096 | ||
1095 | dayEvents = calendar()->events(currentDate,true); | 1097 | dayEvents = calendar()->events(currentDate,true); |
1096 | 1098 | ||
1097 | // Default values, which can never be reached | 1099 | // Default values, which can never be reached |
1098 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1100 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1099 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1101 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1100 | 1102 | ||
1101 | unsigned int numEvent; | 1103 | unsigned int numEvent; |
1102 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1104 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1103 | Event *event = dayEvents.at(numEvent); | 1105 | Event *event = dayEvents.at(numEvent); |
1104 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1106 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1105 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1107 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1106 | continue; | 1108 | continue; |
1107 | // kdDebug() << " Event: " << event->summary() << endl; | 1109 | // kdDebug() << " Event: " << event->summary() << endl; |
1108 | 1110 | ||
1109 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1111 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1110 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1112 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1111 | 1113 | ||
1112 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1114 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1113 | 1115 | ||
1114 | if (event->doesFloat()) { | 1116 | if (event->doesFloat()) { |
1115 | if (event->recurrence()->doesRecur()) { | 1117 | if (event->recurrence()->doesRecur()) { |
1116 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1118 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1117 | } else { | 1119 | } else { |
1118 | if (beginX <= 0 && curCol == 0) { | 1120 | if (beginX <= 0 && curCol == 0) { |
1119 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1121 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1120 | } else if (beginX == curCol) { | 1122 | } else if (beginX == curCol) { |
1121 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1123 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1122 | } | 1124 | } |
1123 | } | 1125 | } |
1124 | } else if (event->isMultiDay()) { | 1126 | } else if (event->isMultiDay()) { |
1125 | if ( event->doesRecur () ) { | 1127 | if ( event->doesRecur () ) { |
1126 | QDate dateit = currentDate; | 1128 | QDate dateit = currentDate; |
1127 | int count = 0; | 1129 | int count = 0; |
1128 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1130 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1129 | while (! event->recursOn( dateit ) && count <= max ) { | 1131 | while (! event->recursOn( dateit ) && count <= max ) { |
1130 | ++count; | 1132 | ++count; |
1131 | dateit = dateit.addDays( -1 ); | 1133 | dateit = dateit.addDays( -1 ); |
1132 | } | 1134 | } |
1133 | bool ok; | 1135 | bool ok; |
1134 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1136 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1135 | if ( ok ) | 1137 | if ( ok ) |
1136 | { | 1138 | { |
1137 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1139 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1138 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1140 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1139 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1141 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1140 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1142 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1141 | 1143 | ||
1142 | } | 1144 | } |
1143 | } | 1145 | } |
1144 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1146 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1145 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1147 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1146 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1148 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1147 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1149 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1148 | //qDebug("insert!!! "); | 1150 | //qDebug("insert!!! "); |
1149 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1151 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1150 | } | 1152 | } |
1151 | if (beginX == curCol) { | 1153 | if (beginX == curCol) { |
1152 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1154 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1153 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1155 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1154 | } else if (endX == curCol) { | 1156 | } else if (endX == curCol) { |
1155 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1157 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1156 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1158 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1157 | } else { | 1159 | } else { |
1158 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1160 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1159 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1161 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1160 | } | 1162 | } |
1161 | } else { | 1163 | } else { |
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index cf0d4ae..92fcd1c 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,512 +1,514 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kfiledialog.h> | 40 | #include <kfiledialog.h> |
41 | #include <kstandarddirs.h> | 41 | #include <kstandarddirs.h> |
42 | 42 | ||
43 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
44 | #include <libkcal/event.h> | 44 | #include <libkcal/event.h> |
45 | #include <libkdepim/categoryselectdialog.h> | 45 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kdateedit.h> | 46 | #include <libkdepim/kdateedit.h> |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | #include "koglobals.h" | 49 | #include "koglobals.h" |
50 | 50 | ||
51 | #include "koeditorgeneral.h" | 51 | #include "koeditorgeneral.h" |
52 | #include "kolocationbox.h" | 52 | #include "kolocationbox.h" |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #else | 55 | #else |
56 | #include <qapplication.h> | 56 | #include <qapplication.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
60 | QObject( parent, name) | 60 | QObject( parent, name) |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | KOEditorGeneral::~KOEditorGeneral() | 64 | KOEditorGeneral::~KOEditorGeneral() |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
69 | { | 69 | { |
70 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 70 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
71 | 71 | ||
72 | #if 0 | 72 | #if 0 |
73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
78 | headerLayout->addWidget(summaryLabel,1,0); | 78 | headerLayout->addWidget(summaryLabel,1,0); |
79 | 79 | ||
80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
85 | if ( QApplication::desktop()->width() > 320 ) | 85 | if ( QApplication::desktop()->width() > 320 ) |
86 | mSummaryEdit->setMaximumHeight( hei +6 ); | 86 | mSummaryEdit->setMaximumHeight( hei +6 ); |
87 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 87 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
88 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 88 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
89 | // mSummaryEdit = new QLineEdit(parent); | 89 | // mSummaryEdit = new QLineEdit(parent); |
90 | headerLayout->addWidget(mSummaryEdit,1,1); | 90 | headerLayout->addWidget(mSummaryEdit,1,1); |
91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
92 | 92 | ||
93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
94 | headerLayout->addWidget(locationLabel,2,0); | 94 | headerLayout->addWidget(locationLabel,2,0); |
95 | 95 | ||
96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
98 | if ( QApplication::desktop()->width() > 320 ) | 98 | if ( QApplication::desktop()->width() > 320 ) |
99 | mLocationEdit->setMaximumHeight( hei + 6); | 99 | mLocationEdit->setMaximumHeight( hei + 6); |
100 | 100 | ||
101 | // mLocationEdit = new QLineEdit(parent); | 101 | // mLocationEdit = new QLineEdit(parent); |
102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
103 | headerLayout->addWidget(mLocationEdit,2,1); | 103 | headerLayout->addWidget(mLocationEdit,2,1); |
104 | headerLayout->setColStretch( 1, 10); | 104 | headerLayout->setColStretch( 1, 10); |
105 | } | 105 | } |
106 | void KOEditorGeneral::setFocusOn( int i ) | 106 | void KOEditorGeneral::setFocusOn( int i ) |
107 | { | 107 | { |
108 | qApp->processEvents(); | 108 | qApp->processEvents(); |
109 | if ( i == 1 ) { | 109 | if ( i == 1 ) { |
110 | mDescriptionEdit->setFocus(); | 110 | mDescriptionEdit->setFocus(); |
111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
112 | } | 112 | } |
113 | if ( i == 2 ) { | 113 | if ( i == 2 ) { |
114 | mSummaryEdit->setFocus(); | 114 | mSummaryEdit->setFocus(); |
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | void KOEditorGeneral::editCategories() | 118 | void KOEditorGeneral::editCategories() |
119 | { | 119 | { |
120 | // qDebug("KOEditorGeneral::editCategories() "); | 120 | // qDebug("KOEditorGeneral::editCategories() "); |
121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
123 | //KOGlobals::fitDialogToScreen( csd ); | 123 | //KOGlobals::fitDialogToScreen( csd ); |
124 | csd->setColorEnabled(); | 124 | csd->setColorEnabled(); |
125 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 125 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
126 | csd->exec(); | 126 | csd->exec(); |
127 | delete csd; | 127 | delete csd; |
128 | } | 128 | } |
129 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 129 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
130 | { | 130 | { |
131 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 131 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
132 | 132 | ||
133 | mCategoriesButton = new QPushButton(parent); | 133 | mCategoriesButton = new QPushButton(parent); |
134 | mCategoriesButton->setText(i18n("Categories...")); | 134 | mCategoriesButton->setText(i18n("Categories...")); |
135 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 135 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
136 | categoriesLayout->addWidget(mCategoriesButton); | 136 | categoriesLayout->addWidget(mCategoriesButton); |
137 | 137 | ||
138 | mCategoriesLabel = new QLabel(parent); | 138 | mCategoriesLabel = new QLabel(parent); |
139 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 139 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
140 | categoriesLayout->addWidget(mCategoriesLabel,1); | 140 | categoriesLayout->addWidget(mCategoriesLabel,1); |
141 | } | 141 | } |
142 | 142 | ||
143 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 143 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
144 | { | 144 | { |
145 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 145 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
146 | 146 | ||
147 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 147 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
148 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 148 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
149 | secrecyLayout->addWidget(mCancelBox); | 149 | secrecyLayout->addWidget(mCancelBox); |
150 | secrecyLayout->addWidget(secrecyLabel); | 150 | secrecyLayout->addWidget(secrecyLabel); |
151 | 151 | ||
152 | mSecrecyCombo = new QComboBox(parent); | 152 | mSecrecyCombo = new QComboBox(parent); |
153 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 153 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
154 | secrecyLayout->addWidget(mSecrecyCombo); | 154 | secrecyLayout->addWidget(mSecrecyCombo); |
155 | } | 155 | } |
156 | 156 | ||
157 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 157 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
158 | { | 158 | { |
159 | mDescriptionEdit = new KTextEdit(parent); | 159 | mDescriptionEdit = new KTextEdit(parent); |
160 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 160 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
161 | mDescriptionEdit->append(""); | 161 | mDescriptionEdit->append(""); |
162 | mDescriptionEdit->setReadOnly(false); | 162 | mDescriptionEdit->setReadOnly(false); |
163 | mDescriptionEdit->setOverwriteMode(false); | 163 | mDescriptionEdit->setOverwriteMode(false); |
164 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 164 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
165 | topLayout->addWidget(mDescriptionEdit); | 165 | topLayout->addWidget(mDescriptionEdit); |
166 | #ifndef DESKTOP_VERSION | 166 | #ifndef DESKTOP_VERSION |
167 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 167 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 172 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
173 | { | 173 | { |
174 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 174 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
175 | 175 | ||
176 | //mAlarmBell = new QLabel(parent); | 176 | //mAlarmBell = new QLabel(parent); |
177 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 177 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
178 | //alarmLayout->addWidget(mAlarmBell); | 178 | //alarmLayout->addWidget(mAlarmBell); |
179 | if ( QApplication::desktop()->width() < 320 ) | 179 | if ( QApplication::desktop()->width() < 320 ) |
180 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 180 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
181 | else | 181 | else |
182 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 182 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
183 | 183 | ||
184 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 184 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
185 | alarmLayout->addWidget(mAlarmButton); | 185 | alarmLayout->addWidget(mAlarmButton); |
186 | 186 | ||
187 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 187 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
188 | alarmLayout->addWidget(mAlarmTimeEdit); | 188 | alarmLayout->addWidget(mAlarmTimeEdit); |
189 | mAlarmIncrCombo = new QComboBox(false, parent); | 189 | mAlarmIncrCombo = new QComboBox(false, parent); |
190 | if ( QApplication::desktop()->width() < 320 ) { | 190 | if ( QApplication::desktop()->width() < 320 ) { |
191 | mAlarmIncrCombo->insertItem(i18n("min")); | 191 | mAlarmIncrCombo->insertItem(i18n("min")); |
192 | mAlarmIncrCombo->insertItem(i18n("hou")); | 192 | mAlarmIncrCombo->insertItem(i18n("hou")); |
193 | mAlarmIncrCombo->insertItem(i18n("day")); | 193 | mAlarmIncrCombo->insertItem(i18n("day")); |
194 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 194 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
195 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 195 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
196 | } else { | 196 | } else { |
197 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 197 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
198 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 198 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
199 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 199 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
200 | } | 200 | } |
201 | 201 | ||
202 | // mAlarmIncrCombo->setMinimumHeight(20); | 202 | // mAlarmIncrCombo->setMinimumHeight(20); |
203 | alarmLayout->addWidget(mAlarmIncrCombo); | 203 | alarmLayout->addWidget(mAlarmIncrCombo); |
204 | mAlarmSoundButton = new QPushButton(parent); | 204 | mAlarmSoundButton = new QPushButton(parent); |
205 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 205 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
206 | mAlarmSoundButton->setToggleButton(true); | 206 | mAlarmSoundButton->setToggleButton(true); |
207 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 207 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
208 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 208 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
209 | alarmLayout->addWidget(mAlarmSoundButton); | 209 | alarmLayout->addWidget(mAlarmSoundButton); |
210 | 210 | ||
211 | mAlarmProgramButton = new QPushButton(parent); | 211 | mAlarmProgramButton = new QPushButton(parent); |
212 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 212 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
213 | mAlarmProgramButton->setToggleButton(true); | 213 | mAlarmProgramButton->setToggleButton(true); |
214 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 214 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
215 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 215 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
216 | alarmLayout->addWidget(mAlarmProgramButton); | 216 | alarmLayout->addWidget(mAlarmProgramButton); |
217 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 217 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
218 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 218 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
219 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 219 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
220 | // mAlarmSoundButton->hide(); | 220 | // mAlarmSoundButton->hide(); |
221 | // mAlarmProgramButton->hide(); | 221 | // mAlarmProgramButton->hide(); |
222 | // } | 222 | // } |
223 | } | 223 | } |
224 | 224 | ||
225 | void KOEditorGeneral::pickAlarmSound() | 225 | void KOEditorGeneral::pickAlarmSound() |
226 | { | 226 | { |
227 | 227 | ||
228 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 228 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
229 | //QString prefix = mAlarmSound; | 229 | //QString prefix = mAlarmSound; |
230 | if (!mAlarmSoundButton->isOn()) { | 230 | if (!mAlarmSoundButton->isOn()) { |
231 | mAlarmSoundButton->setOn(true); | 231 | mAlarmSoundButton->setOn(true); |
232 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 232 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
233 | } else { | 233 | } else { |
234 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 234 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
235 | i18n("*.wav|Wav Files"), 0)); | 235 | i18n("*.wav|Wav Files"), 0)); |
236 | if (!fileName.isEmpty()) { | 236 | if (!fileName.isEmpty()) { |
237 | mAlarmSound = fileName; | 237 | mAlarmSound = fileName; |
238 | QToolTip::remove(mAlarmSoundButton); | 238 | QToolTip::remove(mAlarmSoundButton); |
239 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 239 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
240 | QToolTip::add(mAlarmSoundButton, dispStr); | 240 | QToolTip::add(mAlarmSoundButton, dispStr); |
241 | mAlarmProgramButton->setOn(false); | 241 | mAlarmProgramButton->setOn(false); |
242 | mAlarmSoundButton->setOn(true); | 242 | mAlarmSoundButton->setOn(true); |
243 | } else { | 243 | } else { |
244 | mAlarmProgramButton->setOn(true); | 244 | mAlarmProgramButton->setOn(true); |
245 | mAlarmSoundButton->setOn(false); | 245 | mAlarmSoundButton->setOn(false); |
246 | 246 | ||
247 | } | 247 | } |
248 | } | 248 | } |
249 | #if 0 | 249 | #if 0 |
250 | if (mAlarmProgramButton->isOn()) | 250 | if (mAlarmProgramButton->isOn()) |
251 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 251 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
252 | if ( mAlarmSoundButton->isOn()) | 252 | if ( mAlarmSoundButton->isOn()) |
253 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 253 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
254 | #endif | 254 | #endif |
255 | } | 255 | } |
256 | 256 | ||
257 | void KOEditorGeneral::pickAlarmProgram() | 257 | void KOEditorGeneral::pickAlarmProgram() |
258 | { | 258 | { |
259 | if (!mAlarmProgramButton->isOn()) { | 259 | if (!mAlarmProgramButton->isOn()) { |
260 | mAlarmProgramButton->setOn(true); | 260 | mAlarmProgramButton->setOn(true); |
261 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 261 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
262 | } else { | 262 | } else { |
263 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 263 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
264 | if (!fileName.isEmpty()) { | 264 | if (!fileName.isEmpty()) { |
265 | mAlarmProgram = fileName; | 265 | mAlarmProgram = fileName; |
266 | QToolTip::remove(mAlarmProgramButton); | 266 | QToolTip::remove(mAlarmProgramButton); |
267 | QString dispStr = i18n("Running '%1'").arg(fileName); | 267 | QString dispStr = i18n("Running '%1'").arg(fileName); |
268 | QToolTip::add(mAlarmProgramButton, dispStr); | 268 | QToolTip::add(mAlarmProgramButton, dispStr); |
269 | mAlarmSoundButton->setOn(false); | 269 | mAlarmSoundButton->setOn(false); |
270 | mAlarmProgramButton->setOn(true); | 270 | mAlarmProgramButton->setOn(true); |
271 | } else { | 271 | } else { |
272 | mAlarmProgramButton->setOn(false); | 272 | mAlarmProgramButton->setOn(false); |
273 | mAlarmSoundButton->setOn(true); | 273 | mAlarmSoundButton->setOn(true); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | #if 0 | 276 | #if 0 |
277 | if (mAlarmProgramButton->isOn()) | 277 | if (mAlarmProgramButton->isOn()) |
278 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 278 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
279 | if ( mAlarmSoundButton->isOn()) | 279 | if ( mAlarmSoundButton->isOn()) |
280 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 280 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
281 | #endif | 281 | #endif |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | QString KOEditorGeneral::getFittingPath( const QString s ) | 285 | QString KOEditorGeneral::getFittingPath( const QString s ) |
286 | { | 286 | { |
287 | int maxlen = 50; | 287 | int maxlen = 50; |
288 | if ( QApplication::desktop()->width() < 640 ) { | 288 | if ( QApplication::desktop()->width() < 640 ) { |
289 | if ( QApplication::desktop()->width() < 320 ) | 289 | if ( QApplication::desktop()->width() < 320 ) |
290 | maxlen = 22; | 290 | maxlen = 22; |
291 | else | 291 | else |
292 | maxlen = 35; | 292 | maxlen = 35; |
293 | } | 293 | } |
294 | if ( s.length() > maxlen ) { | 294 | if ( s.length() > maxlen ) { |
295 | return "..."+s.right(maxlen -3); | 295 | return "..."+s.right(maxlen -3); |
296 | } | 296 | } |
297 | return s; | 297 | return s; |
298 | } | 298 | } |
299 | 299 | ||
300 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 300 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
301 | { | 301 | { |
302 | if ( enable ) { | 302 | if ( enable ) { |
303 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 303 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
304 | mAlarmSoundButton->setOn( true ); | 304 | mAlarmSoundButton->setOn( true ); |
305 | if ( mAlarmSound.isEmpty() ) | 305 | if ( mAlarmSound.isEmpty() ) |
306 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 306 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
307 | else { | 307 | else { |
308 | if ( ! QFile::exists( mAlarmSound ) ) | 308 | if ( ! QFile::exists( mAlarmSound ) ) |
309 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 309 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | } | 312 | } |
313 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 313 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
314 | mAlarmTimeEdit->setEnabled(enable); | 314 | mAlarmTimeEdit->setEnabled(enable); |
315 | mAlarmSoundButton->setEnabled(enable); | 315 | mAlarmSoundButton->setEnabled(enable); |
316 | mAlarmProgramButton->setEnabled(enable); | 316 | mAlarmProgramButton->setEnabled(enable); |
317 | mAlarmIncrCombo->setEnabled(enable); | 317 | mAlarmIncrCombo->setEnabled(enable); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 320 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
321 | { | 321 | { |
322 | enableAlarmEdit( !disable ); | 322 | enableAlarmEdit( !disable ); |
323 | } | 323 | } |
324 | 324 | ||
325 | void KOEditorGeneral::enableAlarm( bool enable ) | 325 | void KOEditorGeneral::enableAlarm( bool enable ) |
326 | { | 326 | { |
327 | enableAlarmEdit( enable ); | 327 | enableAlarmEdit( enable ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void KOEditorGeneral::alarmDisable(bool disable) | 330 | void KOEditorGeneral::alarmDisable(bool disable) |
331 | { | 331 | { |
332 | if (!disable) { | 332 | if (!disable) { |
333 | //mAlarmBell->setEnabled(true); | 333 | //mAlarmBell->setEnabled(true); |
334 | mAlarmButton->setEnabled(true); | 334 | mAlarmButton->setEnabled(true); |
335 | } else { | 335 | } else { |
336 | //mAlarmBell->setEnabled(false); | 336 | //mAlarmBell->setEnabled(false); |
337 | mAlarmButton->setEnabled(false); | 337 | mAlarmButton->setEnabled(false); |
338 | mAlarmButton->setChecked(false); | 338 | mAlarmButton->setChecked(false); |
339 | mAlarmTimeEdit->setEnabled(false); | 339 | mAlarmTimeEdit->setEnabled(false); |
340 | mAlarmSoundButton->setEnabled(false); | 340 | mAlarmSoundButton->setEnabled(false); |
341 | mAlarmProgramButton->setEnabled(false); | 341 | mAlarmProgramButton->setEnabled(false); |
342 | mAlarmIncrCombo->setEnabled(false); | 342 | mAlarmIncrCombo->setEnabled(false); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void KOEditorGeneral::setCategories(const QString &str) | 346 | void KOEditorGeneral::setCategories(const QString &str) |
347 | { | 347 | { |
348 | mCategoriesLabel->setText(str); | 348 | mCategoriesLabel->setText(str); |
349 | } | 349 | } |
350 | 350 | ||
351 | void KOEditorGeneral::setDefaults(bool allDay) | 351 | void KOEditorGeneral::setDefaults(bool allDay) |
352 | { | 352 | { |
353 | #if 0 | 353 | #if 0 |
354 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 354 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
355 | #endif | 355 | #endif |
356 | 356 | ||
357 | mAlarmMessage = i18n("Edit new item"); | 357 | mAlarmMessage = i18n("Edit new item"); |
358 | enableAlarmEdit( !allDay ); | 358 | enableAlarmEdit( !allDay ); |
359 | 359 | ||
360 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 360 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
361 | int alarmTime; | 361 | int alarmTime; |
362 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 362 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
363 | int index = KOPrefs::instance()->mAlarmTime; | 363 | int index = KOPrefs::instance()->mAlarmTime; |
364 | if (index < 0 || index > 7) { | 364 | if (index < 0 || index > 7) { |
365 | alarmTime = 15; | 365 | alarmTime = 15; |
366 | } else { | 366 | } else { |
367 | alarmTime = a[index]; | 367 | alarmTime = a[index]; |
368 | } | 368 | } |
369 | mAlarmButton ->setChecked( false ); | 369 | mAlarmButton ->setChecked( false ); |
370 | mAlarmTimeEdit->setValue(alarmTime); | 370 | mAlarmTimeEdit->setValue(alarmTime); |
371 | mAlarmIncrCombo->setCurrentItem(0); | 371 | mAlarmIncrCombo->setCurrentItem(0); |
372 | enableAlarmEdit( false ); | 372 | enableAlarmEdit( false ); |
373 | //alarmDisable (false); | 373 | //alarmDisable (false); |
374 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 374 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
375 | mCancelBox->setChecked( false ); | 375 | mCancelBox->setChecked( false ); |
376 | mSummaryEdit->setEditText(""); | 376 | mSummaryEdit->setEditText(""); |
377 | mLocationEdit->setEditText(""); | 377 | mLocationEdit->setEditText(""); |
378 | mDescriptionEdit->setText(""); | 378 | mDescriptionEdit->setText(""); |
379 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 379 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
380 | setCategories(""); | 380 | setCategories(""); |
381 | } | 381 | } |
382 | void KOEditorGeneral::setSecrecy( int num ) | 382 | void KOEditorGeneral::setSecrecy( int num ) |
383 | { | 383 | { |
384 | mSecrecyCombo->setCurrentItem(num); | 384 | mSecrecyCombo->setCurrentItem(num); |
385 | } | 385 | } |
386 | void KOEditorGeneral::readIncidence(Incidence *event) | 386 | void KOEditorGeneral::readIncidence(Incidence *event) |
387 | { | 387 | { |
388 | 388 | ||
389 | mAlarmMessage = event->summary(); | 389 | mAlarmMessage = event->summary(); |
390 | if ( ! event->location().isEmpty() ) | ||
391 | mAlarmMessage += " ("+event->location()+")"; | ||
390 | mAlarmIncrCombo->setCurrentItem(0); | 392 | mAlarmIncrCombo->setCurrentItem(0); |
391 | mSummaryEdit->setEditText(event->summary()); | 393 | mSummaryEdit->setEditText(event->summary()); |
392 | mLocationEdit->setEditText(event->location()); | 394 | mLocationEdit->setEditText(event->location()); |
393 | mDescriptionEdit->setText(event->description()); | 395 | mDescriptionEdit->setText(event->description()); |
394 | 396 | ||
395 | #if 0 | 397 | #if 0 |
396 | // organizer information | 398 | // organizer information |
397 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 399 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
398 | #endif | 400 | #endif |
399 | 401 | ||
400 | enableAlarmEdit( event->isAlarmEnabled() ); | 402 | enableAlarmEdit( event->isAlarmEnabled() ); |
401 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 403 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
402 | if(!event->isAlarmEnabled()) { | 404 | if(!event->isAlarmEnabled()) { |
403 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 405 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
404 | int alarmTime; | 406 | int alarmTime; |
405 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 407 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
406 | int index = KOPrefs::instance()->mAlarmTime; | 408 | int index = KOPrefs::instance()->mAlarmTime; |
407 | if (index < 0 || index > 7) { | 409 | if (index < 0 || index > 7) { |
408 | alarmTime = 15; | 410 | alarmTime = 15; |
409 | } else { | 411 | } else { |
410 | alarmTime = a[index]; | 412 | alarmTime = a[index]; |
411 | } | 413 | } |
412 | mAlarmTimeEdit->setValue(alarmTime); | 414 | mAlarmTimeEdit->setValue(alarmTime); |
413 | } | 415 | } |
414 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 416 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
415 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 417 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
416 | mCancelBox->setChecked( event->cancelled() ); | 418 | mCancelBox->setChecked( event->cancelled() ); |
417 | mAlarmProgramButton->setOn(false); | 419 | mAlarmProgramButton->setOn(false); |
418 | mAlarmSoundButton->setOn(false); | 420 | mAlarmSoundButton->setOn(false); |
419 | 421 | ||
420 | // set up alarm stuff | 422 | // set up alarm stuff |
421 | QPtrList<Alarm> alarms = event->alarms(); | 423 | QPtrList<Alarm> alarms = event->alarms(); |
422 | Alarm* alarm; | 424 | Alarm* alarm; |
423 | mAlarmIncrCombo->setCurrentItem(0); | 425 | mAlarmIncrCombo->setCurrentItem(0); |
424 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 426 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
425 | int offset; | 427 | int offset; |
426 | if ( alarm->hasTime() ) { | 428 | if ( alarm->hasTime() ) { |
427 | QDateTime t = alarm->time(); | 429 | QDateTime t = alarm->time(); |
428 | offset = event->dtStart().secsTo( t ); | 430 | offset = event->dtStart().secsTo( t ); |
429 | } else { | 431 | } else { |
430 | offset = alarm->startOffset().asSeconds(); | 432 | offset = alarm->startOffset().asSeconds(); |
431 | } | 433 | } |
432 | if ( offset != 0 ) { | 434 | if ( offset != 0 ) { |
433 | offset = offset / -60; // make minutes | 435 | offset = offset / -60; // make minutes |
434 | if (offset % 60 == 0) { // divides evenly into hours? | 436 | if (offset % 60 == 0) { // divides evenly into hours? |
435 | offset = offset / 60; | 437 | offset = offset / 60; |
436 | mAlarmIncrCombo->setCurrentItem(1); | 438 | mAlarmIncrCombo->setCurrentItem(1); |
437 | if (offset % 24 == 0) { // divides evenly into days? | 439 | if (offset % 24 == 0) { // divides evenly into days? |
438 | offset = offset / 24; | 440 | offset = offset / 24; |
439 | mAlarmIncrCombo->setCurrentItem(2); | 441 | mAlarmIncrCombo->setCurrentItem(2); |
440 | } | 442 | } |
441 | } | 443 | } |
442 | } | 444 | } |
443 | mAlarmTimeEdit->setValue( offset ); | 445 | mAlarmTimeEdit->setValue( offset ); |
444 | if (alarm->type() == Alarm::Procedure) { | 446 | if (alarm->type() == Alarm::Procedure) { |
445 | 447 | ||
446 | mAlarmProgram = alarm->programFile(); | 448 | mAlarmProgram = alarm->programFile(); |
447 | mAlarmProgramButton->setOn(true); | 449 | mAlarmProgramButton->setOn(true); |
448 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); | 450 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); |
449 | QToolTip::add(mAlarmProgramButton, dispStr); | 451 | QToolTip::add(mAlarmProgramButton, dispStr); |
450 | } | 452 | } |
451 | else if (alarm->type() == Alarm::Audio) { | 453 | else if (alarm->type() == Alarm::Audio) { |
452 | mAlarmSound = alarm->audioFile(); | 454 | mAlarmSound = alarm->audioFile(); |
453 | if ( ! QFile::exists( mAlarmSound ) ) | 455 | if ( ! QFile::exists( mAlarmSound ) ) |
454 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 456 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
455 | mAlarmSoundButton->setOn(true); | 457 | mAlarmSoundButton->setOn(true); |
456 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); | 458 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); |
457 | QToolTip::add(mAlarmSoundButton, dispStr); | 459 | QToolTip::add(mAlarmSoundButton, dispStr); |
458 | } | 460 | } |
459 | mAlarmButton->setChecked(alarm->enabled()); | 461 | mAlarmButton->setChecked(alarm->enabled()); |
460 | enableAlarmEdit( alarm->enabled() ); | 462 | enableAlarmEdit( alarm->enabled() ); |
461 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); | 463 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); |
462 | // TODO: Deal with multiple alarms | 464 | // TODO: Deal with multiple alarms |
463 | break; // For now, stop after the first alarm | 465 | break; // For now, stop after the first alarm |
464 | } | 466 | } |
465 | 467 | ||
466 | setCategories(event->categoriesStr()); | 468 | setCategories(event->categoriesStr()); |
467 | } | 469 | } |
468 | 470 | ||
469 | void KOEditorGeneral::writeIncidence(Incidence *event) | 471 | void KOEditorGeneral::writeIncidence(Incidence *event) |
470 | { | 472 | { |
471 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; | 473 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; |
472 | mLocationEdit->save(KOLocationBox::LOCATION); | 474 | mLocationEdit->save(KOLocationBox::LOCATION); |
473 | event->setSummary(mSummaryEdit->currentText()); | 475 | event->setSummary(mSummaryEdit->currentText()); |
474 | event->setLocation(mLocationEdit->currentText()); | 476 | event->setLocation(mLocationEdit->currentText()); |
475 | event->setDescription(mDescriptionEdit->text()); | 477 | event->setDescription(mDescriptionEdit->text()); |
476 | event->setCategories(mCategoriesLabel->text()); | 478 | event->setCategories(mCategoriesLabel->text()); |
477 | event->setSecrecy(mSecrecyCombo->currentItem()); | 479 | event->setSecrecy(mSecrecyCombo->currentItem()); |
478 | event->setCancelled(mCancelBox->isChecked() );; | 480 | event->setCancelled(mCancelBox->isChecked() );; |
479 | // alarm stuff | 481 | // alarm stuff |
480 | if (mAlarmButton->isChecked()) { | 482 | if (mAlarmButton->isChecked()) { |
481 | if (event->alarms().count() == 0) | 483 | if (event->alarms().count() == 0) |
482 | event->newAlarm(); | 484 | event->newAlarm(); |
483 | QPtrList<Alarm> alarms = event->alarms(); | 485 | QPtrList<Alarm> alarms = event->alarms(); |
484 | Alarm *alarm; | 486 | Alarm *alarm; |
485 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 487 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
486 | alarm->setEnabled(true); | 488 | alarm->setEnabled(true); |
487 | int j = mAlarmTimeEdit->value()* -60; | 489 | int j = mAlarmTimeEdit->value()* -60; |
488 | if (mAlarmIncrCombo->currentItem() == 1) | 490 | if (mAlarmIncrCombo->currentItem() == 1) |
489 | j = j * 60; | 491 | j = j * 60; |
490 | else if (mAlarmIncrCombo->currentItem() == 2) | 492 | else if (mAlarmIncrCombo->currentItem() == 2) |
491 | j = j * (60 * 24); | 493 | j = j * (60 * 24); |
492 | alarm->setStartOffset( j ); | 494 | alarm->setStartOffset( j ); |
493 | 495 | ||
494 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { | 496 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { |
495 | alarm->setProcedureAlarm(mAlarmProgram); | 497 | alarm->setProcedureAlarm(mAlarmProgram); |
496 | } | 498 | } |
497 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 499 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
498 | alarm->setAudioAlarm(mAlarmSound); | 500 | alarm->setAudioAlarm(mAlarmSound); |
499 | else | 501 | else |
500 | alarm->setType(Alarm::Invalid); | 502 | alarm->setType(Alarm::Invalid); |
501 | //alarm->setAudioAlarm("default"); | 503 | //alarm->setAudioAlarm("default"); |
502 | // TODO: Deal with multiple alarms | 504 | // TODO: Deal with multiple alarms |
503 | break; // For now, stop after the first alarm | 505 | break; // For now, stop after the first alarm |
504 | } | 506 | } |
505 | } else { | 507 | } else { |
506 | Alarm* alarm = event->alarms().first(); | 508 | Alarm* alarm = event->alarms().first(); |
507 | if ( alarm ) { | 509 | if ( alarm ) { |
508 | alarm->setEnabled(false); | 510 | alarm->setEnabled(false); |
509 | alarm->setType(Alarm::Invalid); | 511 | alarm->setType(Alarm::Invalid); |
510 | } | 512 | } |
511 | } | 513 | } |
512 | } | 514 | } |