author | zautrix <zautrix> | 2005-03-26 13:13:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-26 13:13:04 (UTC) |
commit | 93d1be2c6eead07300e7f90f3b417fcef0f109d3 (patch) (unidiff) | |
tree | cdcac27cfa1e02c6fa388c252287ed9818b95847 | |
parent | bc8929ccca1ad8cd04f61366c78254803d9c1565 (diff) | |
download | kdepimpi-93d1be2c6eead07300e7f90f3b417fcef0f109d3.zip kdepimpi-93d1be2c6eead07300e7f90f3b417fcef0f109d3.tar.gz kdepimpi-93d1be2c6eead07300e7f90f3b417fcef0f109d3.tar.bz2 |
icons added
-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,329 +1,331 @@ | |||
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 ) |
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index cf0d4ae..92fcd1c 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -197,316 +197,318 @@ void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | |||
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 | } |