-rw-r--r-- | korganizer/komonthview.cpp | 855 | ||||
-rw-r--r-- | korganizer/komonthview.h | 2 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 2 |
4 files changed, 447 insertions, 416 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 437debe..10e4f1d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1129 +1,1154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(!count()) break; | 118 | if(count() < 2) { |
119 | setCurrentItem((currentItem()+count()-1)%count()); | 119 | e->ignore(); |
120 | if(!itemVisible(currentItem())) { | 120 | break; |
121 | if((unsigned int) currentItem() == (count()-1)) { | ||
122 | setTopItem(currentItem()-numItemsVisible()+1); | ||
123 | } else { | ||
124 | setTopItem(topItem()-1); | ||
125 | } | 121 | } |
126 | } | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
127 | break; | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | ||
125 | setTopItem(currentItem()-numItemsVisible()+1); | ||
126 | } else { | ||
127 | setTopItem(topItem()-1); | ||
128 | } | ||
129 | } | ||
130 | break; | ||
128 | case Key_Down: | 131 | case Key_Down: |
129 | if(!count()) break; | 132 | if(count() < 2) { |
130 | setCurrentItem((currentItem()+1)%count()); | 133 | e->ignore(); |
131 | if(!itemVisible(currentItem())) { | 134 | break; |
132 | if(currentItem() == 0) { | ||
133 | setTopItem(0); | ||
134 | } else { | ||
135 | setTopItem(topItem()+1); | ||
136 | } | 135 | } |
137 | } | 136 | setCurrentItem((currentItem()+1)%count()); |
138 | break; | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | ||
139 | setTopItem(0); | ||
140 | } else { | ||
141 | setTopItem(topItem()+1); | ||
142 | } | ||
143 | } | ||
144 | break; | ||
139 | case Key_Shift: | 145 | case Key_Shift: |
140 | emit shiftDown(); | 146 | emit shiftDown(); |
141 | break; | 147 | break; |
142 | default: | 148 | default: |
143 | e->ignore(); | 149 | e->ignore(); |
144 | break; | 150 | break; |
145 | } | 151 | } |
146 | } | 152 | } |
147 | 153 | ||
148 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
149 | { | 155 | { |
150 | switch(e->key()) { | 156 | switch(e->key()) { |
151 | case Key_Shift: | 157 | case Key_Shift: |
152 | emit shiftUp(); | 158 | emit shiftUp(); |
153 | break; | 159 | break; |
154 | default: | 160 | default: |
155 | break; | 161 | break; |
156 | } | 162 | } |
157 | } | 163 | } |
158 | 164 | ||
159 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
160 | { | 166 | { |
161 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
162 | 168 | ||
163 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
164 | emit rightClick(); | 170 | emit rightClick(); |
165 | } | 171 | } |
166 | } | 172 | } |
167 | 173 | ||
168 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
169 | : QListBoxItem() | 175 | : QListBoxItem() |
170 | { | 176 | { |
171 | setText( s ); | 177 | setText( s ); |
172 | 178 | ||
173 | mIncidence = incidence; | 179 | mIncidence = incidence; |
174 | mDate = qd; | 180 | mDate = qd; |
175 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
176 | mRecur = false; | 182 | mRecur = false; |
177 | mAlarm = false; | 183 | mAlarm = false; |
178 | mReply = false; | 184 | mReply = false; |
179 | mInfo = false; | 185 | mInfo = false; |
180 | } | 186 | } |
181 | 187 | ||
182 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
183 | { | 189 | { |
184 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
185 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
186 | #else | 192 | #else |
187 | bool sel = selected(); | 193 | bool sel = selected(); |
188 | #endif | 194 | #endif |
189 | 195 | ||
190 | 196 | ||
191 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
192 | { | 198 | { |
193 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
194 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
195 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
196 | } | 202 | } |
197 | int x = 1; | 203 | int x = 1; |
198 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
199 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
200 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
201 | size = 3; | 207 | size = 3; |
202 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
203 | if ( mInfo ) { | 209 | if ( mInfo ) { |
204 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
205 | x += size + 1; | 211 | x += size + 1; |
206 | } | 212 | } |
207 | if ( mRecur ) { | 213 | if ( mRecur ) { |
208 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
209 | x += size + 1; | 215 | x += size + 1; |
210 | } | 216 | } |
211 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
212 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
213 | x += size + 1; | 219 | x += size + 1; |
214 | } | 220 | } |
215 | if ( mReply ) { | 221 | if ( mReply ) { |
216 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
217 | x += size + 1; | 223 | x += size + 1; |
218 | } | 224 | } |
219 | } | 225 | } |
220 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
221 | int yPos; | 227 | int yPos; |
222 | int pmheight = size; | 228 | int pmheight = size; |
223 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
224 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
225 | else | 231 | else |
226 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
227 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
228 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
229 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
230 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
231 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
232 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
233 | } | 239 | } |
234 | 240 | ||
235 | } | 241 | } |
236 | 242 | ||
237 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
238 | { | 244 | { |
239 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
240 | } | 246 | } |
241 | 247 | ||
242 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
243 | { | 249 | { |
244 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
245 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
246 | size = 3; | 252 | size = 3; |
247 | int x = 1; | 253 | int x = 1; |
248 | if ( mInfo ) { | 254 | if ( mInfo ) { |
249 | x += size + 1; | 255 | x += size + 1; |
250 | } | 256 | } |
251 | if( mRecur ) { | 257 | if( mRecur ) { |
252 | x += size+1; | 258 | x += size+1; |
253 | } | 259 | } |
254 | if( mAlarm ) { | 260 | if( mAlarm ) { |
255 | x += size+1; | 261 | x += size+1; |
256 | } | 262 | } |
257 | if( mReply ) { | 263 | if( mReply ) { |
258 | x += size+1; | 264 | x += size+1; |
259 | } | 265 | } |
260 | 266 | ||
261 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
262 | } | 268 | } |
263 | 269 | ||
264 | 270 | ||
265 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
266 | : QWidget( parent ), | 272 | : QWidget( parent ), |
267 | mMonthView( parent ) | 273 | mMonthView( parent ) |
268 | { | 274 | { |
269 | 275 | ||
270 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
271 | 277 | ||
272 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
273 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
274 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
275 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
276 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
277 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
278 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
279 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
280 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
282 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
283 | mLabel->raise(); | 289 | mLabel->raise(); |
284 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
285 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
286 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
287 | 293 | ||
288 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
289 | updateConfig(); | 295 | updateConfig(); |
290 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
291 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
292 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
293 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
294 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
295 | const QPoint &) ), | 301 | const QPoint &) ), |
296 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
297 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
298 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
299 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
300 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
301 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
302 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
303 | } | 309 | } |
304 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
305 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
306 | { | 312 | { |
307 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
308 | return mToolTipGroup; | 314 | return mToolTipGroup; |
309 | } | 315 | } |
310 | #endif | 316 | #endif |
311 | 317 | ||
312 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
313 | { | 319 | { |
314 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
315 | mDate = date; | 321 | mDate = date; |
316 | 322 | ||
317 | 323 | ||
318 | 324 | ||
319 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
320 | } | 326 | } |
321 | 327 | ||
322 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
323 | { | 329 | { |
324 | return mDate; | 330 | return mDate; |
325 | } | 331 | } |
326 | 332 | ||
327 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
328 | { | 334 | { |
329 | mPrimary = primary; | 335 | mPrimary = primary; |
330 | //setMyPalette(); | 336 | //setMyPalette(); |
331 | } | 337 | } |
332 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
333 | { | 339 | { |
334 | 340 | ||
335 | if ( mHoliday) { | 341 | if ( mHoliday) { |
336 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
337 | } else { | 343 | } else { |
338 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
339 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
340 | } else { | 346 | } else { |
341 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
342 | } | 348 | } |
343 | } | 349 | } |
344 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
345 | 351 | ||
346 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
347 | } | 353 | } |
348 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
349 | { | 355 | { |
350 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
351 | return mStandardPalette; | 357 | return mStandardPalette; |
352 | if ( mHoliday) { | 358 | if ( mHoliday) { |
353 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
354 | } else { | 360 | } else { |
355 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
356 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
357 | } | 363 | } |
358 | } | 364 | } |
359 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
360 | } | 366 | } |
361 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
362 | { | 368 | { |
363 | return mPrimary; | 369 | return mPrimary; |
364 | } | 370 | } |
365 | 371 | ||
366 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
367 | { | 373 | { |
368 | mHoliday = holiday; | 374 | mHoliday = holiday; |
369 | //setMyPalette(); | 375 | //setMyPalette(); |
370 | } | 376 | } |
371 | 377 | ||
372 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
373 | { | 379 | { |
374 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
375 | 381 | ||
376 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
377 | setHoliday( true ); | 383 | setHoliday( true ); |
378 | } | 384 | } |
379 | } | 385 | } |
380 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
381 | { | 387 | { |
382 | 388 | ||
383 | e->ignore(); | 389 | e->ignore(); |
384 | 390 | ||
385 | } | 391 | } |
386 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
387 | { | 393 | { |
388 | mItemList->clear(); | 394 | mItemList->clear(); |
389 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
390 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
391 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
392 | } | 398 | } |
393 | void MonthViewCell::updateCell() | 399 | void MonthViewCell::updateCell() |
394 | { | 400 | { |
395 | if ( !mMonthView->isUpdatePossible() ) | 401 | if ( !mMonthView->isUpdatePossible() ) |
396 | return; | 402 | return; |
397 | /* | 403 | /* |
398 | if ( !isVisible() ){ | 404 | if ( !isVisible() ){ |
399 | return; | 405 | return; |
400 | } | 406 | } |
401 | */ | 407 | */ |
402 | // qDebug("MonthViewCell::updateCell() "); | 408 | // qDebug("MonthViewCell::updateCell() "); |
403 | setPrimary( mDate.month()%2 ); | 409 | setPrimary( mDate.month()%2 ); |
404 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 410 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
405 | if ( mDate == QDate::currentDate() ) { | 411 | if ( mDate == QDate::currentDate() ) { |
406 | mItemList->setLineWidth( 3 ); | 412 | mItemList->setLineWidth( 3 ); |
407 | } else { | 413 | } else { |
408 | mItemList->setLineWidth( 1 ); | 414 | mItemList->setLineWidth( 1 ); |
409 | } | 415 | } |
410 | mItemList->clear(); | 416 | mItemList->clear(); |
411 | 417 | ||
412 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
413 | QToolTip::remove(this); | 419 | QToolTip::remove(this); |
414 | #endif | 420 | #endif |
415 | QString tipText(""); | 421 | QString tipText(""); |
416 | //qApp->processEvents(); | 422 | //qApp->processEvents(); |
417 | if ( !mHolidayString.isEmpty() ) { | 423 | if ( !mHolidayString.isEmpty() ) { |
418 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
419 | item->setPalette( mHolidayPalette ); | 425 | item->setPalette( mHolidayPalette ); |
420 | mItemList->insertItem( item ); | 426 | mItemList->insertItem( item ); |
421 | tipText += mHolidayString+"\n"; | 427 | tipText += mHolidayString+"\n"; |
422 | } | 428 | } |
423 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
424 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
425 | Event *event; | 431 | Event *event; |
426 | for( event = events.first(); event; event = events.next() ) { // for event | 432 | for( event = events.first(); event; event = events.next() ) { // for event |
427 | 433 | ||
428 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
429 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
430 | continue; | 436 | continue; |
431 | else | 437 | else |
432 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
433 | continue; | 439 | continue; |
434 | } | 440 | } |
435 | 441 | ||
436 | if ( event->categories().contains("Holiday") || | 442 | if ( event->categories().contains("Holiday") || |
437 | event->categories().contains(i18n("Holiday"))) { | 443 | event->categories().contains(i18n("Holiday"))) { |
438 | setHoliday( true ); | 444 | setHoliday( true ); |
439 | if ( mDate.dayOfWeek() == 7 ) | 445 | if ( mDate.dayOfWeek() == 7 ) |
440 | mItemList->setLineWidth( 3 ); | 446 | mItemList->setLineWidth( 3 ); |
441 | } | 447 | } |
442 | QString text; | 448 | QString text; |
443 | if (event->isMultiDay()) { | 449 | if (event->isMultiDay()) { |
444 | QString prefix = "<->"; | 450 | QString prefix = "<->"; |
445 | if ( event->doesRecur() ) { | 451 | if ( event->doesRecur() ) { |
446 | if ( event->recursOn( mDate) ) | 452 | if ( event->recursOn( mDate) ) |
447 | prefix ="->" ; | 453 | prefix ="->" ; |
448 | else { | 454 | else { |
449 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
450 | if ( event->recursOn( mDate.addDays( -days)) ) | 456 | if ( event->recursOn( mDate.addDays( -days)) ) |
451 | prefix ="<-" ; | 457 | prefix ="<-" ; |
452 | } | 458 | } |
453 | 459 | ||
454 | } else { | 460 | } else { |
455 | if (mDate == event->dtStart().date()) { | 461 | if (mDate == event->dtStart().date()) { |
456 | prefix ="->" ; | 462 | prefix ="->" ; |
457 | } else if (mDate == event->dtEnd().date()) { | 463 | } else if (mDate == event->dtEnd().date()) { |
458 | prefix ="<-" ; | 464 | prefix ="<-" ; |
459 | } | 465 | } |
460 | } | 466 | } |
461 | text = prefix + event->summary(); | 467 | text = prefix + event->summary(); |
462 | tipText += text; | 468 | tipText += text; |
463 | } else { | 469 | } else { |
464 | if (event->doesFloat()) { | 470 | if (event->doesFloat()) { |
465 | text = event->summary(); | 471 | text = event->summary(); |
466 | tipText += text; | 472 | tipText += text; |
467 | } | 473 | } |
468 | else { | 474 | else { |
469 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
470 | text += " " + event->summary(); | 476 | text += " " + event->summary(); |
471 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
472 | } | 478 | } |
473 | } | 479 | } |
474 | 480 | ||
475 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
476 | QPalette pal; | 482 | QPalette pal; |
477 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
478 | QStringList categories = event->categories(); | 484 | QStringList categories = event->categories(); |
479 | QString cat = categories.first(); | 485 | QString cat = categories.first(); |
480 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
481 | pal = getPalette(); | 487 | pal = getPalette(); |
482 | if (cat.isEmpty()) { | 488 | if (cat.isEmpty()) { |
483 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
484 | } else { | 490 | } else { |
485 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
486 | } | 492 | } |
487 | 493 | ||
488 | } else { | 494 | } else { |
489 | if (cat.isEmpty()) { | 495 | if (cat.isEmpty()) { |
490 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
491 | } else { | 497 | } else { |
492 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
493 | } | 499 | } |
494 | } | 500 | } |
495 | 501 | ||
496 | } else { | 502 | } else { |
497 | pal = mStandardPalette ; | 503 | pal = mStandardPalette ; |
498 | } | 504 | } |
499 | item->setPalette( pal ); | 505 | item->setPalette( pal ); |
500 | item->setRecur( event->recurrence()->doesRecur() ); | 506 | item->setRecur( event->recurrence()->doesRecur() ); |
501 | item->setAlarm( event->isAlarmEnabled() ); | 507 | item->setAlarm( event->isAlarmEnabled() ); |
502 | item->setMoreInfo( event->description().length() > 0 ); | 508 | item->setMoreInfo( event->description().length() > 0 ); |
503 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
504 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
505 | KOPrefs::instance()->email()); | 511 | KOPrefs::instance()->email()); |
506 | if ( me != 0 ) { | 512 | if ( me != 0 ) { |
507 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
508 | item->setReply(true); | 514 | item->setReply(true); |
509 | else | 515 | else |
510 | item->setReply(false); | 516 | item->setReply(false); |
511 | } else | 517 | } else |
512 | item->setReply(false); | 518 | item->setReply(false); |
513 | #endif | 519 | #endif |
514 | mItemList->insertItem( item ); | 520 | mItemList->insertItem( item ); |
515 | tipText += "\n"; | 521 | tipText += "\n"; |
516 | 522 | ||
517 | } | 523 | } |
518 | 524 | ||
519 | // insert due todos | 525 | // insert due todos |
520 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
521 | Todo *todo; | 527 | Todo *todo; |
522 | for(todo = todos.first(); todo; todo = todos.next()) { | 528 | for(todo = todos.first(); todo; todo = todos.next()) { |
523 | QString text; | 529 | QString text; |
524 | if (todo->hasDueDate()) { | 530 | if (todo->hasDueDate()) { |
525 | if (!todo->doesFloat()) { | 531 | if (!todo->doesFloat()) { |
526 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
527 | text += " "; | 533 | text += " "; |
528 | } | 534 | } |
529 | } | 535 | } |
530 | text += i18n("To-Do: %1").arg(todo->summary()); | 536 | text += i18n("To-Do: %1").arg(todo->summary()); |
531 | 537 | ||
532 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
533 | //item->setPalette( mStandardPalette ); | 539 | //item->setPalette( mStandardPalette ); |
534 | QPalette pal; | 540 | QPalette pal; |
535 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
536 | QStringList categories = todo->categories(); | 542 | QStringList categories = todo->categories(); |
537 | QString cat = categories.first(); | 543 | QString cat = categories.first(); |
538 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
539 | pal = getPalette(); | 545 | pal = getPalette(); |
540 | if (cat.isEmpty()) { | 546 | if (cat.isEmpty()) { |
541 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
542 | } else { | 548 | } else { |
543 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
544 | } | 550 | } |
545 | 551 | ||
546 | } else { | 552 | } else { |
547 | if (cat.isEmpty()) { | 553 | if (cat.isEmpty()) { |
548 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
549 | } else { | 555 | } else { |
550 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
551 | } | 557 | } |
552 | } | 558 | } |
553 | 559 | ||
554 | } else { | 560 | } else { |
555 | pal = mStandardPalette ; | 561 | pal = mStandardPalette ; |
556 | } | 562 | } |
557 | item->setPalette( pal ); | 563 | item->setPalette( pal ); |
558 | mItemList->insertItem( item ); | 564 | mItemList->insertItem( item ); |
559 | tipText += text+"\n"; | 565 | tipText += text+"\n"; |
560 | } | 566 | } |
561 | #ifdef DESKTOP_VERSION | 567 | #ifdef DESKTOP_VERSION |
562 | if (tipText != "") | 568 | if (tipText != "") |
563 | QToolTip::add(this,tipText,toolTipGroup(),""); | 569 | QToolTip::add(this,tipText,toolTipGroup(),""); |
564 | #endif | 570 | #endif |
565 | 571 | ||
566 | //setMyPalette(); | 572 | //setMyPalette(); |
567 | setMyPalette(); | 573 | setMyPalette(); |
568 | QString text; | 574 | QString text; |
569 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
570 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 576 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
571 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
572 | mLabel->resize( mLabelBigSize ); | 578 | mLabel->resize( mLabelBigSize ); |
573 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
574 | } else { | 580 | } else { |
575 | mLabel->resize( mLabelSize ); | 581 | mLabel->resize( mLabelSize ); |
576 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
577 | } | 583 | } |
578 | 584 | ||
579 | mLabel->setText( text ); | 585 | mLabel->setText( text ); |
580 | resizeEvent( 0 ); | 586 | resizeEvent( 0 ); |
581 | // if ( isVisible()) | 587 | // if ( isVisible()) |
582 | //qApp->processEvents(); | 588 | //qApp->processEvents(); |
583 | } | 589 | } |
584 | 590 | ||
585 | void MonthViewCell::updateConfig() | 591 | void MonthViewCell::updateConfig() |
586 | { | 592 | { |
587 | 593 | ||
588 | setFont( KOPrefs::instance()->mMonthViewFont ); | 594 | setFont( KOPrefs::instance()->mMonthViewFont ); |
589 | 595 | ||
590 | QFontMetrics fm( font() ); | 596 | QFontMetrics fm( font() ); |
591 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
592 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
593 | mHolidayPalette = mStandardPalette; | 599 | mHolidayPalette = mStandardPalette; |
594 | mPrimaryPalette = mStandardPalette; | 600 | mPrimaryPalette = mStandardPalette; |
595 | mNonPrimaryPalette = mStandardPalette; | 601 | mNonPrimaryPalette = mStandardPalette; |
596 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
597 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
598 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
599 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
600 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
601 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
602 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
603 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
604 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
605 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
606 | } | 612 | } |
607 | updateCell(); | 613 | updateCell(); |
608 | } | 614 | } |
609 | 615 | ||
610 | void MonthViewCell::enableScrollBars( bool enabled ) | 616 | void MonthViewCell::enableScrollBars( bool enabled ) |
611 | { | 617 | { |
612 | if ( enabled ) { | 618 | if ( enabled ) { |
613 | mItemList->setVScrollBarMode(QScrollView::Auto); | 619 | mItemList->setVScrollBarMode(QScrollView::Auto); |
614 | mItemList->setHScrollBarMode(QScrollView::Auto); | 620 | mItemList->setHScrollBarMode(QScrollView::Auto); |
615 | } else { | 621 | } else { |
616 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
617 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
618 | } | 624 | } |
619 | } | 625 | } |
620 | 626 | ||
621 | Incidence *MonthViewCell::selectedIncidence() | 627 | Incidence *MonthViewCell::selectedIncidence() |
622 | { | 628 | { |
623 | int index = mItemList->currentItem(); | 629 | int index = mItemList->currentItem(); |
624 | if ( index < 0 ) return 0; | 630 | if ( index < 0 ) return 0; |
625 | 631 | ||
626 | MonthViewItem *item = | 632 | MonthViewItem *item = |
627 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
628 | 634 | ||
629 | if ( !item ) return 0; | 635 | if ( !item ) return 0; |
630 | 636 | ||
631 | return item->incidence(); | 637 | return item->incidence(); |
632 | } | 638 | } |
633 | 639 | ||
634 | QDate MonthViewCell::selectedIncidenceDate() | 640 | QDate MonthViewCell::selectedIncidenceDate() |
635 | { | 641 | { |
636 | QDate qd; | 642 | QDate qd; |
637 | int index = mItemList->currentItem(); | 643 | int index = mItemList->currentItem(); |
638 | if ( index < 0 ) return qd; | 644 | if ( index < 0 ) return qd; |
639 | 645 | ||
640 | MonthViewItem *item = | 646 | MonthViewItem *item = |
641 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
642 | 648 | ||
643 | if ( !item ) return qd; | 649 | if ( !item ) return qd; |
644 | 650 | ||
645 | return item->incidenceDate(); | 651 | return item->incidenceDate(); |
646 | } | 652 | } |
647 | 653 | ||
648 | void MonthViewCell::deselect() | 654 | void MonthViewCell::deselect() |
649 | { | 655 | { |
650 | mItemList->clearSelection(); | 656 | mItemList->clearSelection(); |
651 | enableScrollBars( false ); | 657 | enableScrollBars( false ); |
652 | // updateCell(); | 658 | // updateCell(); |
653 | } | 659 | } |
654 | void MonthViewCell::select() | 660 | void MonthViewCell::select() |
655 | { | 661 | { |
656 | ;// updateCell(); | 662 | ;// updateCell(); |
657 | } | 663 | } |
658 | 664 | ||
659 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
660 | { | 666 | { |
661 | if ( !mMonthView->isUpdatePossible() ) | 667 | if ( !mMonthView->isUpdatePossible() ) |
662 | return; | 668 | return; |
663 | #ifndef DESKTOP_VERSION | 669 | #ifndef DESKTOP_VERSION |
664 | if ( !isVisible() ){ | 670 | if ( !isVisible() ){ |
665 | return; | 671 | return; |
666 | } | 672 | } |
667 | #endif | 673 | #endif |
668 | int size = height() - mLabel->height(); | 674 | int size = height() - mLabel->height(); |
669 | if ( size > 0 ) | 675 | if ( size > 0 ) |
670 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
671 | size = width() - mLabel->width(); | 677 | size = width() - mLabel->width(); |
672 | if ( size > 0 ) | 678 | if ( size > 0 ) |
673 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
674 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
675 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
676 | } | 682 | } |
677 | 683 | ||
678 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 684 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
679 | { | 685 | { |
680 | if ( !item ) return; | 686 | if ( !item ) return; |
681 | 687 | ||
682 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
683 | Incidence *incidence = eventItem->incidence(); | 689 | Incidence *incidence = eventItem->incidence(); |
684 | if ( incidence ) mMonthView->defaultAction( incidence ); | 690 | if ( incidence ) mMonthView->defaultAction( incidence ); |
685 | } | 691 | } |
686 | void MonthViewCell::showDay() | 692 | void MonthViewCell::showDay() |
687 | { | 693 | { |
688 | emit showDaySignal( date() ); | 694 | emit showDaySignal( date() ); |
689 | } | 695 | } |
690 | void MonthViewCell::newEvent() | 696 | void MonthViewCell::newEvent() |
691 | { | 697 | { |
692 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 698 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
693 | emit newEventSignal( dt ); | 699 | emit newEventSignal( dt ); |
694 | } | 700 | } |
695 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 701 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
696 | { | 702 | { |
697 | static QListBoxItem * lastClicked = 0; | 703 | static QListBoxItem * lastClicked = 0; |
698 | if ( item == 0 ) { | 704 | if ( item == 0 ) { |
699 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 705 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
700 | emit newEventSignal( dt ); | 706 | emit newEventSignal( dt ); |
701 | return; | 707 | return; |
702 | } | 708 | } |
703 | /* | 709 | /* |
704 | if ( lastClicked ) | 710 | if ( lastClicked ) |
705 | if ( ! item ) { | 711 | if ( ! item ) { |
706 | if ( lastClicked->listBox() != item->listBox() ) | 712 | if ( lastClicked->listBox() != item->listBox() ) |
707 | lastClicked->listBox()->clearSelection(); | 713 | lastClicked->listBox()->clearSelection(); |
708 | } | 714 | } |
709 | */ | 715 | */ |
710 | 716 | ||
711 | mMonthView->setSelectedCell( this ); | 717 | mMonthView->setSelectedCell( this ); |
712 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 718 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); |
713 | select(); | 719 | select(); |
714 | } | 720 | } |
715 | 721 | ||
716 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 722 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
717 | { | 723 | { |
718 | if ( !item ) return; | 724 | if ( !item ) return; |
719 | 725 | ||
720 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 726 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
721 | Incidence *incidence = eventItem->incidence(); | 727 | Incidence *incidence = eventItem->incidence(); |
722 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 728 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
723 | } | 729 | } |
724 | 730 | ||
725 | void MonthViewCell::selection( QListBoxItem *item ) | 731 | void MonthViewCell::selection( QListBoxItem *item ) |
726 | { | 732 | { |
727 | if ( !item ) return; | 733 | if ( !item ) return; |
728 | 734 | ||
729 | mMonthView->setSelectedCell( this ); | 735 | mMonthView->setSelectedCell( this ); |
730 | } | 736 | } |
731 | 737 | ||
732 | 738 | ||
733 | // ******************************************************************************* | 739 | // ******************************************************************************* |
734 | // ******************************************************************************* | 740 | // ******************************************************************************* |
735 | // ******************************************************************************* | 741 | // ******************************************************************************* |
736 | 742 | ||
737 | 743 | ||
738 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 744 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
739 | : KOEventView( calendar, parent, name ), | 745 | : KOEventView( calendar, parent, name ), |
740 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 746 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
741 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 747 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
742 | { | 748 | { |
743 | 749 | ||
744 | updatePossible = false; | 750 | updatePossible = false; |
745 | mCells.setAutoDelete( true ); | 751 | mCells.setAutoDelete( true ); |
746 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 752 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
747 | // mDayLayout = new QGridLayout( this ); | 753 | // mDayLayout = new QGridLayout( this ); |
748 | // create the day of the week labels (Sun, Mon, etc) and add them to | 754 | // create the day of the week labels (Sun, Mon, etc) and add them to |
749 | // the layout. | 755 | // the layout. |
750 | mDayLabels.resize( mDaysPerWeek ); | 756 | mDayLabels.resize( mDaysPerWeek ); |
751 | QFont bfont = font(); | 757 | QFont bfont = font(); |
752 | if ( QApplication::desktop()->width() < 650 ) { | 758 | if ( QApplication::desktop()->width() < 650 ) { |
753 | bfont.setPointSize( bfont.pointSize() - 2 ); | 759 | bfont.setPointSize( bfont.pointSize() - 2 ); |
754 | } | 760 | } |
755 | bfont.setBold( true ); | 761 | bfont.setBold( true ); |
756 | int i; | 762 | int i; |
757 | 763 | ||
758 | for( i = 0; i < mDaysPerWeek; i++ ) { | 764 | for( i = 0; i < mDaysPerWeek; i++ ) { |
759 | QLabel *label = new QLabel( this ); | 765 | QLabel *label = new QLabel( this ); |
760 | label->setFont(bfont); | 766 | label->setFont(bfont); |
761 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 767 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
762 | label->setLineWidth(1); | 768 | label->setLineWidth(1); |
763 | label->setAlignment(AlignCenter); | 769 | label->setAlignment(AlignCenter); |
764 | mDayLabels.insert( i, label ); | 770 | mDayLabels.insert( i, label ); |
765 | } | ||
766 | |||
767 | bfont.setBold( false ); | ||
768 | mWeekLabels.resize( mNumWeeks+1 ); | ||
769 | for( i = 0; i < mNumWeeks+1; i++ ) { | ||
770 | KOWeekButton *label = new KOWeekButton( this ); | ||
771 | label->setFont(bfont); | ||
772 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | ||
773 | label->setFlat(true); | ||
774 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | ||
775 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | ||
776 | //label->setLineWidth(1); | ||
777 | //label->setAlignment(AlignCenter); | ||
778 | mWeekLabels.insert( i, label ); | ||
779 | } | ||
780 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
781 | int row, col; | ||
782 | mCells.resize( mNumCells ); | ||
783 | for( row = 0; row < mNumWeeks; ++row ) { | ||
784 | for( col = 0; col < mDaysPerWeek; ++col ) { | ||
785 | MonthViewCell *cell = new MonthViewCell( this ); | ||
786 | mCells.insert( row * mDaysPerWeek + col, cell ); | ||
787 | |||
788 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | ||
789 | SLOT( defaultAction( Incidence * ) ) ); | ||
790 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | ||
791 | SIGNAL( newEventSignal( QDateTime ) ) ); | ||
792 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | ||
793 | SIGNAL( showDaySignal( QDate ) ) ); | ||
794 | } | 771 | } |
795 | } | ||
796 | 772 | ||
797 | mContextMenu = eventPopup(); | 773 | bfont.setBold( false ); |
798 | // updateConfig(); //useless here | 774 | mWeekLabels.resize( mNumWeeks+1 ); |
775 | for( i = 0; i < mNumWeeks+1; i++ ) { | ||
776 | KOWeekButton *label = new KOWeekButton( this ); | ||
777 | label->setFont(bfont); | ||
778 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | ||
779 | label->setFlat(true); | ||
780 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | ||
781 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | ||
782 | //label->setLineWidth(1); | ||
783 | //label->setAlignment(AlignCenter); | ||
784 | mWeekLabels.insert( i, label ); | ||
785 | } | ||
786 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
787 | int row, col; | ||
788 | mCells.resize( mNumCells ); | ||
789 | for( row = 0; row < mNumWeeks; ++row ) { | ||
790 | for( col = 0; col < mDaysPerWeek; ++col ) { | ||
791 | MonthViewCell *cell = new MonthViewCell( this ); | ||
792 | mCells.insert( row * mDaysPerWeek + col, cell ); | ||
793 | |||
794 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | ||
795 | SLOT( defaultAction( Incidence * ) ) ); | ||
796 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | ||
797 | SIGNAL( newEventSignal( QDateTime ) ) ); | ||
798 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | ||
799 | SIGNAL( showDaySignal( QDate ) ) ); | ||
800 | } | ||
801 | } | ||
799 | 802 | ||
800 | emit incidenceSelected( 0 ); | 803 | mContextMenu = eventPopup(); |
804 | // updateConfig(); //useless here | ||
805 | |||
806 | emit incidenceSelected( 0 ); | ||
801 | } | 807 | } |
802 | 808 | ||
803 | KOMonthView::~KOMonthView() | 809 | KOMonthView::~KOMonthView() |
804 | { | 810 | { |
805 | delete mContextMenu; | 811 | delete mContextMenu; |
806 | } | 812 | } |
807 | 813 | ||
808 | int KOMonthView::maxDatesHint() | 814 | int KOMonthView::maxDatesHint() |
809 | { | 815 | { |
810 | return mNumCells; | 816 | return mNumCells; |
811 | } | 817 | } |
812 | 818 | ||
813 | int KOMonthView::currentDateCount() | 819 | int KOMonthView::currentDateCount() |
814 | { | 820 | { |
815 | return mNumCells; | 821 | return mNumCells; |
816 | } | 822 | } |
817 | 823 | ||
818 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 824 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
819 | { | 825 | { |
820 | QPtrList<Incidence> selected; | 826 | QPtrList<Incidence> selected; |
821 | 827 | ||
822 | if ( mSelectedCell ) { | 828 | if ( mSelectedCell ) { |
823 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 829 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
824 | if ( incidence ) selected.append( incidence ); | 830 | if ( incidence ) selected.append( incidence ); |
825 | } | 831 | } |
826 | 832 | ||
827 | return selected; | 833 | return selected; |
828 | } | 834 | } |
829 | 835 | ||
830 | DateList KOMonthView::selectedDates() | 836 | DateList KOMonthView::selectedDates() |
831 | { | 837 | { |
832 | DateList selected; | 838 | DateList selected; |
833 | 839 | ||
834 | if ( mSelectedCell ) { | 840 | if ( mSelectedCell ) { |
835 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 841 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
836 | if ( qd.isValid() ) selected.append( qd ); | 842 | if ( qd.isValid() ) selected.append( qd ); |
837 | } | 843 | } |
838 | 844 | ||
839 | return selected; | 845 | return selected; |
840 | } | 846 | } |
841 | 847 | ||
842 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 848 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
843 | const QDate &td) | 849 | const QDate &td) |
844 | { | 850 | { |
845 | #ifndef KORG_NOPRINTER | 851 | #ifndef KORG_NOPRINTER |
846 | calPrinter->preview(CalPrinter::Month, fd, td); | 852 | calPrinter->preview(CalPrinter::Month, fd, td); |
847 | #endif | 853 | #endif |
848 | } | 854 | } |
849 | 855 | ||
850 | void KOMonthView::updateConfig() | 856 | void KOMonthView::updateConfig() |
851 | { | 857 | { |
852 | 858 | ||
853 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 859 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
854 | 860 | ||
855 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 861 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
856 | mWidthLongDayLabel = 0; | 862 | mWidthLongDayLabel = 0; |
857 | 863 | ||
858 | for (int i = 0; i < 7; i++) { | 864 | for (int i = 0; i < 7; i++) { |
859 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
860 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
861 | } | 867 | } |
862 | bool temp = mShowSatSunComp ; | 868 | bool temp = mShowSatSunComp ; |
863 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
864 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
865 | computeLayout(); | 871 | computeLayout(); |
866 | updateDayLabels(); | 872 | updateDayLabels(); |
867 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
868 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
869 | //resizeEvent( 0 ); | 875 | //resizeEvent( 0 ); |
870 | for (uint i = 0; i < mCells.count(); ++i) { | 876 | for (uint i = 0; i < mCells.count(); ++i) { |
871 | mCells[i]->updateConfig(); | 877 | mCells[i]->updateConfig(); |
872 | } | 878 | } |
873 | #ifdef DESKTOP_VERSION | 879 | #ifdef DESKTOP_VERSION |
874 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
875 | #endif | 881 | #endif |
876 | } | 882 | } |
877 | 883 | ||
878 | void KOMonthView::updateDayLabels() | 884 | void KOMonthView::updateDayLabels() |
879 | { | 885 | { |
880 | 886 | ||
881 | for (int i = 0; i < 7; i++) { | 887 | for (int i = 0; i < 7; i++) { |
882 | if (mWeekStartsMonday) { | 888 | if (mWeekStartsMonday) { |
883 | bool show = mShortDayLabels; | 889 | bool show = mShortDayLabels; |
884 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
885 | show = true; | 891 | show = true; |
886 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
887 | } else { | 893 | } else { |
888 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
889 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
890 | 896 | ||
897 | } | ||
891 | } | 898 | } |
892 | } | ||
893 | } | 899 | } |
894 | 900 | ||
895 | void KOMonthView::showDates(const QDate &start, const QDate &) | 901 | void KOMonthView::showDates(const QDate &start, const QDate &) |
896 | { | 902 | { |
897 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
898 | 904 | ||
899 | 905 | ||
900 | mStartDate = start; | 906 | mStartDate = start; |
901 | 907 | ||
902 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
903 | 909 | ||
904 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
905 | mStartDate = mStartDate.addDays( -1 ); | 911 | mStartDate = mStartDate.addDays( -1 ); |
906 | } | 912 | } |
907 | 913 | ||
908 | bool primary = false; | 914 | bool primary = false; |
909 | uint i; | 915 | uint i; |
910 | for( i = 0; i < mCells.size(); ++i ) { | 916 | for( i = 0; i < mCells.size(); ++i ) { |
911 | QDate date = mStartDate.addDays( i ); | 917 | QDate date = mStartDate.addDays( i ); |
912 | mCells[i]->setDate( date ); | 918 | mCells[i]->setDate( date ); |
913 | 919 | ||
914 | #ifndef KORG_NOPLUGINS | 920 | #ifndef KORG_NOPLUGINS |
915 | // add holiday, if present | 921 | // add holiday, if present |
916 | QString hstring(KOCore::self()->holiday(date)); | 922 | QString hstring(KOCore::self()->holiday(date)); |
917 | mCells[i]->setHoliday( hstring ); | 923 | mCells[i]->setHoliday( hstring ); |
918 | #endif | 924 | #endif |
919 | 925 | ||
920 | } | 926 | } |
921 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
922 | for( i = 0; i < 6; ++i ) { | 928 | for( i = 0; i < 6; ++i ) { |
923 | int wno; | 929 | int wno; |
924 | // remember, according to ISO 8601, the first week of the year is the | 930 | // remember, according to ISO 8601, the first week of the year is the |
925 | // first week that contains a thursday. Thus we must subtract off 4, | 931 | // first week that contains a thursday. Thus we must subtract off 4, |
926 | // not just 1. | 932 | // not just 1. |
927 | int dayOfYear = date.dayOfYear(); | 933 | int dayOfYear = date.dayOfYear(); |
928 | if (dayOfYear % 7 != 0) | 934 | if (dayOfYear % 7 != 0) |
929 | wno = dayOfYear / 7 + 1; | 935 | wno = dayOfYear / 7 + 1; |
930 | else | 936 | else |
931 | wno =dayOfYear / 7; | 937 | wno =dayOfYear / 7; |
932 | mWeekLabels[i]->setWeekNum( wno ); | 938 | mWeekLabels[i]->setWeekNum( wno ); |
933 | date = date.addDays( 7 ); | 939 | date = date.addDays( 7 ); |
934 | } | 940 | } |
935 | updateView(); | 941 | updateView(); |
936 | } | 942 | } |
937 | 943 | ||
938 | void KOMonthView::showEvents(QPtrList<Event>) | 944 | void KOMonthView::showEvents(QPtrList<Event>) |
939 | { | 945 | { |
940 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
941 | } | 947 | } |
942 | 948 | ||
943 | void KOMonthView::changeEventDisplay(Event *, int) | 949 | void KOMonthView::changeEventDisplay(Event *, int) |
944 | { | 950 | { |
945 | // this should be re-written to be much more efficient, but this | 951 | // this should be re-written to be much more efficient, but this |
946 | // quick-and-dirty-hack gets the job done for right now. | 952 | // quick-and-dirty-hack gets the job done for right now. |
947 | updateView(); | 953 | updateView(); |
948 | } | 954 | } |
949 | 955 | ||
950 | void KOMonthView::updateView() | 956 | void KOMonthView::updateView() |
951 | { | 957 | { |
958 | |||
952 | if ( !updatePossible ) | 959 | if ( !updatePossible ) |
953 | return; | 960 | return; |
954 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
955 | int i; | 962 | int i; |
956 | for( i = 0; i < mCells.count(); ++i ) { | 963 | for( i = 0; i < mCells.count(); ++i ) { |
957 | mCells[i]->updateCell(); | 964 | mCells[i]->updateCell(); |
958 | } | 965 | } |
959 | 966 | ||
960 | //qDebug("KOMonthView::updateView() "); | 967 | //qDebug("KOMonthView::updateView() "); |
961 | processSelectionChange(); | 968 | processSelectionChange(); |
962 | // qDebug("---------------------------------------------------------------------+ "); | 969 | // qDebug("---------------------------------------------------------------------+ "); |
970 | setFocus(); | ||
963 | } | 971 | } |
964 | 972 | ||
965 | void KOMonthView::resizeEvent(QResizeEvent * e) | 973 | void KOMonthView::resizeEvent(QResizeEvent * e) |
966 | { | 974 | { |
967 | computeLayout(); | 975 | computeLayout(); |
968 | } | 976 | } |
969 | void KOMonthView::computeLayout() | 977 | void KOMonthView::computeLayout() |
970 | { | 978 | { |
971 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 979 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
972 | // note this only changes the text if the requested size crosses the | 980 | // note this only changes the text if the requested size crosses the |
973 | // threshold between big enough to support the full name and not big | 981 | // threshold between big enough to support the full name and not big |
974 | // enough. | 982 | // enough. |
975 | 983 | ||
976 | int daysToShow = 7; | 984 | int daysToShow = 7; |
977 | bool combinedSatSun = false; | 985 | bool combinedSatSun = false; |
978 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 986 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
979 | daysToShow = 6; | 987 | daysToShow = 6; |
980 | combinedSatSun = true; | 988 | combinedSatSun = true; |
981 | } | 989 | } |
982 | int tWid = topLevelWidget()->size().width(); | 990 | int tWid = topLevelWidget()->size().width(); |
983 | int tHei = topLevelWidget()->size().height(); | 991 | int tHei = topLevelWidget()->size().height(); |
984 | 992 | ||
985 | int wid = size().width();//e | 993 | int wid = size().width();//e |
986 | int hei = size().height()-1; | 994 | int hei = size().height()-1; |
987 | 995 | ||
988 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 996 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
989 | return; | 997 | return; |
990 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 998 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
991 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 999 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
992 | int weeklabelwid = fm.width( "888" ); | 1000 | int weeklabelwid = fm.width( "888" ); |
993 | wid -= weeklabelwid; | 1001 | wid -= weeklabelwid; |
994 | 1002 | ||
995 | int colWid = wid / daysToShow; | 1003 | int colWid = wid / daysToShow; |
996 | int lastCol = wid - ( colWid*6 ); | 1004 | int lastCol = wid - ( colWid*6 ); |
997 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
998 | int cellHei = (hei - dayLabelHei) /6; | 1006 | int cellHei = (hei - dayLabelHei) /6; |
999 | int colModulo = wid % daysToShow; | 1007 | int colModulo = wid % daysToShow; |
1000 | int rowModulo = (hei- dayLabelHei) % 6; | 1008 | int rowModulo = (hei- dayLabelHei) % 6; |
1001 | //qDebug("rowmod %d ", rowModulo); | 1009 | //qDebug("rowmod %d ", rowModulo); |
1002 | int i; | 1010 | int i; |
1003 | int x,y,w,h; | 1011 | int x,y,w,h; |
1004 | x= 0; | 1012 | x= 0; |
1005 | y= 0; | 1013 | y= 0; |
1006 | w = colWid; | 1014 | w = colWid; |
1007 | h = dayLabelHei ; | 1015 | h = dayLabelHei ; |
1008 | for ( i = 0; i < 7; i++) { | 1016 | for ( i = 0; i < 7; i++) { |
1009 | if ( i == daysToShow-colModulo ) | 1017 | if ( i == daysToShow-colModulo ) |
1010 | ++w; | 1018 | ++w; |
1011 | if ( combinedSatSun ) { | 1019 | if ( combinedSatSun ) { |
1012 | if ( i >= daysToShow-1 ) { | 1020 | if ( i >= daysToShow-1 ) { |
1013 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1021 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1014 | x -= w/2 ; | 1022 | x -= w/2 ; |
1015 | } | 1023 | } |
1016 | else | 1024 | else |
1017 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1018 | } else | 1026 | } else |
1019 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1027 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1020 | x += w; | 1028 | x += w; |
1021 | } | 1029 | } |
1022 | x= 0; | 1030 | x= 0; |
1023 | y= dayLabelHei; | 1031 | y= dayLabelHei; |
1024 | w = colWid; | 1032 | w = colWid; |
1025 | h = cellHei ; | 1033 | h = cellHei ; |
1026 | for ( i = 0; i < mCells.count(); ++i) { | 1034 | for ( i = 0; i < mCells.count(); ++i) { |
1027 | 1035 | ||
1028 | w = colWid; | 1036 | w = colWid; |
1029 | if ( ((i) % 7) >= 7-colModulo ) { | 1037 | if ( ((i) % 7) >= 7-colModulo ) { |
1030 | ++w; | 1038 | ++w; |
1031 | } | 1039 | } |
1032 | if ( i == (6-rowModulo)*7) | 1040 | if ( i == (6-rowModulo)*7) |
1033 | ++h; | 1041 | ++h; |
1034 | if ( combinedSatSun ) { | 1042 | if ( combinedSatSun ) { |
1035 | if ( (i)%7 >= daysToShow-1 ) { | 1043 | if ( (i)%7 >= daysToShow-1 ) { |
1036 | if ( (i)%7 == daysToShow-1 ) { | 1044 | if ( (i)%7 == daysToShow-1 ) { |
1037 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1045 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1038 | x -= w ;y += h/2; | 1046 | x -= w ;y += h/2; |
1039 | } else { | 1047 | } else { |
1040 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1041 | y -= h/2; | 1049 | y -= h/2; |
1042 | } | 1050 | } |
1043 | } else | 1051 | } else |
1044 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1052 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1045 | 1053 | ||
1046 | } | 1054 | } |
1047 | else | 1055 | else |
1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1056 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1049 | x += w; | 1057 | x += w; |
1050 | if ( x + w/2 > wid ) { | 1058 | if ( x + w/2 > wid ) { |
1051 | x = 0; | 1059 | x = 0; |
1052 | y += h; | 1060 | y += h; |
1053 | } | 1061 | } |
1054 | } | 1062 | } |
1055 | y= dayLabelHei; | 1063 | y= dayLabelHei; |
1056 | h = cellHei ; | 1064 | h = cellHei ; |
1057 | for ( i = 0; i < 6; i++) { | 1065 | for ( i = 0; i < 6; i++) { |
1058 | if ( i == (6-rowModulo)) | 1066 | if ( i == (6-rowModulo)) |
1059 | ++h; | 1067 | ++h; |
1060 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1068 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1061 | y += h; | 1069 | y += h; |
1062 | } | 1070 | } |
1063 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1071 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1064 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1072 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1065 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1073 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1066 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1074 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1067 | updateDayLabels(); | 1075 | updateDayLabels(); |
1068 | bool forceUpdate = !updatePossible; | 1076 | bool forceUpdate = !updatePossible; |
1069 | updatePossible = true; | 1077 | updatePossible = true; |
1070 | if ( forceUpdate ) | 1078 | if ( forceUpdate ) |
1071 | updateView(); | 1079 | updateView(); |
1072 | } | 1080 | } |
1073 | 1081 | ||
1074 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1082 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1075 | { | 1083 | { |
1076 | mContextMenu->showIncidencePopup(incidence); | 1084 | mContextMenu->showIncidencePopup(incidence); |
1077 | /* | 1085 | /* |
1078 | if( incidence && incidence->type() == "Event" ) { | 1086 | if( incidence && incidence->type() == "Event" ) { |
1079 | Event *event = static_cast<Event *>(incidence); | 1087 | Event *event = static_cast<Event *>(incidence); |
1080 | mContextMenu->showEventPopup(event); | 1088 | mContextMenu->showEventPopup(event); |
1081 | } else { | 1089 | } else { |
1082 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1090 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1083 | } | 1091 | } |
1084 | */ | 1092 | */ |
1085 | } | 1093 | } |
1086 | MonthViewCell * KOMonthView::selectedCell( ) | 1094 | MonthViewCell * KOMonthView::selectedCell( ) |
1087 | { | 1095 | { |
1088 | return mSelectedCell; | 1096 | return mSelectedCell; |
1089 | } | 1097 | } |
1090 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1098 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1091 | { | 1099 | { |
1092 | // qDebug("KOMonthView::setSelectedCell "); | 1100 | // qDebug("KOMonthView::setSelectedCell "); |
1093 | if ( mSelectedCell && mSelectedCell != cell ) { | 1101 | if ( mSelectedCell && mSelectedCell != cell ) { |
1094 | MonthViewCell * mvc = mSelectedCell; | 1102 | MonthViewCell * mvc = mSelectedCell; |
1095 | mSelectedCell = cell; | 1103 | mSelectedCell = cell; |
1096 | mvc->deselect(); | 1104 | mvc->deselect(); |
1097 | } else | 1105 | } else |
1098 | mSelectedCell = cell; | 1106 | mSelectedCell = cell; |
1099 | // if ( mSelectedCell ) | 1107 | // if ( mSelectedCell ) |
1100 | // mSelectedCell->select(); | 1108 | // mSelectedCell->select(); |
1101 | if ( !mSelectedCell ) | 1109 | if ( !mSelectedCell ) |
1102 | emit incidenceSelected( 0 ); | 1110 | emit incidenceSelected( 0 ); |
1103 | else | 1111 | else |
1104 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1112 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1105 | } | 1113 | } |
1106 | 1114 | ||
1107 | void KOMonthView::processSelectionChange() | 1115 | void KOMonthView::processSelectionChange() |
1108 | { | 1116 | { |
1109 | QPtrList<Incidence> incidences = selectedIncidences(); | 1117 | QPtrList<Incidence> incidences = selectedIncidences(); |
1110 | if (incidences.count() > 0) { | 1118 | if (incidences.count() > 0) { |
1111 | emit incidenceSelected( incidences.first() ); | 1119 | emit incidenceSelected( incidences.first() ); |
1112 | } else { | 1120 | } else { |
1113 | emit incidenceSelected( 0 ); | 1121 | emit incidenceSelected( 0 ); |
1114 | } | 1122 | } |
1115 | } | 1123 | } |
1116 | 1124 | ||
1117 | void KOMonthView::clearSelection() | 1125 | void KOMonthView::clearSelection() |
1118 | { | 1126 | { |
1119 | if ( mSelectedCell ) { | 1127 | if ( mSelectedCell ) { |
1120 | mSelectedCell->deselect(); | 1128 | mSelectedCell->deselect(); |
1121 | mSelectedCell = 0; | 1129 | mSelectedCell = 0; |
1122 | } | 1130 | } |
1123 | } | 1131 | } |
1124 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1132 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1125 | { | 1133 | { |
1126 | 1134 | switch(e->key()) { | |
1127 | e->ignore(); | 1135 | break; |
1128 | 1136 | case Key_Up: | |
1137 | { | ||
1138 | emit prevMonth(); | ||
1139 | setFocus(); | ||
1140 | } | ||
1141 | e->accept(); | ||
1142 | break; | ||
1143 | case Key_Down: | ||
1144 | { | ||
1145 | emit nextMonth(); | ||
1146 | setFocus(); | ||
1147 | } | ||
1148 | e->accept(); | ||
1149 | break; | ||
1150 | default: | ||
1151 | e->ignore(); | ||
1152 | break; | ||
1153 | } | ||
1129 | } | 1154 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index a965bf3..50903b3 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,272 +1,274 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qintdict.h> | 29 | #include <qintdict.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qptrvector.h> | 32 | #include <qptrvector.h> |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | #include <libkcal/event.h> | 35 | #include <libkcal/event.h> |
36 | 36 | ||
37 | #include "koeventview.h" | 37 | #include "koeventview.h" |
38 | 38 | ||
39 | #ifdef DESKTOP_VERSION | 39 | #ifdef DESKTOP_VERSION |
40 | class QToolTipGroup; | 40 | class QToolTipGroup; |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | class KNOWhatsThis; | 43 | class KNOWhatsThis; |
44 | class KOWeekButton : public QPushButton | 44 | class KOWeekButton : public QPushButton |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
49 | QPushButton( parent, name) | 49 | QPushButton( parent, name) |
50 | { | 50 | { |
51 | connect( this, SIGNAL( clicked() ), | 51 | connect( this, SIGNAL( clicked() ), |
52 | SLOT( bottonClicked() )); | 52 | SLOT( bottonClicked() )); |
53 | mNumber = -1; | 53 | mNumber = -1; |
54 | } | 54 | } |
55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
56 | signals: | 56 | signals: |
57 | void selectWeekNum ( int ); | 57 | void selectWeekNum ( int ); |
58 | private: | 58 | private: |
59 | int mNumber; | 59 | int mNumber; |
60 | private slots : | 60 | private slots : |
61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class KNoScrollListBox: public QListBox | 64 | class KNoScrollListBox: public QListBox |
65 | { | 65 | { |
66 | Q_OBJECT | 66 | Q_OBJECT |
67 | public: | 67 | public: |
68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
69 | ~KNoScrollListBox(); | 69 | ~KNoScrollListBox(); |
70 | QString getWhatsThisText(QPoint p) ; | 70 | QString getWhatsThisText(QPoint p) ; |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void shiftDown(); | 73 | void shiftDown(); |
74 | void shiftUp(); | 74 | void shiftUp(); |
75 | void rightClick(); | 75 | void rightClick(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void keyPressEvent(QKeyEvent *); | 78 | void keyPressEvent(QKeyEvent *); |
79 | void keyReleaseEvent(QKeyEvent *); | 79 | void keyReleaseEvent(QKeyEvent *); |
80 | void mousePressEvent(QMouseEvent *); | 80 | void mousePressEvent(QMouseEvent *); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | KNOWhatsThis * mWT; | 83 | KNOWhatsThis * mWT; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
87 | class MonthViewItem: public QListBoxItem | 87 | class MonthViewItem: public QListBoxItem |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
91 | 91 | ||
92 | void setRecur(bool on) { mRecur = on; } | 92 | void setRecur(bool on) { mRecur = on; } |
93 | void setAlarm(bool on) { mAlarm = on; } | 93 | void setAlarm(bool on) { mAlarm = on; } |
94 | void setReply(bool on) { mReply = on; } | 94 | void setReply(bool on) { mReply = on; } |
95 | void setMoreInfo(bool on) { mInfo = on; } | 95 | void setMoreInfo(bool on) { mInfo = on; } |
96 | 96 | ||
97 | 97 | ||
98 | void setPalette(const QPalette &p) { mPalette = p; } | 98 | void setPalette(const QPalette &p) { mPalette = p; } |
99 | QPalette palette() const { return mPalette; } | 99 | QPalette palette() const { return mPalette; } |
100 | 100 | ||
101 | Incidence *incidence() const { return mIncidence; } | 101 | Incidence *incidence() const { return mIncidence; } |
102 | QDate incidenceDate() { return mDate; } | 102 | QDate incidenceDate() { return mDate; } |
103 | 103 | ||
104 | protected: | 104 | protected: |
105 | virtual void paint(QPainter *); | 105 | virtual void paint(QPainter *); |
106 | virtual int height(const QListBox *) const; | 106 | virtual int height(const QListBox *) const; |
107 | virtual int width(const QListBox *) const; | 107 | virtual int width(const QListBox *) const; |
108 | 108 | ||
109 | private: | 109 | private: |
110 | bool mRecur; | 110 | bool mRecur; |
111 | bool mAlarm; | 111 | bool mAlarm; |
112 | bool mReply; | 112 | bool mReply; |
113 | bool mInfo; | 113 | bool mInfo; |
114 | 114 | ||
115 | QPalette mPalette; | 115 | QPalette mPalette; |
116 | QDate mDate; | 116 | QDate mDate; |
117 | 117 | ||
118 | Incidence *mIncidence; | 118 | Incidence *mIncidence; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | class KOMonthView; | 122 | class KOMonthView; |
123 | 123 | ||
124 | class MonthViewCell : public QWidget | 124 | class MonthViewCell : public QWidget |
125 | { | 125 | { |
126 | Q_OBJECT | 126 | Q_OBJECT |
127 | public: | 127 | public: |
128 | MonthViewCell( KOMonthView * ); | 128 | MonthViewCell( KOMonthView * ); |
129 | 129 | ||
130 | void setDate( const QDate & ); | 130 | void setDate( const QDate & ); |
131 | QDate date() const; | 131 | QDate date() const; |
132 | 132 | ||
133 | void setPrimary( bool ); | 133 | void setPrimary( bool ); |
134 | bool isPrimary() const; | 134 | bool isPrimary() const; |
135 | 135 | ||
136 | void setHoliday( bool ); | 136 | void setHoliday( bool ); |
137 | void setHoliday( const QString & ); | 137 | void setHoliday( const QString & ); |
138 | 138 | ||
139 | void updateCell(); | 139 | void updateCell(); |
140 | 140 | ||
141 | void updateConfig(); | 141 | void updateConfig(); |
142 | 142 | ||
143 | void enableScrollBars( bool ); | 143 | void enableScrollBars( bool ); |
144 | 144 | ||
145 | Incidence *selectedIncidence(); | 145 | Incidence *selectedIncidence(); |
146 | QDate selectedIncidenceDate(); | 146 | QDate selectedIncidenceDate(); |
147 | 147 | ||
148 | void deselect(); | 148 | void deselect(); |
149 | void select(); | 149 | void select(); |
150 | void clear(); | 150 | void clear(); |
151 | 151 | ||
152 | #ifdef DESKTOP_VERSION | 152 | #ifdef DESKTOP_VERSION |
153 | static QToolTipGroup *toolTipGroup(); | 153 | static QToolTipGroup *toolTipGroup(); |
154 | #endif | 154 | #endif |
155 | signals: | 155 | signals: |
156 | void defaultAction( Incidence * ); | 156 | void defaultAction( Incidence * ); |
157 | void newEventSignal( QDateTime ); | 157 | void newEventSignal( QDateTime ); |
158 | void showDaySignal( QDate ); | 158 | void showDaySignal( QDate ); |
159 | 159 | ||
160 | protected: | 160 | protected: |
161 | void resizeEvent( QResizeEvent * ); | 161 | void resizeEvent( QResizeEvent * ); |
162 | 162 | ||
163 | protected slots: | 163 | protected slots: |
164 | void defaultAction( QListBoxItem * ); | 164 | void defaultAction( QListBoxItem * ); |
165 | void contextMenu( QListBoxItem * ); | 165 | void contextMenu( QListBoxItem * ); |
166 | void selection( QListBoxItem * ); | 166 | void selection( QListBoxItem * ); |
167 | void cellClicked( QListBoxItem * ); | 167 | void cellClicked( QListBoxItem * ); |
168 | void newEvent(); | 168 | void newEvent(); |
169 | void showDay(); | 169 | void showDay(); |
170 | 170 | ||
171 | private: | 171 | private: |
172 | KOMonthView *mMonthView; | 172 | KOMonthView *mMonthView; |
173 | 173 | ||
174 | QDate mDate; | 174 | QDate mDate; |
175 | bool mPrimary; | 175 | bool mPrimary; |
176 | bool mHoliday; | 176 | bool mHoliday; |
177 | QString mHolidayString; | 177 | QString mHolidayString; |
178 | 178 | ||
179 | //QLabel *mLabel; | 179 | //QLabel *mLabel; |
180 | QPushButton *mLabel; | 180 | QPushButton *mLabel; |
181 | QListBox *mItemList; | 181 | QListBox *mItemList; |
182 | #ifdef DESKTOP_VERSION | 182 | #ifdef DESKTOP_VERSION |
183 | static QToolTipGroup *mToolTipGroup; | 183 | static QToolTipGroup *mToolTipGroup; |
184 | #endif | 184 | #endif |
185 | QSize mLabelSize; | 185 | QSize mLabelSize; |
186 | QSize mLabelBigSize; | 186 | QSize mLabelBigSize; |
187 | QPalette mHolidayPalette; | 187 | QPalette mHolidayPalette; |
188 | QPalette mStandardPalette; | 188 | QPalette mStandardPalette; |
189 | QPalette mPrimaryPalette; | 189 | QPalette mPrimaryPalette; |
190 | QPalette mNonPrimaryPalette; | 190 | QPalette mNonPrimaryPalette; |
191 | void setMyPalette(); | 191 | void setMyPalette(); |
192 | QPalette getPalette (); | 192 | QPalette getPalette (); |
193 | void keyPressEvent ( QKeyEvent * ) ; | 193 | void keyPressEvent ( QKeyEvent * ) ; |
194 | 194 | ||
195 | }; | 195 | }; |
196 | 196 | ||
197 | 197 | ||
198 | class KOMonthView: public KOEventView | 198 | class KOMonthView: public KOEventView |
199 | { | 199 | { |
200 | Q_OBJECT | 200 | Q_OBJECT |
201 | public: | 201 | public: |
202 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 202 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
203 | ~KOMonthView(); | 203 | ~KOMonthView(); |
204 | 204 | ||
205 | /** Returns maximum number of days supported by the komonthview */ | 205 | /** Returns maximum number of days supported by the komonthview */ |
206 | virtual int maxDatesHint(); | 206 | virtual int maxDatesHint(); |
207 | 207 | ||
208 | /** Returns number of currently shown dates. */ | 208 | /** Returns number of currently shown dates. */ |
209 | virtual int currentDateCount(); | 209 | virtual int currentDateCount(); |
210 | 210 | ||
211 | /** returns the currently selected events */ | 211 | /** returns the currently selected events */ |
212 | virtual QPtrList<Incidence> selectedIncidences(); | 212 | virtual QPtrList<Incidence> selectedIncidences(); |
213 | 213 | ||
214 | /** returns dates of the currently selected events */ | 214 | /** returns dates of the currently selected events */ |
215 | virtual DateList selectedDates(); | 215 | virtual DateList selectedDates(); |
216 | 216 | ||
217 | virtual void printPreview(CalPrinter *calPrinter, | 217 | virtual void printPreview(CalPrinter *calPrinter, |
218 | const QDate &, const QDate &); | 218 | const QDate &, const QDate &); |
219 | bool isMonthView() { return true; } | 219 | bool isMonthView() { return true; } |
220 | bool isUpdatePossible() { return updatePossible; } | 220 | bool isUpdatePossible() { return updatePossible; } |
221 | 221 | ||
222 | MonthViewCell * selectedCell(); | 222 | MonthViewCell * selectedCell(); |
223 | public slots: | 223 | public slots: |
224 | virtual void updateView(); | 224 | virtual void updateView(); |
225 | virtual void updateConfig(); | 225 | virtual void updateConfig(); |
226 | virtual void showDates(const QDate &start, const QDate &end); | 226 | virtual void showDates(const QDate &start, const QDate &end); |
227 | virtual void showEvents(QPtrList<Event> eventList); | 227 | virtual void showEvents(QPtrList<Event> eventList); |
228 | 228 | ||
229 | void changeEventDisplay(Event *, int); | 229 | void changeEventDisplay(Event *, int); |
230 | 230 | ||
231 | void clearSelection(); | 231 | void clearSelection(); |
232 | 232 | ||
233 | void showContextMenu( Incidence * ); | 233 | void showContextMenu( Incidence * ); |
234 | 234 | ||
235 | void setSelectedCell( MonthViewCell * ); | 235 | void setSelectedCell( MonthViewCell * ); |
236 | 236 | ||
237 | protected slots: | 237 | protected slots: |
238 | void processSelectionChange(); | 238 | void processSelectionChange(); |
239 | signals: | 239 | signals: |
240 | void nextMonth(); | ||
241 | void prevMonth(); | ||
240 | void selectWeekNum ( int ); | 242 | void selectWeekNum ( int ); |
241 | void showDaySignal( QDate ); | 243 | void showDaySignal( QDate ); |
242 | protected: | 244 | protected: |
243 | void resizeEvent(QResizeEvent *); | 245 | void resizeEvent(QResizeEvent *); |
244 | void viewChanged(); | 246 | void viewChanged(); |
245 | void updateDayLabels(); | 247 | void updateDayLabels(); |
246 | 248 | ||
247 | private: | 249 | private: |
248 | bool updatePossible; | 250 | bool updatePossible; |
249 | int mDaysPerWeek; | 251 | int mDaysPerWeek; |
250 | int mNumWeeks; | 252 | int mNumWeeks; |
251 | int mNumCells; | 253 | int mNumCells; |
252 | bool mWeekStartsMonday; | 254 | bool mWeekStartsMonday; |
253 | bool mShowSatSunComp; | 255 | bool mShowSatSunComp; |
254 | void computeLayout(); | 256 | void computeLayout(); |
255 | 257 | ||
256 | QPtrVector<MonthViewCell> mCells; | 258 | QPtrVector<MonthViewCell> mCells; |
257 | QPtrVector<QLabel> mDayLabels; | 259 | QPtrVector<QLabel> mDayLabels; |
258 | QPtrVector<KOWeekButton> mWeekLabels; | 260 | QPtrVector<KOWeekButton> mWeekLabels; |
259 | 261 | ||
260 | bool mShortDayLabels; | 262 | bool mShortDayLabels; |
261 | int mWidthLongDayLabel; | 263 | int mWidthLongDayLabel; |
262 | 264 | ||
263 | QDate mStartDate; | 265 | QDate mStartDate; |
264 | 266 | ||
265 | MonthViewCell *mSelectedCell; | 267 | MonthViewCell *mSelectedCell; |
266 | 268 | ||
267 | KOEventPopupMenu *mContextMenu; | 269 | KOEventPopupMenu *mContextMenu; |
268 | void keyPressEvent ( QKeyEvent * ) ; | 270 | void keyPressEvent ( QKeyEvent * ) ; |
269 | 271 | ||
270 | }; | 272 | }; |
271 | 273 | ||
272 | #endif | 274 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 94c459b..e8d5ab1 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -76,515 +76,519 @@ KOViewManager::KOViewManager( CalendarView *mainView ) : | |||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOViewManager::writeSettings(KConfig *config) | 101 | void KOViewManager::writeSettings(KConfig *config) |
102 | { | 102 | { |
103 | config->setGroup("General"); | 103 | config->setGroup("General"); |
104 | 104 | ||
105 | QString view; | 105 | QString view; |
106 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 106 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
107 | else if (mCurrentView == mMonthView) view = "Month"; | 107 | else if (mCurrentView == mMonthView) view = "Month"; |
108 | else if (mCurrentView == mListView) view = "List"; | 108 | else if (mCurrentView == mListView) view = "List"; |
109 | else if (mCurrentView == mJournalView) view = "Journal"; | 109 | else if (mCurrentView == mJournalView) view = "Journal"; |
110 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 110 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
111 | else if (mCurrentView == mTodoView) view = "Todo"; | 111 | else if (mCurrentView == mTodoView) view = "Todo"; |
112 | else view = "Agenda"; | 112 | else view = "Agenda"; |
113 | 113 | ||
114 | config->writeEntry("Current View",view); | 114 | config->writeEntry("Current View",view); |
115 | 115 | ||
116 | if (mAgendaView) { | 116 | if (mAgendaView) { |
117 | mAgendaView->writeSettings(config); | 117 | mAgendaView->writeSettings(config); |
118 | } | 118 | } |
119 | if (mTimeSpanView) { | 119 | if (mTimeSpanView) { |
120 | mTimeSpanView->writeSettings(config); | 120 | mTimeSpanView->writeSettings(config); |
121 | } | 121 | } |
122 | if (mListView) { | 122 | if (mListView) { |
123 | mListView->writeSettings(config); | 123 | mListView->writeSettings(config); |
124 | } | 124 | } |
125 | if (mTodoView) { | 125 | if (mTodoView) { |
126 | mTodoView->saveLayout(config,"Todo View"); | 126 | mTodoView->saveLayout(config,"Todo View"); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 130 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
131 | { | 131 | { |
132 | 132 | ||
133 | //mFlagShowNextxDays = false; | 133 | //mFlagShowNextxDays = false; |
134 | //if(view == mCurrentView) return; | 134 | //if(view == mCurrentView) return; |
135 | if ( view == 0 ) { | 135 | if ( view == 0 ) { |
136 | view = mCurrentView; | 136 | view = mCurrentView; |
137 | if ( view == 0 ) | 137 | if ( view == 0 ) |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | bool full = fullScreen; | 140 | bool full = fullScreen; |
141 | if(view == mCurrentView && view != mWhatsNextView ) { | 141 | if(view == mCurrentView && view != mWhatsNextView ) { |
142 | if ( mCurrentAgendaView < 0 ) | 142 | if ( mCurrentAgendaView < 0 ) |
143 | return; | 143 | return; |
144 | full = mMainView->leftFrame()->isVisible(); | 144 | full = mMainView->leftFrame()->isVisible(); |
145 | } else { | 145 | } else { |
146 | mCurrentView = view; | 146 | mCurrentView = view; |
147 | 147 | ||
148 | // bool full = fullScreen; | 148 | // bool full = fullScreen; |
149 | bool isFull = !mMainView->leftFrame()->isVisible(); | 149 | bool isFull = !mMainView->leftFrame()->isVisible(); |
150 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 150 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
151 | full = true; | 151 | full = true; |
152 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 152 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
153 | full = false; | 153 | full = false; |
154 | } | 154 | } |
155 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 155 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
156 | //raiseCurrentView( full ); | 156 | //raiseCurrentView( full ); |
157 | mMainView->processIncidenceSelection( 0 ); | 157 | mMainView->processIncidenceSelection( 0 ); |
158 | mMainView->updateView(); | 158 | mMainView->updateView(); |
159 | raiseCurrentView( full ); | 159 | raiseCurrentView( full ); |
160 | mMainView->adaptNavigationUnits(); | 160 | mMainView->adaptNavigationUnits(); |
161 | } | 161 | } |
162 | 162 | ||
163 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 163 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
164 | { | 164 | { |
165 | //qDebug("raiseCurrentView "); | 165 | //qDebug("raiseCurrentView "); |
166 | mCurrentAgendaView = 0; | 166 | mCurrentAgendaView = 0; |
167 | int wid = mMainView->width() ; | 167 | int wid = mMainView->width() ; |
168 | int hei = mMainView->height(); | 168 | int hei = mMainView->height(); |
169 | if ( mCurrentView == mMonthView ) { | 169 | if ( mCurrentView == mMonthView ) { |
170 | mMainView->navigatorBar()->show(); | 170 | mMainView->navigatorBar()->show(); |
171 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 171 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
172 | //mMainView->navigatorBar()->hide(); | 172 | //mMainView->navigatorBar()->hide(); |
173 | } else { | 173 | } else { |
174 | mMainView->navigatorBar()->hide(); | 174 | mMainView->navigatorBar()->hide(); |
175 | } | 175 | } |
176 | if ( fullScreen ) { | 176 | if ( fullScreen ) { |
177 | mMainView->leftFrame()->hide(); | 177 | mMainView->leftFrame()->hide(); |
178 | } else { | 178 | } else { |
179 | mMainView->leftFrame()->show(); | 179 | mMainView->leftFrame()->show(); |
180 | if ( KOPrefs::instance()->mVerticalScreen ) | 180 | if ( KOPrefs::instance()->mVerticalScreen ) |
181 | hei -= mMainView->leftFrame()->height(); | 181 | hei -= mMainView->leftFrame()->height(); |
182 | else | 182 | else |
183 | wid -= mMainView->leftFrame()->width(); | 183 | wid -= mMainView->leftFrame()->width(); |
184 | } | 184 | } |
185 | emit signalFullScreen( !fullScreen ); | 185 | emit signalFullScreen( !fullScreen ); |
186 | if ( globalFlagBlockAgenda == 5 ) { | 186 | if ( globalFlagBlockAgenda == 5 ) { |
187 | globalFlagBlockAgenda = 4; | 187 | globalFlagBlockAgenda = 4; |
188 | globalFlagBlockAgendaItemPaint = 1; | 188 | globalFlagBlockAgendaItemPaint = 1; |
189 | } | 189 | } |
190 | mMainView->viewStack()->raiseWidget(mCurrentView); | 190 | mMainView->viewStack()->raiseWidget(mCurrentView); |
191 | if ( globalFlagBlockAgenda == 4 ) { | 191 | if ( globalFlagBlockAgenda == 4 ) { |
192 | if ( mCurrentView == mAgendaView ) { | 192 | if ( mCurrentView == mAgendaView ) { |
193 | //globalFlagBlockAgenda =1 ; | 193 | //globalFlagBlockAgenda =1 ; |
194 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 194 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
195 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 195 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
196 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 196 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
197 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 197 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
198 | qApp->processEvents(); | 198 | qApp->processEvents(); |
199 | //qDebug("qApp->processEvents() "); | 199 | //qDebug("qApp->processEvents() "); |
200 | globalFlagBlockAgenda = 0; | 200 | globalFlagBlockAgenda = 0; |
201 | mAgendaView->repaintAgenda(); | 201 | mAgendaView->repaintAgenda(); |
202 | 202 | ||
203 | } | 203 | } |
204 | globalFlagBlockAgenda = 0; | 204 | globalFlagBlockAgenda = 0; |
205 | } | 205 | } |
206 | emit signalAgendaView( mCurrentView == mAgendaView ); | 206 | emit signalAgendaView( mCurrentView == mAgendaView ); |
207 | //qDebug("raiseCurrentView ende "); | 207 | //qDebug("raiseCurrentView ende "); |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | void KOViewManager::updateView() | 211 | void KOViewManager::updateView() |
212 | { | 212 | { |
213 | // qDebug("KOViewManager::updateView() "); | 213 | // qDebug("KOViewManager::updateView() "); |
214 | // if we are updating mTodoView, we get endless recursion | 214 | // if we are updating mTodoView, we get endless recursion |
215 | if ( mTodoView == mCurrentView ) | 215 | if ( mTodoView == mCurrentView ) |
216 | return; | 216 | return; |
217 | if ( mCurrentView ) mCurrentView->updateView(); | 217 | if ( mCurrentView ) mCurrentView->updateView(); |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 221 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
222 | { | 222 | { |
223 | // kdDebug() << "KOViewManager::updateView()" << endl; | 223 | // kdDebug() << "KOViewManager::updateView()" << endl; |
224 | 224 | ||
225 | if (mCurrentView) mCurrentView->showDates(start, end); | 225 | if (mCurrentView) mCurrentView->showDates(start, end); |
226 | 226 | ||
227 | if (mTodoView) mTodoView->updateView(); | 227 | if (mTodoView) mTodoView->updateView(); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void KOViewManager::updateWNview() | 231 | void KOViewManager::updateWNview() |
232 | { | 232 | { |
233 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 233 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
234 | mWhatsNextView->updateView(); | 234 | mWhatsNextView->updateView(); |
235 | 235 | ||
236 | } | 236 | } |
237 | void KOViewManager::showWhatsNextView() | 237 | void KOViewManager::showWhatsNextView() |
238 | { | 238 | { |
239 | if (!mWhatsNextView) { | 239 | if (!mWhatsNextView) { |
240 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 240 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
241 | "KOViewManager::WhatsNextView"); | 241 | "KOViewManager::WhatsNextView"); |
242 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 242 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
243 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 243 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
244 | addView(mWhatsNextView); | 244 | addView(mWhatsNextView); |
245 | connect(this, SIGNAL( printWNV() ), | 245 | connect(this, SIGNAL( printWNV() ), |
246 | mWhatsNextView, SLOT( printMe() ) ); | 246 | mWhatsNextView, SLOT( printMe() ) ); |
247 | } | 247 | } |
248 | globalFlagBlockAgenda = 1; | 248 | globalFlagBlockAgenda = 1; |
249 | showView(mWhatsNextView, true ); | 249 | showView(mWhatsNextView, true ); |
250 | //mWhatsNextView->updateView(); | 250 | //mWhatsNextView->updateView(); |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | void KOViewManager::showListView() | 254 | void KOViewManager::showListView() |
255 | { | 255 | { |
256 | if (!mListView) { | 256 | if (!mListView) { |
257 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 257 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
258 | addView(mListView); | 258 | addView(mListView); |
259 | 259 | ||
260 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 260 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
261 | mMainView, SLOT(showIncidence(Incidence *))); | 261 | mMainView, SLOT(showIncidence(Incidence *))); |
262 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 262 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
263 | mMainView, SLOT(editIncidence(Incidence *))); | 263 | mMainView, SLOT(editIncidence(Incidence *))); |
264 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 264 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
265 | mMainView, SLOT(deleteIncidence(Incidence *))); | 265 | mMainView, SLOT(deleteIncidence(Incidence *))); |
266 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 266 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
267 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 267 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
268 | connect( mListView, SIGNAL( signalNewEvent() ), | 268 | connect( mListView, SIGNAL( signalNewEvent() ), |
269 | mMainView, SLOT( newEvent() ) ); | 269 | mMainView, SLOT( newEvent() ) ); |
270 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 270 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
271 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 271 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
272 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 272 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
273 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 273 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
274 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 274 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
275 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 275 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
276 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 276 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
277 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 277 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
278 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 278 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
279 | } | 279 | } |
280 | // bool temp = mFlagShowNextxDays; | 280 | // bool temp = mFlagShowNextxDays; |
281 | //globalFlagBlockPainting = true; | 281 | //globalFlagBlockPainting = true; |
282 | globalFlagBlockAgenda = 1; | 282 | globalFlagBlockAgenda = 1; |
283 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 283 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
284 | mMainView->setBlockShowDates( true ); | 284 | mMainView->setBlockShowDates( true ); |
285 | mMainView->dateNavigator()->selectMonth(); | 285 | mMainView->dateNavigator()->selectMonth(); |
286 | mMainView->setBlockShowDates( false ); | 286 | mMainView->setBlockShowDates( false ); |
287 | } | 287 | } |
288 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 288 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
289 | //mFlagShowNextxDays = temp; | 289 | //mFlagShowNextxDays = temp; |
290 | } | 290 | } |
291 | 291 | ||
292 | void KOViewManager::showAgendaView( bool fullScreen ) | 292 | void KOViewManager::showAgendaView( bool fullScreen ) |
293 | { | 293 | { |
294 | 294 | ||
295 | mMainView->dialogManager()->hideSearchDialog(); | 295 | mMainView->dialogManager()->hideSearchDialog(); |
296 | // qDebug("KOViewManager::showAgendaView "); | 296 | // qDebug("KOViewManager::showAgendaView "); |
297 | bool full; | 297 | bool full; |
298 | full = fullScreen; | 298 | full = fullScreen; |
299 | if (!mAgendaView) { | 299 | if (!mAgendaView) { |
300 | full = false; | 300 | full = false; |
301 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 301 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
302 | addView(mAgendaView); | 302 | addView(mAgendaView); |
303 | #ifndef DESKTOP_VERSION | 303 | #ifndef DESKTOP_VERSION |
304 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 304 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
305 | #endif | 305 | #endif |
306 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 306 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
307 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 307 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
308 | 308 | ||
309 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 309 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
310 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 310 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
311 | mMainView, SLOT(newEvent(QDateTime))); | 311 | mMainView, SLOT(newEvent(QDateTime))); |
312 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 312 | // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
313 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 313 | // mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
314 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 314 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
315 | mMainView, SLOT(newEvent(QDate))); | 315 | mMainView, SLOT(newEvent(QDate))); |
316 | 316 | ||
317 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 317 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
318 | mMainView, SLOT(editIncidence(Incidence *))); | 318 | mMainView, SLOT(editIncidence(Incidence *))); |
319 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 319 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
320 | mMainView, SLOT(showIncidence(Incidence *))); | 320 | mMainView, SLOT(showIncidence(Incidence *))); |
321 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 321 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
322 | mMainView, SLOT(deleteIncidence(Incidence *))); | 322 | mMainView, SLOT(deleteIncidence(Incidence *))); |
323 | 323 | ||
324 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 324 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
325 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 325 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
326 | 326 | ||
327 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 327 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
328 | mMainView, SLOT( toggleExpand() ) ); | 328 | mMainView, SLOT( toggleExpand() ) ); |
329 | 329 | ||
330 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 330 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
331 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 331 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
332 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 332 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
333 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 333 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
334 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 334 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
335 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 335 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
336 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 336 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
337 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 337 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
338 | SLOT( updateTodo( Todo *, int ) ) ); | 338 | SLOT( updateTodo( Todo *, int ) ) ); |
339 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 339 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
340 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 340 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
341 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 341 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
342 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 342 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
343 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 343 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
344 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 344 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
345 | mAgendaView->readSettings(); | 345 | mAgendaView->readSettings(); |
346 | mAgendaView->updateConfig(); | 346 | mAgendaView->updateConfig(); |
347 | } | 347 | } |
348 | 348 | ||
349 | showView( mAgendaView, full); | 349 | showView( mAgendaView, full); |
350 | 350 | ||
351 | } | 351 | } |
352 | 352 | ||
353 | void KOViewManager::showDayView() | 353 | void KOViewManager::showDayView() |
354 | { | 354 | { |
355 | mFlagShowNextxDays = false; | 355 | mFlagShowNextxDays = false; |
356 | globalFlagBlockLabel = 1; | 356 | globalFlagBlockLabel = 1; |
357 | globalFlagBlockAgenda = 1; | 357 | globalFlagBlockAgenda = 1; |
358 | if ( mCurrentAgendaView != 1 ) | 358 | if ( mCurrentAgendaView != 1 ) |
359 | mCurrentAgendaView = -1; | 359 | mCurrentAgendaView = -1; |
360 | showAgendaView(); | 360 | showAgendaView(); |
361 | qApp->processEvents(); | 361 | qApp->processEvents(); |
362 | globalFlagBlockAgenda = 2; | 362 | globalFlagBlockAgenda = 2; |
363 | globalFlagBlockLabel = 0; | 363 | globalFlagBlockLabel = 0; |
364 | mMainView->dateNavigator()->selectDates( 1 ); | 364 | mMainView->dateNavigator()->selectDates( 1 ); |
365 | mCurrentAgendaView = 1 ; | 365 | mCurrentAgendaView = 1 ; |
366 | 366 | ||
367 | } | 367 | } |
368 | 368 | ||
369 | void KOViewManager::showWorkWeekView() | 369 | void KOViewManager::showWorkWeekView() |
370 | { | 370 | { |
371 | mFlagShowNextxDays = false; | 371 | mFlagShowNextxDays = false; |
372 | globalFlagBlockAgenda = 1; | 372 | globalFlagBlockAgenda = 1; |
373 | globalFlagBlockLabel = 1; | 373 | globalFlagBlockLabel = 1; |
374 | if ( mCurrentAgendaView != 5 ) | 374 | if ( mCurrentAgendaView != 5 ) |
375 | mCurrentAgendaView = -1; | 375 | mCurrentAgendaView = -1; |
376 | showAgendaView(); | 376 | showAgendaView(); |
377 | qApp->processEvents(); | 377 | qApp->processEvents(); |
378 | globalFlagBlockAgenda = 2; | 378 | globalFlagBlockAgenda = 2; |
379 | globalFlagBlockLabel = 0; | 379 | globalFlagBlockLabel = 0; |
380 | mMainView->dateNavigator()->selectWorkWeek(); | 380 | mMainView->dateNavigator()->selectWorkWeek(); |
381 | mCurrentAgendaView = 5 ; | 381 | mCurrentAgendaView = 5 ; |
382 | 382 | ||
383 | } | 383 | } |
384 | 384 | ||
385 | void KOViewManager::showWeekView() | 385 | void KOViewManager::showWeekView() |
386 | { | 386 | { |
387 | /* | 387 | /* |
388 | globalFlagBlockAgenda = 2; | 388 | globalFlagBlockAgenda = 2; |
389 | qDebug("4globalFlagBlockAgenda = 2; "); | 389 | qDebug("4globalFlagBlockAgenda = 2; "); |
390 | //globalFlagBlockPainting = true; | 390 | //globalFlagBlockPainting = true; |
391 | mMainView->dateNavigator()->selectWeek(); | 391 | mMainView->dateNavigator()->selectWeek(); |
392 | showAgendaView(); | 392 | showAgendaView(); |
393 | */ | 393 | */ |
394 | 394 | ||
395 | 395 | ||
396 | mFlagShowNextxDays = false; | 396 | mFlagShowNextxDays = false; |
397 | globalFlagBlockAgenda = 1; | 397 | globalFlagBlockAgenda = 1; |
398 | globalFlagBlockLabel = 1; | 398 | globalFlagBlockLabel = 1; |
399 | if ( mCurrentAgendaView != 7 ) | 399 | if ( mCurrentAgendaView != 7 ) |
400 | mCurrentAgendaView = -1; | 400 | mCurrentAgendaView = -1; |
401 | showAgendaView(); | 401 | showAgendaView(); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | globalFlagBlockAgenda = 2; | 403 | globalFlagBlockAgenda = 2; |
404 | globalFlagBlockLabel = 0; | 404 | globalFlagBlockLabel = 0; |
405 | mMainView->dateNavigator()->selectWeek(); | 405 | mMainView->dateNavigator()->selectWeek(); |
406 | mCurrentAgendaView = 7 ; | 406 | mCurrentAgendaView = 7 ; |
407 | } | 407 | } |
408 | 408 | ||
409 | void KOViewManager::showNextXView() | 409 | void KOViewManager::showNextXView() |
410 | { | 410 | { |
411 | 411 | ||
412 | globalFlagBlockAgenda = 1; | 412 | globalFlagBlockAgenda = 1; |
413 | if ( mCurrentAgendaView != 3 ) | 413 | if ( mCurrentAgendaView != 3 ) |
414 | mCurrentAgendaView = -1; | 414 | mCurrentAgendaView = -1; |
415 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 415 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
416 | globalFlagBlockAgenda = 2; | 416 | globalFlagBlockAgenda = 2; |
417 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 417 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
418 | KOPrefs::instance()->mNextXDays ); | 418 | KOPrefs::instance()->mNextXDays ); |
419 | mFlagShowNextxDays = true; | 419 | mFlagShowNextxDays = true; |
420 | mCurrentAgendaView = 3 ; | 420 | mCurrentAgendaView = 3 ; |
421 | } | 421 | } |
422 | bool KOViewManager::showsNextDays() | 422 | bool KOViewManager::showsNextDays() |
423 | { | 423 | { |
424 | return mFlagShowNextxDays; | 424 | return mFlagShowNextxDays; |
425 | } | 425 | } |
426 | void KOViewManager::showMonthView() | 426 | void KOViewManager::showMonthView() |
427 | { | 427 | { |
428 | if (!mMonthView) { | 428 | if (!mMonthView) { |
429 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 429 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
430 | 430 | ||
431 | addView(mMonthView); | 431 | addView(mMonthView); |
432 | // mMonthView->show(); | 432 | // mMonthView->show(); |
433 | // SIGNALS/SLOTS FOR MONTH VIEW | 433 | // SIGNALS/SLOTS FOR MONTH VIEW |
434 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 434 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
435 | mMainView, SLOT(newEvent(QDateTime))); | 435 | mMainView, SLOT(newEvent(QDateTime))); |
436 | 436 | ||
437 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 437 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
438 | mMainView, SLOT(showIncidence(Incidence *))); | 438 | mMainView, SLOT(showIncidence(Incidence *))); |
439 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 439 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
440 | mMainView, SLOT(editIncidence(Incidence *))); | 440 | mMainView, SLOT(editIncidence(Incidence *))); |
441 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 441 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
442 | mMainView, SLOT(deleteIncidence(Incidence *))); | 442 | mMainView, SLOT(deleteIncidence(Incidence *))); |
443 | 443 | ||
444 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 444 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
445 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 445 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
446 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 446 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
447 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 447 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
448 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 448 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
449 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 449 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
450 | 450 | ||
451 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 451 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
452 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 452 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
453 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 453 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
454 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 454 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
455 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 455 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
456 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 456 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
457 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 457 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
458 | mMainView, SLOT ( showDay( QDate ) ) ); | 458 | mMainView, SLOT ( showDay( QDate ) ) ); |
459 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 459 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
460 | connect( mMonthView, SIGNAL(nextMonth() ), | ||
461 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | ||
462 | connect( mMonthView, SIGNAL(prevMonth() ), | ||
463 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | ||
460 | mMonthView->updateConfig(); | 464 | mMonthView->updateConfig(); |
461 | } | 465 | } |
462 | 466 | ||
463 | globalFlagBlockAgenda = 1; | 467 | globalFlagBlockAgenda = 1; |
464 | //mFlagShowNextxDays = false; | 468 | //mFlagShowNextxDays = false; |
465 | // if(mMonthView == mCurrentView) return; | 469 | // if(mMonthView == mCurrentView) return; |
466 | mMainView->dateNavigator()->selectMonth(); | 470 | mMainView->dateNavigator()->selectMonth(); |
467 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 471 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
468 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 472 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
469 | 473 | ||
470 | showView(mMonthView, true ); | 474 | showView(mMonthView, true ); |
471 | 475 | ||
472 | } | 476 | } |
473 | 477 | ||
474 | void KOViewManager::showTodoView() | 478 | void KOViewManager::showTodoView() |
475 | { | 479 | { |
476 | //mFlagShowNextxDays = false; | 480 | //mFlagShowNextxDays = false; |
477 | if ( !mTodoView ) { | 481 | if ( !mTodoView ) { |
478 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 482 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
479 | "KOViewManager::TodoView" ); | 483 | "KOViewManager::TodoView" ); |
480 | 484 | ||
481 | addView( mTodoView ); | 485 | addView( mTodoView ); |
482 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 486 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
483 | 487 | ||
484 | // SIGNALS/SLOTS FOR TODO VIEW | 488 | // SIGNALS/SLOTS FOR TODO VIEW |
485 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 489 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
486 | mMainView, SLOT( newTodo() ) ); | 490 | mMainView, SLOT( newTodo() ) ); |
487 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 491 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
488 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 492 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
489 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 493 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
490 | mMainView, SLOT( showTodo( Todo * ) ) ); | 494 | mMainView, SLOT( showTodo( Todo * ) ) ); |
491 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 495 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
492 | mMainView, SLOT( editTodo( Todo * ) ) ); | 496 | mMainView, SLOT( editTodo( Todo * ) ) ); |
493 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 497 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
494 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 498 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
495 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 499 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
496 | mMainView, SLOT( purgeCompleted() ) ); | 500 | mMainView, SLOT( purgeCompleted() ) ); |
497 | 501 | ||
498 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 502 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
499 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 503 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
500 | 504 | ||
501 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 505 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
502 | SLOT( updateConfig() ) ); | 506 | SLOT( updateConfig() ) ); |
503 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 507 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
504 | SLOT( updateTodo( Todo *, int ) ) ); | 508 | SLOT( updateTodo( Todo *, int ) ) ); |
505 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 509 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
506 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 510 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
507 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 511 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
508 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 512 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
509 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 513 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
510 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 514 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
511 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 515 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
512 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 516 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
513 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 517 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
514 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 518 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
515 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 519 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
516 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 520 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
517 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 521 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
518 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 522 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
519 | KConfig *config = KOGlobals::config(); | 523 | KConfig *config = KOGlobals::config(); |
520 | mTodoView->restoreLayout(config,"Todo View"); | 524 | mTodoView->restoreLayout(config,"Todo View"); |
521 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 525 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
522 | } | 526 | } |
523 | 527 | ||
524 | globalFlagBlockAgenda = 1; | 528 | globalFlagBlockAgenda = 1; |
525 | showView( mTodoView, true ); | 529 | showView( mTodoView, true ); |
526 | 530 | ||
527 | } | 531 | } |
528 | 532 | ||
529 | void KOViewManager::showJournalView() | 533 | void KOViewManager::showJournalView() |
530 | { | 534 | { |
531 | //mFlagShowNextxDays = false; | 535 | //mFlagShowNextxDays = false; |
532 | if (!mJournalView) { | 536 | if (!mJournalView) { |
533 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 537 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
534 | "KOViewManager::JournalView"); | 538 | "KOViewManager::JournalView"); |
535 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 539 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
536 | SLOT( updateConfig() ) ); | 540 | SLOT( updateConfig() ) ); |
537 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 541 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
538 | addView(mJournalView); | 542 | addView(mJournalView); |
539 | } | 543 | } |
540 | 544 | ||
541 | showView(mJournalView); | 545 | showView(mJournalView); |
542 | } | 546 | } |
543 | 547 | ||
544 | void KOViewManager::showTimeSpanView() | 548 | void KOViewManager::showTimeSpanView() |
545 | { | 549 | { |
546 | //mFlagShowNextxDays = false; | 550 | //mFlagShowNextxDays = false; |
547 | if (!mTimeSpanView) { | 551 | if (!mTimeSpanView) { |
548 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 552 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
549 | "KOViewManager::TimeSpanView"); | 553 | "KOViewManager::TimeSpanView"); |
550 | addView(mTimeSpanView); | 554 | addView(mTimeSpanView); |
551 | 555 | ||
552 | mTimeSpanView->readSettings(); | 556 | mTimeSpanView->readSettings(); |
553 | } | 557 | } |
554 | 558 | ||
555 | showView(mTimeSpanView); | 559 | showView(mTimeSpanView); |
556 | } | 560 | } |
557 | 561 | ||
558 | Incidence *KOViewManager::currentSelection() | 562 | Incidence *KOViewManager::currentSelection() |
559 | { | 563 | { |
560 | if (!mCurrentView) return 0; | 564 | if (!mCurrentView) return 0; |
561 | if ( mCurrentView == mListView ) { | 565 | if ( mCurrentView == mListView ) { |
562 | if ( mListView->currentItem() ) | 566 | if ( mListView->currentItem() ) |
563 | return mListView->currentItem(); | 567 | return mListView->currentItem(); |
564 | } | 568 | } |
565 | return mCurrentView->selectedIncidences().first(); | 569 | return mCurrentView->selectedIncidences().first(); |
566 | } | 570 | } |
567 | 571 | ||
568 | QDate KOViewManager::currentSelectionDate() | 572 | QDate KOViewManager::currentSelectionDate() |
569 | { | 573 | { |
570 | QDate qd; | 574 | QDate qd; |
571 | if (mCurrentView) { | 575 | if (mCurrentView) { |
572 | DateList qvl = mCurrentView->selectedDates(); | 576 | DateList qvl = mCurrentView->selectedDates(); |
573 | if (!qvl.isEmpty()) qd = qvl.first(); | 577 | if (!qvl.isEmpty()) qd = qvl.first(); |
574 | } | 578 | } |
575 | return qd; | 579 | return qd; |
576 | } | 580 | } |
577 | 581 | ||
578 | void KOViewManager::addView(KOrg::BaseView *view) | 582 | void KOViewManager::addView(KOrg::BaseView *view) |
579 | { | 583 | { |
580 | #if QT_VERSION >= 0x030000 | 584 | #if QT_VERSION >= 0x030000 |
581 | mMainView->viewStack()->addWidget( view ); | 585 | mMainView->viewStack()->addWidget( view ); |
582 | #else | 586 | #else |
583 | mMainView->viewStack()->addWidget( view, 1 ); | 587 | mMainView->viewStack()->addWidget( view, 1 ); |
584 | #endif | 588 | #endif |
585 | } | 589 | } |
586 | 590 | ||
587 | void KOViewManager::setDocumentId( const QString &id ) | 591 | void KOViewManager::setDocumentId( const QString &id ) |
588 | { | 592 | { |
589 | if (mTodoView) mTodoView->setDocumentId( id ); | 593 | if (mTodoView) mTodoView->setDocumentId( id ); |
590 | } | 594 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 145b36c..950d2ec 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1355,565 +1355,565 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) | |||
1355 | } else if ( incidence->type() == "Todo" ) { | 1355 | } else if ( incidence->type() == "Todo" ) { |
1356 | mShowAction->setText( i18n("Show Todo...") ); | 1356 | mShowAction->setText( i18n("Show Todo...") ); |
1357 | mEditAction->setText( i18n("Edit Todo...") ); | 1357 | mEditAction->setText( i18n("Edit Todo...") ); |
1358 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1358 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1359 | 1359 | ||
1360 | mNewSubTodoAction->setEnabled( true ); | 1360 | mNewSubTodoAction->setEnabled( true ); |
1361 | } else { | 1361 | } else { |
1362 | mShowAction->setText( i18n("Show...") ); | 1362 | mShowAction->setText( i18n("Show...") ); |
1363 | mShowAction->setText( i18n("Edit...") ); | 1363 | mShowAction->setText( i18n("Edit...") ); |
1364 | mShowAction->setText( i18n("Delete...") ); | 1364 | mShowAction->setText( i18n("Delete...") ); |
1365 | 1365 | ||
1366 | mNewSubTodoAction->setEnabled( false ); | 1366 | mNewSubTodoAction->setEnabled( false ); |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | void MainWindow::enableIncidenceActions( bool enabled ) | 1370 | void MainWindow::enableIncidenceActions( bool enabled ) |
1371 | { | 1371 | { |
1372 | mShowAction->setEnabled( enabled ); | 1372 | mShowAction->setEnabled( enabled ); |
1373 | mEditAction->setEnabled( enabled ); | 1373 | mEditAction->setEnabled( enabled ); |
1374 | mDeleteAction->setEnabled( enabled ); | 1374 | mDeleteAction->setEnabled( enabled ); |
1375 | 1375 | ||
1376 | mCloneAction->setEnabled( enabled ); | 1376 | mCloneAction->setEnabled( enabled ); |
1377 | mMoveAction->setEnabled( enabled ); | 1377 | mMoveAction->setEnabled( enabled ); |
1378 | mBeamAction->setEnabled( enabled ); | 1378 | mBeamAction->setEnabled( enabled ); |
1379 | mCancelAction->setEnabled( enabled ); | 1379 | mCancelAction->setEnabled( enabled ); |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | void MainWindow::importOL() | 1382 | void MainWindow::importOL() |
1383 | { | 1383 | { |
1384 | #ifdef _OL_IMPORT_ | 1384 | #ifdef _OL_IMPORT_ |
1385 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1385 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1386 | id->exec(); | 1386 | id->exec(); |
1387 | delete id; | 1387 | delete id; |
1388 | mView->updateView(); | 1388 | mView->updateView(); |
1389 | #endif | 1389 | #endif |
1390 | } | 1390 | } |
1391 | void MainWindow::importBday() | 1391 | void MainWindow::importBday() |
1392 | { | 1392 | { |
1393 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1393 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1394 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1394 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1395 | i18n("Import!"), i18n("Cancel"), 0, | 1395 | i18n("Import!"), i18n("Cancel"), 0, |
1396 | 0, 1 ); | 1396 | 0, 1 ); |
1397 | if ( result == 0 ) { | 1397 | if ( result == 0 ) { |
1398 | mView->importBday(); | 1398 | mView->importBday(); |
1399 | 1399 | ||
1400 | } | 1400 | } |
1401 | 1401 | ||
1402 | 1402 | ||
1403 | } | 1403 | } |
1404 | void MainWindow::importQtopia() | 1404 | void MainWindow::importQtopia() |
1405 | { | 1405 | { |
1406 | #ifndef DESKTOP_VERSION | 1406 | #ifndef DESKTOP_VERSION |
1407 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1407 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1408 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1408 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1409 | i18n("Import!"), i18n("Cancel"), 0, | 1409 | i18n("Import!"), i18n("Cancel"), 0, |
1410 | 0, 1 ); | 1410 | 0, 1 ); |
1411 | if ( result == 0 ) { | 1411 | if ( result == 0 ) { |
1412 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1412 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1413 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1413 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1414 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1414 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1415 | mView->importQtopia( categories, datebook, todolist ); | 1415 | mView->importQtopia( categories, datebook, todolist ); |
1416 | } | 1416 | } |
1417 | #else | 1417 | #else |
1418 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1418 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1419 | i18n("Not supported \non desktop!\n"), | 1419 | i18n("Not supported \non desktop!\n"), |
1420 | i18n("Ok"), i18n("Cancel"), 0, | 1420 | i18n("Ok"), i18n("Cancel"), 0, |
1421 | 0, 1 ); | 1421 | 0, 1 ); |
1422 | 1422 | ||
1423 | #endif | 1423 | #endif |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | void MainWindow::saveOnClose() | 1426 | void MainWindow::saveOnClose() |
1427 | { | 1427 | { |
1428 | KOPrefs *p = KOPrefs::instance(); | 1428 | KOPrefs *p = KOPrefs::instance(); |
1429 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1429 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1430 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1430 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1431 | iconToolBar->y() > height()/2; | 1431 | iconToolBar->y() > height()/2; |
1432 | mView->writeSettings(); | 1432 | mView->writeSettings(); |
1433 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1433 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1434 | save(); | 1434 | save(); |
1435 | } | 1435 | } |
1436 | void MainWindow::slotModifiedChanged( bool changed ) | 1436 | void MainWindow::slotModifiedChanged( bool changed ) |
1437 | { | 1437 | { |
1438 | if ( mBlockAtStartup ) | 1438 | if ( mBlockAtStartup ) |
1439 | return; | 1439 | return; |
1440 | int msec; | 1440 | int msec; |
1441 | // we store the changes after 1 minute, | 1441 | // we store the changes after 1 minute, |
1442 | // and for safety reasons after 10 minutes again | 1442 | // and for safety reasons after 10 minutes again |
1443 | if ( !mSyncManager->blockSave() ) | 1443 | if ( !mSyncManager->blockSave() ) |
1444 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1444 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1445 | else | 1445 | else |
1446 | msec = 1000 * 600; | 1446 | msec = 1000 * 600; |
1447 | mSaveTimer.start( msec, true ); // 1 minute | 1447 | mSaveTimer.start( msec, true ); // 1 minute |
1448 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1448 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1449 | mCalendarModifiedFlag = true; | 1449 | mCalendarModifiedFlag = true; |
1450 | } | 1450 | } |
1451 | void MainWindow::save() | 1451 | void MainWindow::save() |
1452 | { | 1452 | { |
1453 | if ( mSyncManager->blockSave() ) | 1453 | if ( mSyncManager->blockSave() ) |
1454 | return; | 1454 | return; |
1455 | mSyncManager->setBlockSave(true); | 1455 | mSyncManager->setBlockSave(true); |
1456 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1456 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1457 | 1457 | ||
1458 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1458 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1459 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1459 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1460 | qDebug("KO: Start saving data to file!"); | 1460 | qDebug("KO: Start saving data to file!"); |
1461 | mView->saveCalendar( defaultFileName() ); | 1461 | mView->saveCalendar( defaultFileName() ); |
1462 | 1462 | ||
1463 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1463 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1464 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1464 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1465 | QString savemes; | 1465 | QString savemes; |
1466 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1466 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1467 | setCaption(savemes); | 1467 | setCaption(savemes); |
1468 | } else | 1468 | } else |
1469 | setCaption(i18n("Saving cancelled!")); | 1469 | setCaption(i18n("Saving cancelled!")); |
1470 | mCalendarModifiedFlag = false; | 1470 | mCalendarModifiedFlag = false; |
1471 | mSyncManager->setBlockSave( false ); | 1471 | mSyncManager->setBlockSave( false ); |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1474 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1475 | { | 1475 | { |
1476 | if ( !e->isAutoRepeat() ) { | 1476 | if ( !e->isAutoRepeat() ) { |
1477 | mFlagKeyPressed = false; | 1477 | mFlagKeyPressed = false; |
1478 | } | 1478 | } |
1479 | } | 1479 | } |
1480 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1480 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1481 | { | 1481 | { |
1482 | qApp->processEvents(); | 1482 | qApp->processEvents(); |
1483 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1483 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1484 | e->ignore(); | 1484 | e->ignore(); |
1485 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1485 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1486 | return; | 1486 | return; |
1487 | } | 1487 | } |
1488 | if (! e->isAutoRepeat() ) | 1488 | if (! e->isAutoRepeat() ) |
1489 | mFlagKeyPressed = true; | 1489 | mFlagKeyPressed = true; |
1490 | KOPrefs *p = KOPrefs::instance(); | 1490 | KOPrefs *p = KOPrefs::instance(); |
1491 | bool showSelectedDates = false; | 1491 | bool showSelectedDates = false; |
1492 | int size; | 1492 | int size; |
1493 | int pro = 0; | 1493 | int pro = 0; |
1494 | //qDebug("MainWindow::keyPressEvent "); | 1494 | //qDebug("MainWindow::keyPressEvent "); |
1495 | switch ( e->key() ) { | 1495 | switch ( e->key() ) { |
1496 | case Qt::Key_Right: | 1496 | case Qt::Key_Right: |
1497 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1497 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1498 | mView->goNextMonth(); | 1498 | mView->goNextMonth(); |
1499 | else | 1499 | else |
1500 | mView->goNext(); | 1500 | mView->goNext(); |
1501 | showSelectedDates = true; | 1501 | showSelectedDates = true; |
1502 | break; | 1502 | break; |
1503 | case Qt::Key_Left: | 1503 | case Qt::Key_Left: |
1504 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1504 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1505 | mView->goPreviousMonth(); | 1505 | mView->goPreviousMonth(); |
1506 | else | 1506 | else |
1507 | mView->goPrevious(); | 1507 | mView->goPrevious(); |
1508 | showSelectedDates = true; | 1508 | showSelectedDates = true; |
1509 | break; | 1509 | break; |
1510 | case Qt::Key_Down: | 1510 | case Qt::Key_Down: |
1511 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1511 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1512 | break; | 1512 | break; |
1513 | case Qt::Key_Up: | 1513 | case Qt::Key_Up: |
1514 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1514 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1515 | break; | 1515 | break; |
1516 | case Qt::Key_I: | 1516 | case Qt::Key_I: |
1517 | mView->showIncidence(); | 1517 | mView->showIncidence(); |
1518 | break; | 1518 | break; |
1519 | case Qt::Key_Delete: | 1519 | case Qt::Key_Delete: |
1520 | case Qt::Key_Backspace: | 1520 | case Qt::Key_Backspace: |
1521 | mView->deleteIncidence(); | 1521 | mView->deleteIncidence(); |
1522 | break; | 1522 | break; |
1523 | case Qt::Key_D: | 1523 | case Qt::Key_D: |
1524 | mView->viewManager()->showDayView(); | 1524 | mView->viewManager()->showDayView(); |
1525 | showSelectedDates = true; | 1525 | showSelectedDates = true; |
1526 | break; | 1526 | break; |
1527 | case Qt::Key_O: | 1527 | case Qt::Key_O: |
1528 | mView->toggleFilerEnabled( ); | 1528 | mView->toggleFilerEnabled( ); |
1529 | break; | 1529 | break; |
1530 | case Qt::Key_0: | 1530 | case Qt::Key_0: |
1531 | case Qt::Key_1: | 1531 | case Qt::Key_1: |
1532 | case Qt::Key_2: | 1532 | case Qt::Key_2: |
1533 | case Qt::Key_3: | 1533 | case Qt::Key_3: |
1534 | case Qt::Key_4: | 1534 | case Qt::Key_4: |
1535 | case Qt::Key_5: | 1535 | case Qt::Key_5: |
1536 | case Qt::Key_6: | 1536 | case Qt::Key_6: |
1537 | case Qt::Key_7: | 1537 | case Qt::Key_7: |
1538 | case Qt::Key_8: | 1538 | case Qt::Key_8: |
1539 | case Qt::Key_9: | 1539 | case Qt::Key_9: |
1540 | pro = e->key()-48; | 1540 | pro = e->key()-48; |
1541 | if ( pro == 0 ) | 1541 | if ( pro == 0 ) |
1542 | pro = 10; | 1542 | pro = 10; |
1543 | if ( e->state() == Qt::ControlButton) | 1543 | if ( e->state() == Qt::ControlButton) |
1544 | pro += 10; | 1544 | pro += 10; |
1545 | break; | 1545 | break; |
1546 | case Qt::Key_M: | 1546 | case Qt::Key_M: |
1547 | mView->viewManager()->showMonthView(); | 1547 | mView->viewManager()->showMonthView(); |
1548 | showSelectedDates = true; | 1548 | showSelectedDates = true; |
1549 | break; | 1549 | break; |
1550 | case Qt::Key_Insert: | 1550 | case Qt::Key_Insert: |
1551 | mView->newEvent(); | 1551 | mView->newEvent(); |
1552 | break; | 1552 | break; |
1553 | case Qt::Key_S : | 1553 | case Qt::Key_S : |
1554 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1554 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1555 | mView->newSubTodo(); | 1555 | mView->newSubTodo(); |
1556 | else | 1556 | else |
1557 | mView->dialogManager()->showSearchDialog(); | 1557 | mView->dialogManager()->showSearchDialog(); |
1558 | break; | 1558 | break; |
1559 | case Qt::Key_Y : | 1559 | case Qt::Key_Y : |
1560 | case Qt::Key_Z : | 1560 | case Qt::Key_Z : |
1561 | mView->viewManager()->showWorkWeekView(); | 1561 | mView->viewManager()->showWorkWeekView(); |
1562 | showSelectedDates = true; | 1562 | showSelectedDates = true; |
1563 | break; | 1563 | break; |
1564 | case Qt::Key_U : | 1564 | case Qt::Key_U : |
1565 | mView->viewManager()->showWeekView(); | 1565 | mView->viewManager()->showWeekView(); |
1566 | showSelectedDates = true; | 1566 | showSelectedDates = true; |
1567 | break; | 1567 | break; |
1568 | case Qt::Key_H : | 1568 | case Qt::Key_H : |
1569 | keyBindings(); | 1569 | keyBindings(); |
1570 | break; | 1570 | break; |
1571 | case Qt::Key_W: | 1571 | case Qt::Key_W: |
1572 | mView->viewManager()->showWhatsNextView(); | 1572 | mView->viewManager()->showWhatsNextView(); |
1573 | break; | 1573 | break; |
1574 | case Qt::Key_L: | 1574 | case Qt::Key_L: |
1575 | mView->viewManager()->showListView(); | 1575 | mView->viewManager()->showListView(); |
1576 | break; | 1576 | break; |
1577 | case Qt::Key_N: | 1577 | case Qt::Key_N: |
1578 | mView->viewManager()->showNextXView(); | 1578 | mView->viewManager()->showNextXView(); |
1579 | showSelectedDates = true; | 1579 | showSelectedDates = true; |
1580 | break; | 1580 | break; |
1581 | case Qt::Key_V: | 1581 | case Qt::Key_V: |
1582 | mView->viewManager()->showTodoView(); | 1582 | mView->viewManager()->showTodoView(); |
1583 | break; | 1583 | break; |
1584 | case Qt::Key_C: | 1584 | case Qt::Key_C: |
1585 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1585 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1586 | break; | 1586 | break; |
1587 | case Qt::Key_P: | 1587 | case Qt::Key_P: |
1588 | mView->showDatePicker( ); | 1588 | mView->showDatePicker( ); |
1589 | break; | 1589 | break; |
1590 | case Qt::Key_F: | 1590 | case Qt::Key_F: |
1591 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1591 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1592 | mView->editFilters(); | 1592 | mView->editFilters(); |
1593 | else | 1593 | else |
1594 | mView->toggleFilter(); | 1594 | mView->toggleFilter(); |
1595 | break; | 1595 | break; |
1596 | case Qt::Key_X: | 1596 | case Qt::Key_X: |
1597 | mView->toggleDateNavigatorWidget(); | 1597 | mView->toggleDateNavigatorWidget(); |
1598 | break; | 1598 | break; |
1599 | case Qt::Key_Space: | 1599 | case Qt::Key_Space: |
1600 | mView->toggleExpand(); | 1600 | mView->toggleExpand(); |
1601 | break; | 1601 | break; |
1602 | case Qt::Key_A: | 1602 | case Qt::Key_A: |
1603 | mView->toggleAllDaySize(); | 1603 | mView->toggleAllDaySize(); |
1604 | break; | 1604 | break; |
1605 | case Qt::Key_T: | 1605 | case Qt::Key_T: |
1606 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1606 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1607 | mView->newTodo(); | 1607 | mView->newTodo(); |
1608 | else { | 1608 | else { |
1609 | mView->goToday(); | 1609 | mView->goToday(); |
1610 | showSelectedDates = true; | 1610 | showSelectedDates = true; |
1611 | } | 1611 | } |
1612 | break; | 1612 | break; |
1613 | case Qt::Key_J: | 1613 | case Qt::Key_J: |
1614 | mView->viewManager()->showJournalView(); | 1614 | mView->viewManager()->showJournalView(); |
1615 | break; | 1615 | break; |
1616 | case Qt::Key_B: | 1616 | case Qt::Key_B: |
1617 | mView->editIncidenceDescription();; | 1617 | mView->editIncidenceDescription();; |
1618 | break; | 1618 | break; |
1619 | // case Qt::Key_Return: | 1619 | // case Qt::Key_Return: |
1620 | case Qt::Key_E: | 1620 | case Qt::Key_E: |
1621 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1621 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1622 | mView->newEvent(); | 1622 | mView->newEvent(); |
1623 | else | 1623 | else |
1624 | mView->editIncidence(); | 1624 | mView->editIncidence(); |
1625 | break; | 1625 | break; |
1626 | case Qt::Key_Plus: | 1626 | case Qt::Key_Plus: |
1627 | size = p->mHourSize +2; | 1627 | size = p->mHourSize +2; |
1628 | if ( size <= 18 ) | 1628 | if ( size <= 18 ) |
1629 | configureAgenda( size ); | 1629 | configureAgenda( size ); |
1630 | break; | 1630 | break; |
1631 | case Qt::Key_Minus: | 1631 | case Qt::Key_Minus: |
1632 | size = p->mHourSize - 2; | 1632 | size = p->mHourSize - 2; |
1633 | if ( size >= 4 ) | 1633 | if ( size >= 4 ) |
1634 | configureAgenda( size ); | 1634 | configureAgenda( size ); |
1635 | break; | 1635 | break; |
1636 | 1636 | ||
1637 | 1637 | ||
1638 | default: | 1638 | default: |
1639 | e->ignore(); | 1639 | e->ignore(); |
1640 | } | 1640 | } |
1641 | if ( pro > 0 ) { | 1641 | if ( pro > 0 ) { |
1642 | mView->selectFilter( pro-1 ); | 1642 | mView->selectFilter( pro-1 ); |
1643 | } | 1643 | } |
1644 | if ( showSelectedDates ) { | 1644 | if ( showSelectedDates ) { |
1645 | ;// setCaptionToDates(); | 1645 | ;// setCaptionToDates(); |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | void MainWindow::fillFilterMenu() | 1650 | void MainWindow::fillFilterMenu() |
1651 | { | 1651 | { |
1652 | selectFilterMenu->clear(); | 1652 | selectFilterMenu->clear(); |
1653 | bool disable = false; | 1653 | bool disable = false; |
1654 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1654 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1655 | selectFilterMenu->insertSeparator(); | 1655 | selectFilterMenu->insertSeparator(); |
1656 | if ( mView->filterView()->filtersEnabled() ) { | 1656 | if ( mView->filterView()->filtersEnabled() ) { |
1657 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); | 1657 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); |
1658 | } | 1658 | } |
1659 | else { | 1659 | else { |
1660 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); | 1660 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); |
1661 | disable = true; | 1661 | disable = true; |
1662 | } | 1662 | } |
1663 | selectFilterMenu->insertSeparator(); | 1663 | selectFilterMenu->insertSeparator(); |
1664 | QPtrList<CalFilter> fili = mView->filters(); | 1664 | QPtrList<CalFilter> fili = mView->filters(); |
1665 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1665 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1666 | CalFilter *filter = fili.first(); | 1666 | CalFilter *filter = fili.first(); |
1667 | int iii = 2; | 1667 | int iii = 2; |
1668 | while(filter) { | 1668 | while(filter) { |
1669 | selectFilterMenu->insertItem( filter->name(), iii ); | 1669 | selectFilterMenu->insertItem( filter->name(), iii ); |
1670 | if ( filter == curfilter) | 1670 | if ( filter == curfilter) |
1671 | selectFilterMenu->setItemChecked( iii, true ); | 1671 | selectFilterMenu->setItemChecked( iii, true ); |
1672 | if ( disable ) | 1672 | if ( disable ) |
1673 | selectFilterMenu->setItemEnabled( iii, false ); | 1673 | selectFilterMenu->setItemEnabled( iii, false ); |
1674 | filter = fili.next(); | 1674 | filter = fili.next(); |
1675 | ++iii; | 1675 | ++iii; |
1676 | } | 1676 | } |
1677 | } | 1677 | } |
1678 | void MainWindow::selectFilter( int fil ) | 1678 | void MainWindow::selectFilter( int fil ) |
1679 | { | 1679 | { |
1680 | if ( fil == 0 ) { | 1680 | if ( fil == 0 ) { |
1681 | mView->editFilters( ); | 1681 | mView->editFilters( ); |
1682 | } else if ( fil == 1 ){ | 1682 | } else if ( fil == 1 ){ |
1683 | mView->toggleFilerEnabled( ); | 1683 | mView->toggleFilerEnabled( ); |
1684 | } else { | 1684 | } else { |
1685 | mView->selectFilter( fil-2 ); | 1685 | mView->selectFilter( fil-2 ); |
1686 | } | 1686 | } |
1687 | } | 1687 | } |
1688 | void MainWindow::configureToolBar( int item ) | 1688 | void MainWindow::configureToolBar( int item ) |
1689 | { | 1689 | { |
1690 | 1690 | ||
1691 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1691 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1692 | KOPrefs *p = KOPrefs::instance(); | 1692 | KOPrefs *p = KOPrefs::instance(); |
1693 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1693 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1694 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1694 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1695 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1695 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1696 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1696 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1697 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1697 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1698 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1698 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1699 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1699 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1700 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1700 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1701 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1701 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1702 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1702 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1703 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1703 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1704 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1704 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1705 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1705 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1706 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1706 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1707 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1707 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1708 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1708 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1709 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1709 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1710 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1710 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1711 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1711 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1712 | // initActions(); | 1712 | // initActions(); |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | void MainWindow::setCaptionToDates() | 1715 | void MainWindow::setCaptionToDates() |
1716 | { | 1716 | { |
1717 | QString selDates; | 1717 | QString selDates; |
1718 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1718 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1719 | if (mView->startDate() < mView->endDate() ) | 1719 | if (mView->startDate() < mView->endDate() ) |
1720 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1720 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1721 | else { | 1721 | else { |
1722 | QString addString; | 1722 | QString addString; |
1723 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) | 1723 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) |
1724 | addString = i18n("Today"); | 1724 | addString = i18n("Today"); |
1725 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) | 1725 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) |
1726 | addString = i18n("Tomorrow"); | 1726 | addString = i18n("Tomorrow"); |
1727 | if ( !addString.isEmpty() ) | 1727 | if ( !addString.isEmpty() ) |
1728 | selDates = addString+", "+selDates ; | 1728 | selDates = addString+", "+selDates ; |
1729 | } | 1729 | } |
1730 | setCaption( i18n("Dates: ") + selDates ); | 1730 | setCaption( i18n("Dates: ") + selDates ); |
1731 | 1731 | ||
1732 | } | 1732 | } |
1733 | void MainWindow::showConfigureAgenda( ) | 1733 | void MainWindow::showConfigureAgenda( ) |
1734 | { | 1734 | { |
1735 | int iii; | 1735 | int iii; |
1736 | for ( iii = 1;iii<= 10 ;++iii ){ | 1736 | for ( iii = 1;iii<= 10 ;++iii ){ |
1737 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 1737 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
1738 | } | 1738 | } |
1739 | configureAgendaMenu->setItemChecked( KOPrefs::instance()->mHourSize, true ); | 1739 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
1740 | } | 1740 | } |
1741 | void MainWindow::configureAgenda( int item ) | 1741 | void MainWindow::configureAgenda( int item ) |
1742 | { | 1742 | { |
1743 | if ( KOPrefs::instance()->mHourSize == item ) | 1743 | if ( KOPrefs::instance()->mHourSize == item ) |
1744 | return; | 1744 | return; |
1745 | KOPrefs::instance()->mHourSize=item; | 1745 | KOPrefs::instance()->mHourSize=item; |
1746 | mView->viewManager()->agendaView()->updateConfig(); | 1746 | mView->viewManager()->agendaView()->updateConfig(); |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | void MainWindow::saveCalendar() | 1749 | void MainWindow::saveCalendar() |
1750 | { | 1750 | { |
1751 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1751 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1752 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1752 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1753 | 1753 | ||
1754 | if ( fn == "" ) | 1754 | if ( fn == "" ) |
1755 | return; | 1755 | return; |
1756 | QFileInfo info; | 1756 | QFileInfo info; |
1757 | info.setFile( fn ); | 1757 | info.setFile( fn ); |
1758 | QString mes; | 1758 | QString mes; |
1759 | bool createbup = true; | 1759 | bool createbup = true; |
1760 | if ( info. exists() ) { | 1760 | if ( info. exists() ) { |
1761 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1761 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1762 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1762 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1763 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1763 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1764 | 0, 1 ); | 1764 | 0, 1 ); |
1765 | if ( result != 0 ) { | 1765 | if ( result != 0 ) { |
1766 | createbup = false; | 1766 | createbup = false; |
1767 | } | 1767 | } |
1768 | } | 1768 | } |
1769 | if ( createbup ) { | 1769 | if ( createbup ) { |
1770 | mView->saveCalendar( fn ); | 1770 | mView->saveCalendar( fn ); |
1771 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1771 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1772 | KOPrefs::instance()->mLastSaveFile = fn; | 1772 | KOPrefs::instance()->mLastSaveFile = fn; |
1773 | setCaption(mes); | 1773 | setCaption(mes); |
1774 | } | 1774 | } |
1775 | } | 1775 | } |
1776 | void MainWindow::loadCalendar() | 1776 | void MainWindow::loadCalendar() |
1777 | { | 1777 | { |
1778 | 1778 | ||
1779 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1779 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1780 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1780 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1781 | 1781 | ||
1782 | if ( fn == "" ) | 1782 | if ( fn == "" ) |
1783 | return; | 1783 | return; |
1784 | QFileInfo info; | 1784 | QFileInfo info; |
1785 | info.setFile( fn ); | 1785 | info.setFile( fn ); |
1786 | QString mess; | 1786 | QString mess; |
1787 | bool loadbup = true; | 1787 | bool loadbup = true; |
1788 | if ( info. exists() ) { | 1788 | if ( info. exists() ) { |
1789 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1789 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1790 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1790 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1791 | mess, | 1791 | mess, |
1792 | i18n("Load!"), i18n("Cancel"), 0, | 1792 | i18n("Load!"), i18n("Cancel"), 0, |
1793 | 0, 1 ); | 1793 | 0, 1 ); |
1794 | if ( result != 0 ) { | 1794 | if ( result != 0 ) { |
1795 | loadbup = false; | 1795 | loadbup = false; |
1796 | } | 1796 | } |
1797 | } else { | 1797 | } else { |
1798 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1798 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1799 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1799 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1800 | 0, 1 ); | 1800 | 0, 1 ); |
1801 | 1801 | ||
1802 | return; | 1802 | return; |
1803 | } | 1803 | } |
1804 | if ( loadbup ) { | 1804 | if ( loadbup ) { |
1805 | mView->openCalendar( fn ); | 1805 | mView->openCalendar( fn ); |
1806 | KOPrefs::instance()->mLastLoadFile = fn; | 1806 | KOPrefs::instance()->mLastLoadFile = fn; |
1807 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1807 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1808 | setCaption(mess); | 1808 | setCaption(mess); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | } | 1811 | } |
1812 | void MainWindow::quickImportIcal() | 1812 | void MainWindow::quickImportIcal() |
1813 | { | 1813 | { |
1814 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1814 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1815 | } | 1815 | } |
1816 | void MainWindow::importFile( QString fn, bool quick ) | 1816 | void MainWindow::importFile( QString fn, bool quick ) |
1817 | { | 1817 | { |
1818 | QFileInfo info; | 1818 | QFileInfo info; |
1819 | info.setFile( fn ); | 1819 | info.setFile( fn ); |
1820 | QString mess; | 1820 | QString mess; |
1821 | bool loadbup = true; | 1821 | bool loadbup = true; |
1822 | if ( !info. exists() ) { | 1822 | if ( !info. exists() ) { |
1823 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1823 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1824 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1824 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1825 | mess ); | 1825 | mess ); |
1826 | return; | 1826 | return; |
1827 | } | 1827 | } |
1828 | int result = 0; | 1828 | int result = 0; |
1829 | if ( !quick ) { | 1829 | if ( !quick ) { |
1830 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1830 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1831 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1831 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1832 | mess, | 1832 | mess, |
1833 | "Import", "Cancel", 0, | 1833 | "Import", "Cancel", 0, |
1834 | 0, 1 ); | 1834 | 0, 1 ); |
1835 | } | 1835 | } |
1836 | if ( result == 0 ) { | 1836 | if ( result == 0 ) { |
1837 | if ( mView->openCalendar( fn, true )) { | 1837 | if ( mView->openCalendar( fn, true )) { |
1838 | KOPrefs::instance()->mLastImportFile = fn; | 1838 | KOPrefs::instance()->mLastImportFile = fn; |
1839 | setCaption(i18n("Imported file successfully")); | 1839 | setCaption(i18n("Imported file successfully")); |
1840 | } else { | 1840 | } else { |
1841 | setCaption(i18n("Error importing file")); | 1841 | setCaption(i18n("Error importing file")); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | 1845 | ||
1846 | void MainWindow::importIcal() | 1846 | void MainWindow::importIcal() |
1847 | { | 1847 | { |
1848 | 1848 | ||
1849 | QString fn =KOPrefs::instance()->mLastImportFile; | 1849 | QString fn =KOPrefs::instance()->mLastImportFile; |
1850 | 1850 | ||
1851 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1851 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1852 | if ( fn == "" ) | 1852 | if ( fn == "" ) |
1853 | return; | 1853 | return; |
1854 | importFile( fn, true ); | 1854 | importFile( fn, true ); |
1855 | 1855 | ||
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | void MainWindow::exportVCalendar() | 1858 | void MainWindow::exportVCalendar() |
1859 | { | 1859 | { |
1860 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1860 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1861 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1861 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1862 | if ( fn == "" ) | 1862 | if ( fn == "" ) |
1863 | return; | 1863 | return; |
1864 | QFileInfo info; | 1864 | QFileInfo info; |
1865 | info.setFile( fn ); | 1865 | info.setFile( fn ); |
1866 | QString mes; | 1866 | QString mes; |
1867 | bool createbup = true; | 1867 | bool createbup = true; |
1868 | if ( info. exists() ) { | 1868 | if ( info. exists() ) { |
1869 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1869 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1870 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1870 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1871 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1871 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1872 | 0, 1 ); | 1872 | 0, 1 ); |
1873 | if ( result != 0 ) { | 1873 | if ( result != 0 ) { |
1874 | createbup = false; | 1874 | createbup = false; |
1875 | } | 1875 | } |
1876 | } | 1876 | } |
1877 | if ( createbup ) { | 1877 | if ( createbup ) { |
1878 | if ( mView->exportVCalendar( fn ) ) { | 1878 | if ( mView->exportVCalendar( fn ) ) { |
1879 | KOPrefs::instance()->mLastVcalFile = fn; | 1879 | KOPrefs::instance()->mLastVcalFile = fn; |
1880 | if ( fn.length() > 20 ) | 1880 | if ( fn.length() > 20 ) |
1881 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1881 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1882 | else | 1882 | else |
1883 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1883 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1884 | setCaption(mes); | 1884 | setCaption(mes); |
1885 | } | 1885 | } |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | void MainWindow::syncFileRequest() | 1890 | void MainWindow::syncFileRequest() |
1891 | { | 1891 | { |
1892 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1892 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1893 | mSyncManager->slotSyncMenu( 999 ); | 1893 | mSyncManager->slotSyncMenu( 999 ); |
1894 | } | 1894 | } |
1895 | save(); | 1895 | save(); |
1896 | } | 1896 | } |
1897 | void MainWindow::getFile( bool success ) | 1897 | void MainWindow::getFile( bool success ) |
1898 | { | 1898 | { |
1899 | if ( ! success ) { | 1899 | if ( ! success ) { |
1900 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 1900 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1901 | return; | 1901 | return; |
1902 | } | 1902 | } |
1903 | mView->openCalendar( defaultFileName() ); | 1903 | mView->openCalendar( defaultFileName() ); |
1904 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1904 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1905 | mSyncManager->slotSyncMenu( 999 ); | 1905 | mSyncManager->slotSyncMenu( 999 ); |
1906 | } | 1906 | } |
1907 | setCaption( i18n("Pi-Sync successful!") ); | 1907 | setCaption( i18n("Pi-Sync successful!") ); |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | void MainWindow::printSel( ) | 1910 | void MainWindow::printSel( ) |
1911 | { | 1911 | { |
1912 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 1912 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
1913 | } | 1913 | } |
1914 | 1914 | ||
1915 | void MainWindow::printCal() | 1915 | void MainWindow::printCal() |
1916 | { | 1916 | { |
1917 | mView->print();//mCp->showDialog(); | 1917 | mView->print();//mCp->showDialog(); |
1918 | } | 1918 | } |
1919 | 1919 | ||