summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp4
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp4
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp4
-rw-r--r--korganizer/kotodoviewitem.cpp2
-rw-r--r--korganizer/kotodoviewitem.h2
-rw-r--r--korganizer/koviewmanager.cpp2
-rw-r--r--korganizer/searchdialog.cpp22
-rw-r--r--korganizer/timespanview.cpp2
-rw-r--r--libkcal/icalformatimpl.cpp6
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp10
-rw-r--r--microkde/kcalendarsystemgregorian.cpp8
11 files changed, 31 insertions, 35 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 6fcd73f..9d8c5ce 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -125,383 +125,383 @@ void AddresseeCardView::printMe()
125 return; 125 return;
126 QPainter p; 126 QPainter p;
127 p.begin ( &printer ); 127 p.begin ( &printer );
128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
129 float dx, dy; 129 float dx, dy;
130 int wid = (m.width() * 9)/10; 130 int wid = (m.width() * 9)/10;
131 dx = (float) wid/(float)contentsWidth (); 131 dx = (float) wid/(float)contentsWidth ();
132 dy = (float)(m.height()) / (float)contentsHeight (); 132 dy = (float)(m.height()) / (float)contentsHeight ();
133 float scale; 133 float scale;
134 // scale to fit the width or height of the paper 134 // scale to fit the width or height of the paper
135 if ( dx < dy ) 135 if ( dx < dy )
136 scale = dx; 136 scale = dx;
137 else 137 else
138 scale = dy; 138 scale = dy;
139 p.translate( m.width()/10,0 ); 139 p.translate( m.width()/10,0 );
140 p.scale( scale, scale ); 140 p.scale( scale, scale );
141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
142 p.end(); 142 p.end();
143 repaint(); 143 repaint();
144#endif 144#endif
145} 145}
146 146
147 147
148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
149{ 149{
150#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
151 if (QTextDrag::canDecode(e)) 151 if (QTextDrag::canDecode(e))
152 e->accept(); 152 e->accept();
153#else //KAB_EMBEDDED 153#else //KAB_EMBEDDED
154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
155#endif //KAB_EMBEDDED 155#endif //KAB_EMBEDDED
156} 156}
157 157
158void AddresseeCardView::dropEvent(QDropEvent *e) 158void AddresseeCardView::dropEvent(QDropEvent *e)
159{ 159{
160 emit addresseeDropped(e); 160 emit addresseeDropped(e);
161} 161}
162 162
163void AddresseeCardView::startDrag() 163void AddresseeCardView::startDrag()
164{ 164{
165 emit startAddresseeDrag(); 165 emit startAddresseeDrag();
166} 166}
167 167
168 168
169/////////////////////////////// 169///////////////////////////////
170// KAddressBookCardView 170// KAddressBookCardView
171 171
172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
173 QWidget *parent, const char *name ) 173 QWidget *parent, const char *name )
174 : KAddressBookView( ab, parent, name ) 174 : KAddressBookView( ab, parent, name )
175{ 175{
176 mShowEmptyFields = false; 176 mShowEmptyFields = false;
177 177
178 // Init the GUI 178 // Init the GUI
179 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 179 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
180 180
181 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 181 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
182 mCardView->setSelectionMode(CardView::Extended); 182 mCardView->setSelectionMode(CardView::Extended);
183 layout->addWidget(mCardView); 183 layout->addWidget(mCardView);
184 184
185 // Connect up the signals 185 // Connect up the signals
186 connect(mCardView, SIGNAL(executed(CardViewItem *)), 186 connect(mCardView, SIGNAL(executed(CardViewItem *)),
187 this, SLOT(addresseeExecuted(CardViewItem *))); 187 this, SLOT(addresseeExecuted(CardViewItem *)));
188 connect(mCardView, SIGNAL(selectionChanged()), 188 connect(mCardView, SIGNAL(selectionChanged()),
189 this, SLOT(addresseeSelected())); 189 this, SLOT(addresseeSelected()));
190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
191 this, SIGNAL(dropped(QDropEvent*))); 191 this, SIGNAL(dropped(QDropEvent*)));
192 connect(mCardView, SIGNAL(startAddresseeDrag()), 192 connect(mCardView, SIGNAL(startAddresseeDrag()),
193 this, SIGNAL(startDrag())); 193 this, SIGNAL(startDrag()));
194 connect(this, SIGNAL(printView()), 194 connect(this, SIGNAL(printView()),
195 mCardView , SLOT(printMe())); 195 mCardView , SLOT(printMe()));
196} 196}
197 197
198KAddressBookCardView::~KAddressBookCardView() 198KAddressBookCardView::~KAddressBookCardView()
199{ 199{
200} 200}
201void KAddressBookCardView::setFocusAV() 201void KAddressBookCardView::setFocusAV()
202{ 202{
203 if ( mCardView ) 203 if ( mCardView )
204 mCardView->setFocus(); 204 mCardView->setFocus();
205 205
206} 206}
207void KAddressBookCardView::scrollUP() 207void KAddressBookCardView::scrollUP()
208{ 208{
209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
210 QApplication::postEvent( mCardView, ev ); 210 QApplication::postEvent( mCardView, ev );
211 211
212} 212}
213void KAddressBookCardView::scrollDOWN() 213void KAddressBookCardView::scrollDOWN()
214{ 214{
215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
216 QApplication::postEvent( mCardView, ev ); 216 QApplication::postEvent( mCardView, ev );
217} 217}
218void KAddressBookCardView::readConfig(KConfig *config) 218void KAddressBookCardView::readConfig(KConfig *config)
219{ 219{
220 KAddressBookView::readConfig(config); 220 KAddressBookView::readConfig(config);
221 221
222 // costum colors? 222 // costum colors?
223 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 223 if ( config->readBoolEntry( "EnableCustomColors", false ) )
224 { 224 {
225 QPalette p( mCardView->palette() ); 225 QPalette p( mCardView->palette() );
226 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 226 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
228 c = p.color(QPalette::Normal, QColorGroup::Text ); 228 c = p.color(QPalette::Normal, QColorGroup::Text );
229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
230 c = p.color(QPalette::Normal, QColorGroup::Button ); 230 c = p.color(QPalette::Normal, QColorGroup::Button );
231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 232 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 234 c = p.color(QPalette::Normal, QColorGroup::Highlight );
235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
238 mCardView->viewport()->setPalette( p ); 238 mCardView->viewport()->setPalette( p );
239 } 239 }
240 else 240 else
241 { 241 {
242 // needed if turned off during a session. 242 // needed if turned off during a session.
243 mCardView->viewport()->setPalette( mCardView->palette() ); 243 mCardView->viewport()->setPalette( mCardView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 } 253 }
254 else 254 else
255 { 255 {
256 mCardView->setFont( f ); 256 mCardView->setFont( f );
257 f.setBold( true ); 257 f.setBold( true );
258 mCardView->setHeaderFont( f ); 258 mCardView->setHeaderFont( f );
259 } 259 }
260 260
261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
263 true)); 263 true));
264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
266 266
267 mCardView->setShowEmptyFields( mShowEmptyFields ); 267 mCardView->setShowEmptyFields( mShowEmptyFields );
268 268
269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
273 273
274#if 0 274#if 0
275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
277 this, SLOT(addresseeExecuted(CardViewItem *))); 277 this, SLOT(addresseeExecuted(CardViewItem *)));
278 278
279 if (KABPrefs::instance()->mHonorSingleClick) 279 if (KABPrefs::instance()->mHonorSingleClick)
280 connect(mCardView, SIGNAL(executed(CardViewItem *)), 280 connect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
282 else 282 else
283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
284 this, SLOT(addresseeExecuted(CardViewItem *))); 284 this, SLOT(addresseeExecuted(CardViewItem *)));
285#endif 285#endif
286 286
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 288 this, SLOT(addresseeExecuted(CardViewItem *)));
289} 289}
290 290
291void KAddressBookCardView::writeConfig( KConfig *config ) 291void KAddressBookCardView::writeConfig( KConfig *config )
292{ 292{
293 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 293 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
294 KAddressBookView::writeConfig( config ); 294 KAddressBookView::writeConfig( config );
295} 295}
296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
297{ 297{
298 mCardView->clear(); 298 mCardView->clear();
299 if ( s.isEmpty() || s == "*" ) { 299 if ( s.isEmpty() || s == "*" ) {
300 refresh(); 300 refresh();
301 return; 301 return;
302 } 302 }
303 QString pattern = s.lower()+"*"; 303 QString pattern = s.lower()+"*";
304 QRegExp re; 304 QRegExp re;
305 re.setWildcard(true); // most people understand these better. 305 re.setWildcard(true); // most people understand these better.
306 re.setCaseSensitive(false); 306 re.setCaseSensitive(false);
307 re.setPattern( pattern ); 307 re.setPattern( pattern );
308 if (!re.isValid()) 308 if (!re.isValid())
309 return; 309 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 310 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 311 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 312 KABC::Addressee::List::Iterator it;
313 if ( field ) { 313 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 316 continue;
317#if QT_VERSION >= 300 317#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) != -1) 318 if (re.search(field->value( *it ).lower()) != -1)
319#else 319#else
320 if (re.match(field->value( *it ).lower()) != -1) 320 if (re.match(field->value( *it ).lower()) != -1)
321#endif 321#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 322 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 323 addressBook(), *it, mCardView);
324 324
325 } 325 }
326 } else { 326 } else {
327 KABC::Field::List fieldList = allFields(); 327 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 328 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 331 continue;
332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
333#if QT_VERSION >= 300 333#if QT_VERSION >= 0x030000
334 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 334 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
335#else 335#else
336 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 336 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
337#endif 337#endif
338 { 338 {
339 new AddresseeCardViewItem(fields(), mShowEmptyFields, 339 new AddresseeCardViewItem(fields(), mShowEmptyFields,
340 addressBook(), *it, mCardView); 340 addressBook(), *it, mCardView);
341 break; 341 break;
342 } 342 }
343 } 343 }
344 } 344 }
345 } 345 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 346 mCardView->viewport()->setUpdatesEnabled( true );
347 mCardView->viewport()->update(); 347 mCardView->viewport()->update();
348 if ( mCardView->firstItem() ) { 348 if ( mCardView->firstItem() ) {
349 mCardView->setCurrentItem ( mCardView->firstItem() ); 349 mCardView->setCurrentItem ( mCardView->firstItem() );
350 mCardView->setSelected ( mCardView->firstItem() , true ); 350 mCardView->setSelected ( mCardView->firstItem() , true );
351 } 351 }
352 else 352 else
353 emit selected(QString::null); 353 emit selected(QString::null);
354} 354}
355QStringList KAddressBookCardView::selectedUids() 355QStringList KAddressBookCardView::selectedUids()
356{ 356{
357 QStringList uidList; 357 QStringList uidList;
358 CardViewItem *item; 358 CardViewItem *item;
359 AddresseeCardViewItem *aItem; 359 AddresseeCardViewItem *aItem;
360 360
361 for (item = mCardView->firstItem(); item; item = item->nextItem()) 361 for (item = mCardView->firstItem(); item; item = item->nextItem())
362 { 362 {
363 if (item->isSelected()) 363 if (item->isSelected())
364 { 364 {
365#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
366 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 366 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
367#else //KAB_EMBEDDED 367#else //KAB_EMBEDDED
368 aItem = (AddresseeCardViewItem*)(item); 368 aItem = (AddresseeCardViewItem*)(item);
369#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
370 if (aItem) 370 if (aItem)
371 uidList << aItem->addressee().uid(); 371 uidList << aItem->addressee().uid();
372 } 372 }
373 } 373 }
374 374
375 return uidList; 375 return uidList;
376} 376}
377 377
378void KAddressBookCardView::refresh(QString uid) 378void KAddressBookCardView::refresh(QString uid)
379{ 379{
380 CardViewItem *item; 380 CardViewItem *item;
381 AddresseeCardViewItem *aItem; 381 AddresseeCardViewItem *aItem;
382 382
383 if (uid.isNull()) 383 if (uid.isNull())
384 { 384 {
385 // Rebuild the view 385 // Rebuild the view
386 mCardView->viewport()->setUpdatesEnabled( false ); 386 mCardView->viewport()->setUpdatesEnabled( false );
387 mCardView->clear(); 387 mCardView->clear();
388 388
389 KABC::Addressee::List addresseeList = addressees(); 389 KABC::Addressee::List addresseeList = addressees();
390 KABC::Addressee::List::Iterator iter; 390 KABC::Addressee::List::Iterator iter;
391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
392 { 392 {
393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
394 continue; 394 continue;
395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
396 addressBook(), *iter, mCardView); 396 addressBook(), *iter, mCardView);
397 } 397 }
398 mCardView->viewport()->setUpdatesEnabled( true ); 398 mCardView->viewport()->setUpdatesEnabled( true );
399 mCardView->viewport()->update(); 399 mCardView->viewport()->update();
400 400
401 // by default nothing is selected 401 // by default nothing is selected
402 emit selected(QString::null); 402 emit selected(QString::null);
403 } 403 }
404 else 404 else
405 { 405 {
406 // Try to find the one to refresh 406 // Try to find the one to refresh
407 bool found = false; 407 bool found = false;
408 for (item = mCardView->firstItem(); item && !found; 408 for (item = mCardView->firstItem(); item && !found;
409 item = item->nextItem()) 409 item = item->nextItem())
410 { 410 {
411#ifndef KAB_EMBEDDED 411#ifndef KAB_EMBEDDED
412 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 412 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
413#else //KAB_EMBEDDED 413#else //KAB_EMBEDDED
414 aItem = (AddresseeCardViewItem*)(item); 414 aItem = (AddresseeCardViewItem*)(item);
415#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
416 416
417 if ((aItem) && (aItem->addressee().uid() == uid)) 417 if ((aItem) && (aItem->addressee().uid() == uid))
418 { 418 {
419 aItem->refresh(); 419 aItem->refresh();
420 found = true; 420 found = true;
421 } 421 }
422 } 422 }
423 } 423 }
424} 424}
425 425
426void KAddressBookCardView::setSelected(QString uid, bool selected) 426void KAddressBookCardView::setSelected(QString uid, bool selected)
427{ 427{
428 CardViewItem *item; 428 CardViewItem *item;
429 AddresseeCardViewItem *aItem; 429 AddresseeCardViewItem *aItem;
430 430
431 if (uid.isNull()) 431 if (uid.isNull())
432 { 432 {
433 mCardView->selectAll(selected); 433 mCardView->selectAll(selected);
434 } 434 }
435 else 435 else
436 { 436 {
437 bool found = false; 437 bool found = false;
438 for (item = mCardView->firstItem(); item && !found; 438 for (item = mCardView->firstItem(); item && !found;
439 item = item->nextItem()) 439 item = item->nextItem())
440 { 440 {
441#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
442 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 442 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
443#else //KAB_EMBEDDED 443#else //KAB_EMBEDDED
444 aItem = (AddresseeCardViewItem*)(item); 444 aItem = (AddresseeCardViewItem*)(item);
445#endif //KAB_EMBEDDED 445#endif //KAB_EMBEDDED
446 446
447 if ((aItem) && (aItem->addressee().uid() == uid)) 447 if ((aItem) && (aItem->addressee().uid() == uid))
448 { 448 {
449 mCardView->setSelected(aItem, selected); 449 mCardView->setSelected(aItem, selected);
450 mCardView->ensureItemVisible(item); 450 mCardView->ensureItemVisible(item);
451 found = true; 451 found = true;
452 } 452 }
453 } 453 }
454 } 454 }
455} 455}
456 456
457//US added an additional method without parameter 457//US added an additional method without parameter
458void KAddressBookCardView::setSelected() 458void KAddressBookCardView::setSelected()
459{ 459{
460 setSelected(QString::null, true); 460 setSelected(QString::null, true);
461} 461}
462 462
463void KAddressBookCardView::addresseeExecuted(CardViewItem *item) 463void KAddressBookCardView::addresseeExecuted(CardViewItem *item)
464{ 464{
465#ifndef KAB_EMBEDDED 465#ifndef KAB_EMBEDDED
466 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); 466 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item);
467#else //KAB_EMBEDDED 467#else //KAB_EMBEDDED
468 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); 468 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item);
469#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
470 if (aItem) 470 if (aItem)
471 { 471 {
472 //kdDebug()<<"... even has a valid item:)"<<endl; 472 //kdDebug()<<"... even has a valid item:)"<<endl;
473 emit executed(aItem->addressee().uid()); 473 emit executed(aItem->addressee().uid());
474 } 474 }
475} 475}
476 476
477void KAddressBookCardView::addresseeSelected() 477void KAddressBookCardView::addresseeSelected()
478{ 478{
479 CardViewItem *item; 479 CardViewItem *item;
480 AddresseeCardViewItem *aItem; 480 AddresseeCardViewItem *aItem;
481 481
482 bool found = false; 482 bool found = false;
483 for (item = mCardView->firstItem(); item && !found; 483 for (item = mCardView->firstItem(); item && !found;
484 item = item->nextItem()) 484 item = item->nextItem())
485 { 485 {
486 if (item->isSelected()) 486 if (item->isSelected())
487 { 487 {
488#ifndef KAB_EMBEDDED 488#ifndef KAB_EMBEDDED
489 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 489 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
490#else //KAB_EMBEDDED 490#else //KAB_EMBEDDED
491 aItem = (AddresseeCardViewItem*)(item); 491 aItem = (AddresseeCardViewItem*)(item);
492#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
493 if ( aItem ) 493 if ( aItem )
494 { 494 {
495 emit selected(aItem->addressee().uid()); 495 emit selected(aItem->addressee().uid());
496 found = true; 496 found = true;
497 } 497 }
498 } 498 }
499 } 499 }
500 500
501 if (!found) 501 if (!found)
502 emit selected(QString::null); 502 emit selected(QString::null);
503 503
504} 504}
505#ifndef KAB_EMBEDDED 505#ifndef KAB_EMBEDDED
506#include "kaddressbookcardview.moc" 506#include "kaddressbookcardview.moc"
507#endif //KAB_EMBEDDED 507#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index ef0a23a..fb53215 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -83,374 +83,374 @@ AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
83 setGridX( 100 ); 83 setGridX( 100 );
84 setItemsMovable(false); 84 setItemsMovable(false);
85 setSorting(true, true); 85 setSorting(true, true);
86 86
87 87
88//US ??? setMode( KIconView::Select ); 88//US ??? setMode( KIconView::Select );
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 91
92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95} 95}
96 96
97AddresseeIconView::~AddresseeIconView() 97AddresseeIconView::~AddresseeIconView()
98{ 98{
99} 99}
100 100
101 101
102void AddresseeIconView::itemDropped(QDropEvent *e, 102void AddresseeIconView::itemDropped(QDropEvent *e,
103 const QValueList<QIconDragItem> &) 103 const QValueList<QIconDragItem> &)
104{ 104{
105 emit addresseeDropped(e); 105 emit addresseeDropped(e);
106} 106}
107 107
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *AddresseeIconView::dragObject()
109{ 109{
110 emit startAddresseeDrag(); 110 emit startAddresseeDrag();
111 111
112 // We never want IconView to start the drag 112 // We never want IconView to start the drag
113 return 0; 113 return 0;
114} 114}
115//////////////////////////////// 115////////////////////////////////
116// AddresseeIconViewItem (internal class) 116// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class AddresseeIconViewItem : public QIconViewItem
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
122{ 122{
123 public: 123 public:
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 125 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 126 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 127 QIconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 129#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 130 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 131 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 132 QIconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 { 135 {
136 if ( mFields.isEmpty() ) { 136 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 137 mFields = KABC::Field::defaultFields();
138 } 138 }
139 refresh(); 139 refresh();
140 } 140 }
141 141
142 const KABC::Addressee &addressee() const { return mAddressee; } 142 const KABC::Addressee &addressee() const { return mAddressee; }
143 143
144 void refresh() 144 void refresh()
145 { 145 {
146 // Update our addressee, since it may have changed elsewhere 146 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 147 mAddressee = mDocument->findByUid(mAddressee.uid());
148 148
149 if (!mAddressee.isEmpty()) 149 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 150 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 151
152 QPixmap icon; 152 QPixmap icon;
153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) );
154 KABC::Picture pic = mAddressee.photo(); 154 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 155 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 156 pic = mAddressee.logo();
157 157
158 if ( pic.isIntern() && !pic.data().isNull() ) { 158 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 159 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 161 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 162 icon = img.scaleWidth( 32 );
163 else 163 else
164 icon = img.scaleHeight( 32 ); 164 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 165#else //KAB_EMBEDDED
166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
167 icon.convertFromImage(img.smoothScale(32, 32)); 167 icon.convertFromImage(img.smoothScale(32, 32));
168#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
169 169
170 } else 170 } else
171 icon = defaultIcon; 171 icon = defaultIcon;
172 172
173 setPixmap( icon ); 173 setPixmap( icon );
174 } 174 }
175 175
176 private: 176 private:
177 KABC::Field::List mFields; 177 KABC::Field::List mFields;
178 KABC::AddressBook *mDocument; 178 KABC::AddressBook *mDocument;
179 KABC::Addressee mAddressee; 179 KABC::Addressee mAddressee;
180}; 180};
181 181
182/////////////////////////////// 182///////////////////////////////
183// KAddressBookView 183// KAddressBookView
184 184
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
186 QWidget *parent, const char *name) 186 QWidget *parent, const char *name)
187 : KAddressBookView( ab, parent, name ) 187 : KAddressBookView( ab, parent, name )
188{ 188{
189 // Init the GUI 189 // Init the GUI
190 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 190 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
191 191
192 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 192 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
193 layout->addWidget(mIconView); 193 layout->addWidget(mIconView);
194 194
195 // Connect up the signals 195 // Connect up the signals
196 196
197//US method executed is part of KIconView 197//US method executed is part of KIconView
198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
199//US this, SLOT(addresseeExecuted(QIconViewItem *))); 199//US this, SLOT(addresseeExecuted(QIconViewItem *)));
200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
201 this, SLOT(addresseeExecuted(QIconViewItem *))); 201 this, SLOT(addresseeExecuted(QIconViewItem *)));
202 202
203 connect(mIconView, SIGNAL(selectionChanged()), 203 connect(mIconView, SIGNAL(selectionChanged()),
204 this, SLOT(addresseeSelected())); 204 this, SLOT(addresseeSelected()));
205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
206 this, SIGNAL(dropped(QDropEvent*))); 206 this, SIGNAL(dropped(QDropEvent*)));
207 connect(mIconView, SIGNAL(startAddresseeDrag()), 207 connect(mIconView, SIGNAL(startAddresseeDrag()),
208 this, SIGNAL(startDrag())); 208 this, SIGNAL(startDrag()));
209} 209}
210 210
211KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
212{ 212{
213} 213}
214void KAddressBookIconView::setFocusAV() 214void KAddressBookIconView::setFocusAV()
215{ 215{
216 if ( mIconView ) 216 if ( mIconView )
217 mIconView->setFocus(); 217 mIconView->setFocus();
218} 218}
219 219
220 220
221void KAddressBookIconView::scrollUP() 221void KAddressBookIconView::scrollUP()
222{ 222{
223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
224 QApplication::postEvent( mIconView, ev ); 224 QApplication::postEvent( mIconView, ev );
225} 225}
226void KAddressBookIconView::scrollDOWN() 226void KAddressBookIconView::scrollDOWN()
227{ 227{
228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
229 QApplication::postEvent( mIconView, ev ); 229 QApplication::postEvent( mIconView, ev );
230} 230}
231void KAddressBookIconView::readConfig(KConfig *config) 231void KAddressBookIconView::readConfig(KConfig *config)
232{ 232{
233 KAddressBookView::readConfig(config); 233 KAddressBookView::readConfig(config);
234 234
235//US method executed is part of KIconView 235//US method executed is part of KIconView
236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
237//US this, SLOT(addresseeExecuted(QIconViewItem *))); 237//US this, SLOT(addresseeExecuted(QIconViewItem *)));
238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 240
241//US method executed is part of KIconView. Use selectionChanged instead 241//US method executed is part of KIconView. Use selectionChanged instead
242/*US 242/*US
243 if (KABPrefs::instance()->mHonorSingleClick) 243 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 244 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 else 246 else
247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
248 this, SLOT(addresseeExecuted(QIconViewItem *))); 248 this, SLOT(addresseeExecuted(QIconViewItem *)));
249*/ 249*/
250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
251 this, SLOT(addresseeExecuted(QIconViewItem *))); 251 this, SLOT(addresseeExecuted(QIconViewItem *)));
252 252
253} 253}
254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255{ 255{
256 mIconView->clear(); 256 mIconView->clear();
257 mIconList.clear(); 257 mIconList.clear();
258 if ( s.isEmpty() || s == "*" ) { 258 if ( s.isEmpty() || s == "*" ) {
259 refresh(); 259 refresh();
260 return; 260 return;
261 } 261 }
262 QString pattern = s.lower()+"*"; 262 QString pattern = s.lower()+"*";
263 QRegExp re; 263 QRegExp re;
264 re.setWildcard(true); // most people understand these better. 264 re.setWildcard(true); // most people understand these better.
265 re.setCaseSensitive(false); 265 re.setCaseSensitive(false);
266 re.setPattern( pattern ); 266 re.setPattern( pattern );
267 if (!re.isValid()) 267 if (!re.isValid())
268 return; 268 return;
269 KABC::Addressee::List addresseeList = addressees(); 269 KABC::Addressee::List addresseeList = addressees();
270 KABC::Addressee::List::Iterator it; 270 KABC::Addressee::List::Iterator it;
271 if ( field ) { 271 if ( field ) {
272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
273 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 273 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
274 continue; 274 continue;
275#if QT_VERSION >= 300 275#if QT_VERSION >= 0x030000
276 if (re.search(field->value( *it ).lower()) != -1) 276 if (re.search(field->value( *it ).lower()) != -1)
277#else 277#else
278 if (re.match(field->value( *it ).lower()) != -1) 278 if (re.match(field->value( *it ).lower()) != -1)
279#endif 279#endif
280 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 280 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
281 281
282 282
283 } 283 }
284 } else { 284 } else {
285 KABC::Field::List fieldList = allFields(); 285 KABC::Field::List fieldList = allFields();
286 KABC::Field::List::ConstIterator fieldIt; 286 KABC::Field::List::ConstIterator fieldIt;
287 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 287 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
288 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 288 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
289 continue; 289 continue;
290 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 290 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
291#if QT_VERSION >= 300 291#if QT_VERSION >= 0x030000
292 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 292 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
293#else 293#else
294 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 294 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
295#endif 295#endif
296 { 296 {
297 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 297 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
298 break; 298 break;
299 } 299 }
300 } 300 }
301 } 301 }
302 } 302 }
303 mIconView->arrangeItemsInGrid( true ); 303 mIconView->arrangeItemsInGrid( true );
304 if ( mIconView->firstItem() ) { 304 if ( mIconView->firstItem() ) {
305 mIconView->setCurrentItem ( mIconView->firstItem() ); 305 mIconView->setCurrentItem ( mIconView->firstItem() );
306 mIconView->setSelected ( mIconView->firstItem() , true ); 306 mIconView->setSelected ( mIconView->firstItem() , true );
307 } 307 }
308 else 308 else
309 emit selected(QString::null); 309 emit selected(QString::null);
310} 310}
311QStringList KAddressBookIconView::selectedUids() 311QStringList KAddressBookIconView::selectedUids()
312{ 312{
313 QStringList uidList; 313 QStringList uidList;
314 QIconViewItem *item; 314 QIconViewItem *item;
315 AddresseeIconViewItem *aItem; 315 AddresseeIconViewItem *aItem;
316 316
317 for (item = mIconView->firstItem(); item; item = item->nextItem()) 317 for (item = mIconView->firstItem(); item; item = item->nextItem())
318 { 318 {
319 if (item->isSelected()) 319 if (item->isSelected())
320 { 320 {
321#ifndef KAB_EMBEDDED 321#ifndef KAB_EMBEDDED
322 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 322 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
323#else //KAB_EMBEDDED 323#else //KAB_EMBEDDED
324 aItem = (AddresseeIconViewItem*)(item); 324 aItem = (AddresseeIconViewItem*)(item);
325#endif //KAB_EMBEDDED 325#endif //KAB_EMBEDDED
326 if (aItem) 326 if (aItem)
327 uidList << aItem->addressee().uid(); 327 uidList << aItem->addressee().uid();
328 } 328 }
329 } 329 }
330 330
331 return uidList; 331 return uidList;
332} 332}
333 333
334void KAddressBookIconView::refresh(QString uid) 334void KAddressBookIconView::refresh(QString uid)
335{ 335{
336 QIconViewItem *item; 336 QIconViewItem *item;
337 AddresseeIconViewItem *aItem; 337 AddresseeIconViewItem *aItem;
338 338
339 if ( uid.isNull() ) { 339 if ( uid.isNull() ) {
340 // Rebuild the view 340 // Rebuild the view
341 mIconView->clear(); 341 mIconView->clear();
342 mIconList.clear(); 342 mIconList.clear();
343 343
344 KABC::Addressee::List addresseeList = addressees(); 344 KABC::Addressee::List addresseeList = addressees();
345 KABC::Addressee::List::Iterator iter; 345 KABC::Addressee::List::Iterator iter;
346 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 346 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
347 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 347 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
348 continue; 348 continue;
349 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 349 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
350 } 350 }
351 351
352 mIconView->arrangeItemsInGrid( true ); 352 mIconView->arrangeItemsInGrid( true );
353 353
354 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 354 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
355 { 355 {
356#ifndef KAB_EMBEDDED 356#ifndef KAB_EMBEDDED
357 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 357 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
358#else //KAB_EMBEDDED 358#else //KAB_EMBEDDED
359 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 359 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
360#endif //KAB_EMBEDDED 360#endif //KAB_EMBEDDED
361 mIconList.append( aivi ); 361 mIconList.append( aivi );
362 } 362 }
363 363
364 } else { 364 } else {
365 // Try to find the one to refresh 365 // Try to find the one to refresh
366 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 366 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
367#ifndef KAB_EMBEDDED 367#ifndef KAB_EMBEDDED
368 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 368 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
369#else //KAB_EMBEDDED 369#else //KAB_EMBEDDED
370 aItem = (AddresseeIconViewItem*)(item); 370 aItem = (AddresseeIconViewItem*)(item);
371#endif //KAB_EMBEDDED 371#endif //KAB_EMBEDDED
372 if ((aItem) && (aItem->addressee().uid() == uid)) { 372 if ((aItem) && (aItem->addressee().uid() == uid)) {
373 aItem->refresh(); 373 aItem->refresh();
374 mIconView->arrangeItemsInGrid( true ); 374 mIconView->arrangeItemsInGrid( true );
375 return; 375 return;
376 } 376 }
377 } 377 }
378 refresh( QString::null ); 378 refresh( QString::null );
379 } 379 }
380} 380}
381 381
382void KAddressBookIconView::setSelected(QString uid, bool selected) 382void KAddressBookIconView::setSelected(QString uid, bool selected)
383{ 383{
384 QIconViewItem *item; 384 QIconViewItem *item;
385 AddresseeIconViewItem *aItem; 385 AddresseeIconViewItem *aItem;
386 386
387 if (uid.isNull()) 387 if (uid.isNull())
388 { 388 {
389 mIconView->selectAll(selected); 389 mIconView->selectAll(selected);
390 } 390 }
391 else 391 else
392 { 392 {
393 bool found = false; 393 bool found = false;
394 for (item = mIconView->firstItem(); item && !found; 394 for (item = mIconView->firstItem(); item && !found;
395 item = item->nextItem()) 395 item = item->nextItem())
396 { 396 {
397#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
398 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 398 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
399#else //KAB_EMBEDDED 399#else //KAB_EMBEDDED
400 aItem = (AddresseeIconViewItem*)(item); 400 aItem = (AddresseeIconViewItem*)(item);
401#endif //KAB_EMBEDDED 401#endif //KAB_EMBEDDED
402 402
403 if ((aItem) && (aItem->addressee().uid() == uid)) 403 if ((aItem) && (aItem->addressee().uid() == uid))
404 { 404 {
405 mIconView->setSelected(aItem, selected); 405 mIconView->setSelected(aItem, selected);
406 mIconView->ensureItemVisible( aItem ); 406 mIconView->ensureItemVisible( aItem );
407 found = true; 407 found = true;
408 } 408 }
409 } 409 }
410 } 410 }
411} 411}
412 412
413void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 413void KAddressBookIconView::addresseeExecuted(QIconViewItem *item)
414{ 414{
415#ifndef KAB_EMBEDDED 415#ifndef KAB_EMBEDDED
416 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); 416 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item);
417#else //KAB_EMBEDDED 417#else //KAB_EMBEDDED
418 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); 418 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item);
419#endif //KAB_EMBEDDED 419#endif //KAB_EMBEDDED
420 420
421 if (aItem) { 421 if (aItem) {
422 emit executed(aItem->addressee().uid()); 422 emit executed(aItem->addressee().uid());
423 } 423 }
424} 424}
425 425
426void KAddressBookIconView::addresseeSelected() 426void KAddressBookIconView::addresseeSelected()
427{ 427{
428 QIconViewItem *item; 428 QIconViewItem *item;
429 AddresseeIconViewItem *aItem; 429 AddresseeIconViewItem *aItem;
430 430
431 bool found = false; 431 bool found = false;
432 for (item = mIconView->firstItem(); item && !found; 432 for (item = mIconView->firstItem(); item && !found;
433 item = item->nextItem()) 433 item = item->nextItem())
434 { 434 {
435 if (item->isSelected()) 435 if (item->isSelected())
436 { 436 {
437#ifndef KAB_EMBEDDED 437#ifndef KAB_EMBEDDED
438 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 438 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
439#else //KAB_EMBEDDED 439#else //KAB_EMBEDDED
440 aItem = (AddresseeIconViewItem*)(item); 440 aItem = (AddresseeIconViewItem*)(item);
441#endif //KAB_EMBEDDED 441#endif //KAB_EMBEDDED
442 if (aItem) 442 if (aItem)
443 { 443 {
444 emit selected(aItem->addressee().uid()); 444 emit selected(aItem->addressee().uid());
445 found = true; 445 found = true;
446 } 446 }
447 } 447 }
448 } 448 }
449 449
450 if (!found) 450 if (!found)
451 emit selected(QString::null); 451 emit selected(QString::null);
452} 452}
453 453
454#ifndef KAB_EMBEDDED 454#ifndef KAB_EMBEDDED
455#include "kaddressbookiconview.moc" 455#include "kaddressbookiconview.moc"
456#endif //KAB_EMBEDDED 456#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 7022dcb..69802a4 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,366 +1,366 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <qdragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
39 39
40 40
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV() 54void KAddressBookTableView::setFocusAV()
55{ 55{
56 if ( mListView ) 56 if ( mListView )
57 mListView->setFocus(); 57 mListView->setFocus();
58 58
59} 59}
60void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
61{ 61{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
64} 64}
65void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
66{ 66{
67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
68 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
69} 69}
70void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
71{ 71{
72 if (mListView) 72 if (mListView)
73 { 73 {
74 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
75 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
76 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
79 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
81 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 84
85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
86 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
87 delete mListView; 87 delete mListView;
88 } 88 }
89 89
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
91 91
92 connect(this, SIGNAL(printView()), 92 connect(this, SIGNAL(printView()),
93 mListView , SLOT(printMe())); 93 mListView , SLOT(printMe()));
94 //US set singleClick manually, because it is no global configparameter in embedded space 94 //US set singleClick manually, because it is no global configparameter in embedded space
95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
96 96
97 // Add the columns 97 // Add the columns
98 KABC::Field::List fieldList = fields(); 98 KABC::Field::List fieldList = fields();
99 KABC::Field::List::ConstIterator it; 99 KABC::Field::List::ConstIterator it;
100 100
101 int c = 0; 101 int c = 0;
102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
103 mListView->addColumn( (*it)->label() ); 103 mListView->addColumn( (*it)->label() );
104 mListView->setColumnWidthMode(c++, QListView::Manual); 104 mListView->setColumnWidthMode(c++, QListView::Manual);
105//US 105//US
106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
107 } 107 }
108 108
109 connect(mListView, SIGNAL(selectionChanged()), 109 connect(mListView, SIGNAL(selectionChanged()),
110 this, SLOT(addresseeSelected())); 110 this, SLOT(addresseeSelected()));
111 connect(mListView, SIGNAL(startAddresseeDrag()), this, 111 connect(mListView, SIGNAL(startAddresseeDrag()), this,
112 SIGNAL(startDrag())); 112 SIGNAL(startDrag()));
113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
114 SIGNAL(dropped(QDropEvent*))); 114 SIGNAL(dropped(QDropEvent*)));
115 115
116 if (KABPrefs::instance()->mHonorSingleClick) { 116 if (KABPrefs::instance()->mHonorSingleClick) {
117 // qDebug("KAddressBookTableView::reconstructListView single"); 117 // qDebug("KAddressBookTableView::reconstructListView single");
118 connect(mListView, SIGNAL(executed(QListViewItem*)), 118 connect(mListView, SIGNAL(executed(QListViewItem*)),
119 this, SLOT(addresseeExecuted(QListViewItem*))); 119 this, SLOT(addresseeExecuted(QListViewItem*)));
120 } else { 120 } else {
121 // qDebug("KAddressBookTableView::reconstructListView double"); 121 // qDebug("KAddressBookTableView::reconstructListView double");
122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } 124 }
125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
126 this, SLOT(addresseeExecuted(QListViewItem*))); 126 this, SLOT(addresseeExecuted(QListViewItem*)));
127 connect(mListView, SIGNAL(signalDelete()), 127 connect(mListView, SIGNAL(signalDelete()),
128 this, SLOT(addresseeDeleted())); 128 this, SLOT(addresseeDeleted()));
129 129
130//US performceimprovement. Refresh is done from the outside 130//US performceimprovement. Refresh is done from the outside
131//US refresh(); 131//US refresh();
132 132
133 mListView->setSorting( 0, true ); 133 mListView->setSorting( 0, true );
134 mainLayout->addWidget( mListView ); 134 mainLayout->addWidget( mListView );
135 mainLayout->activate(); 135 mainLayout->activate();
136 mListView->show(); 136 mListView->show();
137} 137}
138 138
139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
140{ 140{
141 mListView->clear(); 141 mListView->clear();
142 if ( s.isEmpty() || s == "*" ) { 142 if ( s.isEmpty() || s == "*" ) {
143 refresh(); 143 refresh();
144 return; 144 return;
145 } 145 }
146 QString pattern = s.lower()+"*"; 146 QString pattern = s.lower()+"*";
147 QRegExp re; 147 QRegExp re;
148 re.setWildcard(true); // most people understand these better. 148 re.setWildcard(true); // most people understand these better.
149 re.setCaseSensitive(false); 149 re.setCaseSensitive(false);
150 re.setPattern( pattern ); 150 re.setPattern( pattern );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 300 159#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) != -1) 162 if (re.match(field->value( *it ).lower()) != -1)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 300 174#if QT_VERSION >= 0x030000
175 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 175 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
176#else 176#else
177 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 177 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
178#endif 178#endif
179 { 179 {
180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
181 break; 181 break;
182 } 182 }
183 } 183 }
184 } 184 }
185 } 185 }
186 // Sometimes the background pixmap gets messed up when we add lots 186 // Sometimes the background pixmap gets messed up when we add lots
187 // of items. 187 // of items.
188 mListView->repaint(); 188 mListView->repaint();
189 if ( mListView->firstChild() ) { 189 if ( mListView->firstChild() ) {
190 mListView->setCurrentItem ( mListView->firstChild() ); 190 mListView->setCurrentItem ( mListView->firstChild() );
191 mListView->setSelected ( mListView->firstChild(), true ); 191 mListView->setSelected ( mListView->firstChild(), true );
192 } 192 }
193 else 193 else
194 emit selected(QString::null); 194 emit selected(QString::null);
195 195
196} 196}
197void KAddressBookTableView::writeConfig(KConfig *config) 197void KAddressBookTableView::writeConfig(KConfig *config)
198{ 198{
199 KAddressBookView::writeConfig(config); 199 KAddressBookView::writeConfig(config);
200 200
201 mListView->saveLayout(config, config->group()); 201 mListView->saveLayout(config, config->group());
202} 202}
203 203
204void KAddressBookTableView::readConfig(KConfig *config) 204void KAddressBookTableView::readConfig(KConfig *config)
205{ 205{
206 KAddressBookView::readConfig( config ); 206 KAddressBookView::readConfig( config );
207 // The config could have changed the fields, so we need to reconstruct 207 // The config could have changed the fields, so we need to reconstruct
208 // the listview. 208 // the listview.
209 reconstructListView(); 209 reconstructListView();
210 210
211 // costum colors? 211 // costum colors?
212 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 212 if ( config->readBoolEntry( "EnableCustomColors", false ) )
213 { 213 {
214 QPalette p( mListView->palette() ); 214 QPalette p( mListView->palette() );
215 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 215 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
217 c = p.color(QPalette::Normal, QColorGroup::Text ); 217 c = p.color(QPalette::Normal, QColorGroup::Text );
218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
219 c = p.color(QPalette::Normal, QColorGroup::Button ); 219 c = p.color(QPalette::Normal, QColorGroup::Button );
220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
221 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 221 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
223 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 223 c = p.color(QPalette::Normal, QColorGroup::Highlight );
224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
227#ifndef KAB_EMBEDDED 227#ifndef KAB_EMBEDDED
228 c = KGlobalSettings::alternateBackgroundColor(); 228 c = KGlobalSettings::alternateBackgroundColor();
229#else //KAB_EMBEDDED 229#else //KAB_EMBEDDED
230 c = QColor(240, 240, 240); 230 c = QColor(240, 240, 240);
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 232 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
233 mListView->setAlternateColor(c); 233 mListView->setAlternateColor(c);
234 234
235 235
236 //US mListView->viewport()->setPalette( p ); 236 //US mListView->viewport()->setPalette( p );
237 mListView->setPalette( p ); 237 mListView->setPalette( p );
238 } 238 }
239 else 239 else
240 { 240 {
241 // needed if turned off during a session. 241 // needed if turned off during a session.
242 //US mListView->viewport()->setPalette( mListView->palette() ); 242 //US mListView->viewport()->setPalette( mListView->palette() );
243 mListView->setPalette( mListView->palette() ); 243 mListView->setPalette( mListView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mListView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
254 } 254 }
255 else 255 else
256 { 256 {
257 mListView->setFont( f ); 257 mListView->setFont( f );
258 f.setBold( true ); 258 f.setBold( true );
259 //US mListView->setHeaderFont( f ); 259 //US mListView->setHeaderFont( f );
260 mListView->header()->setFont( f ); 260 mListView->header()->setFont( f );
261 } 261 }
262 262
263 // Set the list view options 263 // Set the list view options
264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
265 true)); 265 true));
266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
268 268
269 if (config->readBoolEntry("Background", false)) 269 if (config->readBoolEntry("Background", false))
270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
271 271
272 // Restore the layout of the listview 272 // Restore the layout of the listview
273 mListView->restoreLayout(config, config->group()); 273 mListView->restoreLayout(config, config->group());
274} 274}
275 275
276void KAddressBookTableView::refresh(QString uid) 276void KAddressBookTableView::refresh(QString uid)
277{ 277{
278 // For now just repopulate. In reality this method should 278 // For now just repopulate. In reality this method should
279 // check the value of uid, and if valid iterate through 279 // check the value of uid, and if valid iterate through
280 // the listview to find the entry, then tell it to refresh. 280 // the listview to find the entry, then tell it to refresh.
281 281
282 if (uid.isNull()) { 282 if (uid.isNull()) {
283 // Clear the list view 283 // Clear the list view
284 QString currentUID, nextUID; 284 QString currentUID, nextUID;
285#ifndef KAB_EMBEDDED 285#ifndef KAB_EMBEDDED
286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
287#else //KAB_EMBEDDED 287#else //KAB_EMBEDDED
288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
289#endif //KAB_EMBEDDED 289#endif //KAB_EMBEDDED
290 290
291 if ( currentItem ) { 291 if ( currentItem ) {
292#ifndef KAB_EMBEDDED 292#ifndef KAB_EMBEDDED
293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
294#else //KAB_EMBEDDED 294#else //KAB_EMBEDDED
295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
296#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
297 if ( nextItem ) 297 if ( nextItem )
298 nextUID = nextItem->addressee().uid(); 298 nextUID = nextItem->addressee().uid();
299 currentUID = currentItem->addressee().uid(); 299 currentUID = currentItem->addressee().uid();
300 } 300 }
301 301
302 mListView->clear(); 302 mListView->clear();
303 303
304 currentItem = 0; 304 currentItem = 0;
305 KABC::Addressee::List addresseeList = addressees(); 305 KABC::Addressee::List addresseeList = addressees();
306 KABC::Addressee::List::Iterator it; 306 KABC::Addressee::List::Iterator it;
307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
309 continue; 309 continue;
310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
311 if ( (*it).uid() == currentUID ) 311 if ( (*it).uid() == currentUID )
312 currentItem = item; 312 currentItem = item;
313 else if ( (*it).uid() == nextUID && !currentItem ) 313 else if ( (*it).uid() == nextUID && !currentItem )
314 currentItem = item; 314 currentItem = item;
315 } 315 }
316 316
317 // Sometimes the background pixmap gets messed up when we add lots 317 // Sometimes the background pixmap gets messed up when we add lots
318 // of items. 318 // of items.
319 mListView->repaint(); 319 mListView->repaint();
320 320
321 if ( currentItem ) { 321 if ( currentItem ) {
322 mListView->setCurrentItem( currentItem ); 322 mListView->setCurrentItem( currentItem );
323 mListView->ensureItemVisible( currentItem ); 323 mListView->ensureItemVisible( currentItem );
324 } 324 }
325 } else { 325 } else {
326 // Only need to update on entry. Iterate through and try to find it 326 // Only need to update on entry. Iterate through and try to find it
327 ContactListViewItem *ceItem; 327 ContactListViewItem *ceItem;
328 QListViewItemIterator it( mListView ); 328 QListViewItemIterator it( mListView );
329 while ( it.current() ) { 329 while ( it.current() ) {
330#ifndef KAB_EMBEDDED 330#ifndef KAB_EMBEDDED
331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
332#else //KAB_EMBEDDED 332#else //KAB_EMBEDDED
333 ceItem = (ContactListViewItem*)( it.current() ); 333 ceItem = (ContactListViewItem*)( it.current() );
334#endif //KAB_EMBEDDED 334#endif //KAB_EMBEDDED
335 335
336 if ( ceItem && ceItem->addressee().uid() == uid ) { 336 if ( ceItem && ceItem->addressee().uid() == uid ) {
337 ceItem->refresh(); 337 ceItem->refresh();
338 return; 338 return;
339 } 339 }
340 ++it; 340 ++it;
341 } 341 }
342 342
343 refresh( QString::null ); 343 refresh( QString::null );
344 } 344 }
345} 345}
346 346
347QStringList KAddressBookTableView::selectedUids() 347QStringList KAddressBookTableView::selectedUids()
348{ 348{
349 QStringList uidList; 349 QStringList uidList;
350 QListViewItem *item; 350 QListViewItem *item;
351 ContactListViewItem *ceItem; 351 ContactListViewItem *ceItem;
352 352
353 for(item = mListView->firstChild(); item; item = item->itemBelow()) 353 for(item = mListView->firstChild(); item; item = item->itemBelow())
354 { 354 {
355 if (mListView->isSelected( item )) 355 if (mListView->isSelected( item ))
356 { 356 {
357#ifndef KAB_EMBEDDED 357#ifndef KAB_EMBEDDED
358 ceItem = dynamic_cast<ContactListViewItem*>(item); 358 ceItem = dynamic_cast<ContactListViewItem*>(item);
359#else //KAB_EMBEDDED 359#else //KAB_EMBEDDED
360 ceItem = (ContactListViewItem*)(item); 360 ceItem = (ContactListViewItem*)(item);
361#endif //KAB_EMBEDDED 361#endif //KAB_EMBEDDED
362 362
363 if (ceItem != 0L) 363 if (ceItem != 0L)
364 uidList << ceItem->addressee().uid(); 364 uidList << ceItem->addressee().uid();
365 } 365 }
366 } 366 }
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index ead8628..21ecb73 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,259 +1,259 @@
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 <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23 23
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include "kotodoviewitem.h" 25#include "kotodoviewitem.h"
26#include "kotodoview.h" 26#include "kotodoview.h"
27#include "koprefs.h" 27#include "koprefs.h"
28 28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{ 31{
32 construct(); 32 construct();
33} 33}
34 34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{ 37{
38 construct(); 38 construct();
39} 39}
40 40
41QString KOTodoViewItem::key(int column,bool) const 41QString KOTodoViewItem::key(int column,bool) const
42{ 42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) { 44 if (it == mKeyMap.end()) {
45 return text(column).lower(); 45 return text(column).lower();
46 } else { 46 } else {
47 return *it; 47 return *it;
48 } 48 }
49} 49}
50 50
51void KOTodoViewItem:: setup() 51void KOTodoViewItem:: setup()
52{ 52{
53 53
54 int h = 20; 54 int h = 20;
55 if ( listView () ) { 55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () ); 56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height(); 57 h = fm.height();
58 } 58 }
59 setHeight( h ); 59 setHeight( h );
60 60
61} 61}
62void KOTodoViewItem::setSortKey(int column,const QString &key) 62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{ 63{
64 mKeyMap.insert(column,key); 64 mKeyMap.insert(column,key);
65} 65}
66 66
67#if QT_VERSION >= 300 67#if QT_VERSION >= 0x030000
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h) 69 int y,int h)
70{ 70{
71 QListViewItem::paintBranches(p,cg,w,y,h); 71 QListViewItem::paintBranches(p,cg,w,y,h);
72} 72}
73#else 73#else
74#endif 74#endif
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 206
207 kdDebug() << "State changed, modified " << state << endl; 207 kdDebug() << "State changed, modified " << state << endl;
208 QString keyd = "=="; 208 QString keyd = "==";
209 QString keyt = "=="; 209 QString keyt = "==";
210 210
211 if (state) mTodo->setCompleted(state); 211 if (state) mTodo->setCompleted(state);
212 else mTodo->setPercentComplete(0); 212 else mTodo->setPercentComplete(0);
213 if (isOn()!=state) { 213 if (isOn()!=state) {
214 setOn(state); 214 setOn(state);
215 } 215 }
216 216
217 if (mTodo->hasDueDate()) { 217 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 218 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 219 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 221 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 222 if (mTodo->doesFloat()) {
223 setText(4,""); 223 setText(4,"");
224 } 224 }
225 else { 225 else {
226 setText(4,mTodo->dtDueTimeStr()); 226 setText(4,mTodo->dtDueTimeStr());
227 QTime t = mTodo->dtDue().time(); 227 QTime t = mTodo->dtDue().time();
228 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 228 keyt.sprintf("%02d%02d",t.hour(),t.minute());
229 setSortKey(4,keyt); 229 setSortKey(4,keyt);
230 } 230 }
231 } 231 }
232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
234 234
235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
236 if (mTodo->percentComplete()<100) { 236 if (mTodo->percentComplete()<100) {
237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
238 else setSortKey(2,QString::number(mTodo->percentComplete())); 238 else setSortKey(2,QString::number(mTodo->percentComplete()));
239 } 239 }
240 else { 240 else {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(99)); 242 else setSortKey(2,QString::number(99));
243 } 243 }
244 QListViewItem * myChild = firstChild(); 244 QListViewItem * myChild = firstChild();
245 KOTodoViewItem *item; 245 KOTodoViewItem *item;
246 while( myChild ) { 246 while( myChild ) {
247 item = static_cast<KOTodoViewItem*>(myChild); 247 item = static_cast<KOTodoViewItem*>(myChild);
248 item->stateChange(state); 248 item->stateChange(state);
249 myChild = myChild->nextSibling(); 249 myChild = myChild->nextSibling();
250 } 250 }
251 mTodoView->modified(true); 251 mTodoView->modified(true);
252 setMyPixmap(); 252 setMyPixmap();
253 mTodoView->setTodoModified( mTodo ); 253 mTodoView->setTodoModified( mTodo );
254} 254}
255 255
256bool KOTodoViewItem::isAlternate() 256bool KOTodoViewItem::isAlternate()
257{ 257{
258#ifndef KORG_NOLVALTERNATION 258#ifndef KORG_NOLVALTERNATION
259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
diff --git a/korganizer/kotodoviewitem.h b/korganizer/kotodoviewitem.h
index 74dbe98..bd024c8 100644
--- a/korganizer/kotodoviewitem.h
+++ b/korganizer/kotodoviewitem.h
@@ -1,93 +1,93 @@
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#ifndef KOTODOVIEWITEM_H 19#ifndef KOTODOVIEWITEM_H
20#define KOTODOVIEWITEM_H 20#define KOTODOVIEWITEM_H
21 21
22#include <qfont.h> 22#include <qfont.h>
23#include <qfontmetrics.h> 23#include <qfontmetrics.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qstrlist.h> 26#include <qstrlist.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qmap.h> 30#include <qmap.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qpainter.h> 32#include <qpainter.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/todo.h> 35#include <libkcal/todo.h>
36 36
37using namespace KCal; 37using namespace KCal;
38 38
39class KOTodoView; 39class KOTodoView;
40 40
41/** 41/**
42 This class provides a way of displaying a single Event of Todo-Type in a 42 This class provides a way of displaying a single Event of Todo-Type in a
43 KTodoView. 43 KTodoView.
44 44
45 @author Cornelius Schumacher <schumacher@kde.org> 45 @author Cornelius Schumacher <schumacher@kde.org>
46 @see KOTodoView 46 @see KOTodoView
47*/ 47*/
48class KOTodoViewItem : public QCheckListItem 48class KOTodoViewItem : public QCheckListItem
49{ 49{
50 public: 50 public:
51 /** 51 /**
52 Constructor. 52 Constructor.
53 53
54 @param parent is the list view to which this item belongs. 54 @param parent is the list view to which this item belongs.
55 @param ev is the event to have the item display information for. 55 @param ev is the event to have the item display information for.
56 */ 56 */
57 KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo); 57 KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo);
58 KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo); 58 KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo);
59 //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );} 59 //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );}
60 60
61 void construct(); 61 void construct();
62 62
63 Todo *todo() { return mTodo; } 63 Todo *todo() { return mTodo; }
64 64
65 QString key(int, bool) const; 65 QString key(int, bool) const;
66 66
67 void setSortKey(int column,const QString &key); 67 void setSortKey(int column,const QString &key);
68 68
69 bool isAlternate(); 69 bool isAlternate();
70 70
71 virtual void paintCell(QPainter *p, const QColorGroup &cg, 71 virtual void paintCell(QPainter *p, const QColorGroup &cg,
72 int column, int width, int alignment); 72 int column, int width, int alignment);
73 virtual void setup(); 73 virtual void setup();
74 protected: 74 protected:
75#if QT_VERSION >= 300 75#if QT_VERSION >= 0x030000
76 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h); 76 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h);
77#else 77#else
78#endif 78#endif
79 virtual void stateChange(bool); 79 virtual void stateChange(bool);
80 void setMyPixmap(); 80 void setMyPixmap();
81 81
82 private: 82 private:
83 Todo *mTodo; 83 Todo *mTodo;
84 KOTodoView *mTodoView; 84 KOTodoView *mTodoView;
85 85
86 QMap<int,QString> mKeyMap; 86 QMap<int,QString> mKeyMap;
87 uint m_odd : 1; 87 uint m_odd : 1;
88 uint m_known : 1; 88 uint m_known : 1;
89 uint m_unused : 30; 89 uint m_unused : 30;
90 bool m_init; 90 bool m_init;
91}; 91};
92 92
93#endif 93#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f6b7718..e255b83 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -386,203 +386,203 @@ void KOViewManager::showWeekView()
386 globalFlagBlockAgenda = 2; 386 globalFlagBlockAgenda = 2;
387 qDebug("4globalFlagBlockAgenda = 2; "); 387 qDebug("4globalFlagBlockAgenda = 2; ");
388 //globalFlagBlockPainting = true; 388 //globalFlagBlockPainting = true;
389 mMainView->dateNavigator()->selectWeek(); 389 mMainView->dateNavigator()->selectWeek();
390 showAgendaView(); 390 showAgendaView();
391 */ 391 */
392 392
393 393
394 mFlagShowNextxDays = false; 394 mFlagShowNextxDays = false;
395 globalFlagBlockAgenda = 1; 395 globalFlagBlockAgenda = 1;
396 globalFlagBlockLabel = 1; 396 globalFlagBlockLabel = 1;
397 if ( mCurrentAgendaView != 7 ) 397 if ( mCurrentAgendaView != 7 )
398 mCurrentAgendaView = -1; 398 mCurrentAgendaView = -1;
399 showAgendaView(); 399 showAgendaView();
400 qApp->processEvents(); 400 qApp->processEvents();
401 globalFlagBlockAgenda = 2; 401 globalFlagBlockAgenda = 2;
402 globalFlagBlockLabel = 0; 402 globalFlagBlockLabel = 0;
403 mMainView->dateNavigator()->selectWeek(); 403 mMainView->dateNavigator()->selectWeek();
404 mCurrentAgendaView = 7 ; 404 mCurrentAgendaView = 7 ;
405} 405}
406 406
407void KOViewManager::showNextXView() 407void KOViewManager::showNextXView()
408{ 408{
409 409
410 globalFlagBlockAgenda = 1; 410 globalFlagBlockAgenda = 1;
411 if ( mCurrentAgendaView != 3 ) 411 if ( mCurrentAgendaView != 3 )
412 mCurrentAgendaView = -1; 412 mCurrentAgendaView = -1;
413 showAgendaView(KOPrefs::instance()->mFullViewMonth); 413 showAgendaView(KOPrefs::instance()->mFullViewMonth);
414 globalFlagBlockAgenda = 2; 414 globalFlagBlockAgenda = 2;
415 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 415 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
416 KOPrefs::instance()->mNextXDays ); 416 KOPrefs::instance()->mNextXDays );
417 mFlagShowNextxDays = true; 417 mFlagShowNextxDays = true;
418 mCurrentAgendaView = 3 ; 418 mCurrentAgendaView = 3 ;
419} 419}
420bool KOViewManager::showsNextDays() 420bool KOViewManager::showsNextDays()
421{ 421{
422 return mFlagShowNextxDays; 422 return mFlagShowNextxDays;
423} 423}
424void KOViewManager::showMonthView() 424void KOViewManager::showMonthView()
425{ 425{
426 if (!mMonthView) { 426 if (!mMonthView) {
427 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 427 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
428 428
429 addView(mMonthView); 429 addView(mMonthView);
430 // mMonthView->show(); 430 // mMonthView->show();
431 // SIGNALS/SLOTS FOR MONTH VIEW 431 // SIGNALS/SLOTS FOR MONTH VIEW
432 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 432 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
433 mMainView, SLOT(newEvent(QDateTime))); 433 mMainView, SLOT(newEvent(QDateTime)));
434 434
435 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 435 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
436 mMainView, SLOT(showIncidence(Incidence *))); 436 mMainView, SLOT(showIncidence(Incidence *)));
437 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 437 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
438 mMainView, SLOT(editIncidence(Incidence *))); 438 mMainView, SLOT(editIncidence(Incidence *)));
439 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 439 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
440 mMainView, SLOT(deleteIncidence(Incidence *))); 440 mMainView, SLOT(deleteIncidence(Incidence *)));
441 441
442 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 442 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
443 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 443 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
444 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 444 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
445 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 445 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 446 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 447 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
448 448
449 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 449 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
450 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 450 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
451 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
452 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
453 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 453 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
454 mMainView, SLOT ( selectWeekNum( int ) ) ); 454 mMainView, SLOT ( selectWeekNum( int ) ) );
455 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 455 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
456 mMainView, SLOT ( showDay( QDate ) ) ); 456 mMainView, SLOT ( showDay( QDate ) ) );
457 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 457 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
458 mMonthView->updateConfig(); 458 mMonthView->updateConfig();
459 } 459 }
460 460
461 globalFlagBlockAgenda = 1; 461 globalFlagBlockAgenda = 1;
462 //mFlagShowNextxDays = false; 462 //mFlagShowNextxDays = false;
463 // if(mMonthView == mCurrentView) return; 463 // if(mMonthView == mCurrentView) return;
464 mMainView->dateNavigator()->selectMonth(); 464 mMainView->dateNavigator()->selectMonth();
465 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 465 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
466 //mMonthView->showDates(tmpList.first(), tmpList.last()); 466 //mMonthView->showDates(tmpList.first(), tmpList.last());
467 467
468 showView(mMonthView, true ); 468 showView(mMonthView, true );
469 469
470} 470}
471 471
472void KOViewManager::showTodoView() 472void KOViewManager::showTodoView()
473{ 473{
474 //mFlagShowNextxDays = false; 474 //mFlagShowNextxDays = false;
475 if ( !mTodoView ) { 475 if ( !mTodoView ) {
476 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 476 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
477 "KOViewManager::TodoView" ); 477 "KOViewManager::TodoView" );
478 478
479 addView( mTodoView ); 479 addView( mTodoView );
480 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 480 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
481 481
482 // SIGNALS/SLOTS FOR TODO VIEW 482 // SIGNALS/SLOTS FOR TODO VIEW
483 connect( mTodoView, SIGNAL( newTodoSignal() ), 483 connect( mTodoView, SIGNAL( newTodoSignal() ),
484 mMainView, SLOT( newTodo() ) ); 484 mMainView, SLOT( newTodo() ) );
485 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 485 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
486 mMainView, SLOT( newSubTodo( Todo *) ) ); 486 mMainView, SLOT( newSubTodo( Todo *) ) );
487 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 487 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
488 mMainView, SLOT( showTodo( Todo * ) ) ); 488 mMainView, SLOT( showTodo( Todo * ) ) );
489 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 489 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
490 mMainView, SLOT( editTodo( Todo * ) ) ); 490 mMainView, SLOT( editTodo( Todo * ) ) );
491 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 491 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
492 mMainView, SLOT( deleteTodo( Todo * ) ) ); 492 mMainView, SLOT( deleteTodo( Todo * ) ) );
493 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 493 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
494 mMainView, SLOT( purgeCompleted() ) ); 494 mMainView, SLOT( purgeCompleted() ) );
495 495
496 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 496 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
497 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 497 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
498 498
499 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 499 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
500 SLOT( updateConfig() ) ); 500 SLOT( updateConfig() ) );
501 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 501 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
502 SLOT( updateTodo( Todo *, int ) ) ); 502 SLOT( updateTodo( Todo *, int ) ) );
503 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 503 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
504 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 504 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
505 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 505 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
506 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
507 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 507 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
508 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 508 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
509 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 509 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
510 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 510 mMainView, SLOT ( todo_unsub( Todo * ) ) );
511 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 511 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
512 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 512 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
513 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 513 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
514 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 514 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
515 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 515 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
516 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 516 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
517 KConfig *config = KOGlobals::config(); 517 KConfig *config = KOGlobals::config();
518 mTodoView->restoreLayout(config,"Todo View"); 518 mTodoView->restoreLayout(config,"Todo View");
519 mTodoView->setNavigator( mMainView->dateNavigator() ); 519 mTodoView->setNavigator( mMainView->dateNavigator() );
520 } 520 }
521 521
522 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
523 showView( mTodoView, true ); 523 showView( mTodoView, true );
524 524
525} 525}
526 526
527void KOViewManager::showJournalView() 527void KOViewManager::showJournalView()
528{ 528{
529 //mFlagShowNextxDays = false; 529 //mFlagShowNextxDays = false;
530 if (!mJournalView) { 530 if (!mJournalView) {
531 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 531 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
532 "KOViewManager::JournalView"); 532 "KOViewManager::JournalView");
533 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 533 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
534 SLOT( updateConfig() ) ); 534 SLOT( updateConfig() ) );
535 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 535 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
536 addView(mJournalView); 536 addView(mJournalView);
537 } 537 }
538 538
539 showView(mJournalView); 539 showView(mJournalView);
540} 540}
541 541
542void KOViewManager::showTimeSpanView() 542void KOViewManager::showTimeSpanView()
543{ 543{
544 //mFlagShowNextxDays = false; 544 //mFlagShowNextxDays = false;
545 if (!mTimeSpanView) { 545 if (!mTimeSpanView) {
546 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 546 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
547 "KOViewManager::TimeSpanView"); 547 "KOViewManager::TimeSpanView");
548 addView(mTimeSpanView); 548 addView(mTimeSpanView);
549 549
550 mTimeSpanView->readSettings(); 550 mTimeSpanView->readSettings();
551 } 551 }
552 552
553 showView(mTimeSpanView); 553 showView(mTimeSpanView);
554} 554}
555 555
556Incidence *KOViewManager::currentSelection() 556Incidence *KOViewManager::currentSelection()
557{ 557{
558 if (!mCurrentView) return 0; 558 if (!mCurrentView) return 0;
559 if ( mCurrentView == mListView ) { 559 if ( mCurrentView == mListView ) {
560 if ( mListView->currentItem() ) 560 if ( mListView->currentItem() )
561 return mListView->currentItem(); 561 return mListView->currentItem();
562 } 562 }
563 return mCurrentView->selectedIncidences().first(); 563 return mCurrentView->selectedIncidences().first();
564} 564}
565 565
566QDate KOViewManager::currentSelectionDate() 566QDate KOViewManager::currentSelectionDate()
567{ 567{
568 QDate qd; 568 QDate qd;
569 if (mCurrentView) { 569 if (mCurrentView) {
570 DateList qvl = mCurrentView->selectedDates(); 570 DateList qvl = mCurrentView->selectedDates();
571 if (!qvl.isEmpty()) qd = qvl.first(); 571 if (!qvl.isEmpty()) qd = qvl.first();
572 } 572 }
573 return qd; 573 return qd;
574} 574}
575 575
576void KOViewManager::addView(KOrg::BaseView *view) 576void KOViewManager::addView(KOrg::BaseView *view)
577{ 577{
578#if QT_VERSION >= 300 578#if QT_VERSION >= 0x030000
579 mMainView->viewStack()->addWidget( view ); 579 mMainView->viewStack()->addWidget( view );
580#else 580#else
581 mMainView->viewStack()->addWidget( view, 1 ); 581 mMainView->viewStack()->addWidget( view, 1 );
582#endif 582#endif
583} 583}
584 584
585void KOViewManager::setDocumentId( const QString &id ) 585void KOViewManager::setDocumentId( const QString &id )
586{ 586{
587 if (mTodoView) mTodoView->setDocumentId( id ); 587 if (mTodoView) mTodoView->setDocumentId( id );
588} 588}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 72ee1d2..39966b5 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -45,353 +45,353 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, 45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false,
46 i18n("&Find")) 46 i18n("&Find"))
47{ 47{
48 mCalendar = calendar; 48 mCalendar = calendar;
49 QFrame *topFrame = plainPage(); 49 QFrame *topFrame = plainPage();
50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); 50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint());
51 51
52 // Search expression 52 // Search expression
53 QHBoxLayout *subLayout = new QHBoxLayout(); 53 QHBoxLayout *subLayout = new QHBoxLayout();
54 layout->addLayout(subLayout); 54 layout->addLayout(subLayout);
55 55
56 searchLabel = new QLabel(topFrame); 56 searchLabel = new QLabel(topFrame);
57 searchLabel->setText(i18n("Search for:")); 57 searchLabel->setText(i18n("Search for:"));
58 subLayout->addWidget(searchLabel); 58 subLayout->addWidget(searchLabel);
59 59
60 searchEdit = new QLineEdit(topFrame); 60 searchEdit = new QLineEdit(topFrame);
61 subLayout->addWidget(searchEdit); 61 subLayout->addWidget(searchEdit);
62 searchEdit->setText("*"); // Find all events by default 62 searchEdit->setText("*"); // Find all events by default
63 searchEdit->setFocus(); 63 searchEdit->setFocus();
64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
66 // Subjects to search 66 // Subjects to search
67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
68 // topFrame); 68 // topFrame);
69 69
70 70
71 71
72 QHBox *incidenceGroup = new QHBox( topFrame ); 72 QHBox *incidenceGroup = new QHBox( topFrame );
73 layout->addWidget(incidenceGroup); 73 layout->addWidget(incidenceGroup);
74 74
75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
76 mSearchEvent->setChecked(true); 76 mSearchEvent->setChecked(true);
77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
79 79
80 QHBox *subjectGroup = new QHBox( topFrame ); 80 QHBox *subjectGroup = new QHBox( topFrame );
81 layout->addWidget(subjectGroup); 81 layout->addWidget(subjectGroup);
82 82
83 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup); 83 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup);
84 mSummaryCheck->setChecked(true); 84 mSummaryCheck->setChecked(true);
85 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); 85 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup);
86 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 86 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
87 87
88 QHBox *attendeeGroup = new QHBox( topFrame ); 88 QHBox *attendeeGroup = new QHBox( topFrame );
89 layout->addWidget(attendeeGroup ); 89 layout->addWidget(attendeeGroup );
90 new QLabel( i18n("Attendee:"),attendeeGroup ); 90 new QLabel( i18n("Attendee:"),attendeeGroup );
91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
93 // Date range 93 // Date range
94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
95 // topFrame); 95 // topFrame);
96 // layout->addWidget(rangeGroup); 96 // layout->addWidget(rangeGroup);
97 97
98 QWidget *rangeWidget = new QWidget(topFrame); 98 QWidget *rangeWidget = new QWidget(topFrame);
99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); 99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint());
100 100
101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
102 mStartDate = new KDateEdit(rangeWidget); 102 mStartDate = new KDateEdit(rangeWidget);
103 rangeLayout->addWidget(mStartDate); 103 rangeLayout->addWidget(mStartDate);
104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
105 mEndDate = new KDateEdit(rangeWidget); 105 mEndDate = new KDateEdit(rangeWidget);
106 mEndDate->setDate(QDate::currentDate().addDays(365)); 106 mEndDate->setDate(QDate::currentDate().addDays(365));
107 rangeLayout->addWidget(mEndDate); 107 rangeLayout->addWidget(mEndDate);
108 108
109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); 109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame);
110 //mInclusiveCheck->setChecked(false); 110 //mInclusiveCheck->setChecked(false);
111 layout->addWidget(rangeWidget); 111 layout->addWidget(rangeWidget);
112 //layout->addWidget(mInclusiveCheck); 112 //layout->addWidget(mInclusiveCheck);
113 // Subjects to search 113 // Subjects to search
114 114
115 115
116 // Results list view 116 // Results list view
117 listView = new KOListView(mCalendar,topFrame); 117 listView = new KOListView(mCalendar,topFrame);
118 //listView->showDates(); 118 //listView->showDates();
119 119
120 120
121 layout->addWidget(listView); 121 layout->addWidget(listView);
122 122
123 // if ( KOPrefs::instance()->mCompactDialogs ) { 123 // if ( KOPrefs::instance()->mCompactDialogs ) {
124 // KOGlobals::fitDialogToScreen( this, true ); 124 // KOGlobals::fitDialogToScreen( this, true );
125 // } 125 // }
126 126
127 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 127 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); 128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch()));
129 QPushButton *CloseButton = findButton( Close ); 129 QPushButton *CloseButton = findButton( Close );
130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); 130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear()));
131 131
132#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
133 setCaption(i18n("Click OK to search ->")); 133 setCaption(i18n("Click OK to search ->"));
134 hideButtons(); 134 hideButtons();
135#endif 135#endif
136} 136}
137 137
138SearchDialog::~SearchDialog() 138SearchDialog::~SearchDialog()
139{ 139{
140 140
141} 141}
142void SearchDialog::accept() 142void SearchDialog::accept()
143{ 143{
144 doSearch(); 144 doSearch();
145} 145}
146void SearchDialog::updateList() 146void SearchDialog::updateList()
147{ 147{
148 //listView->updateList(); 148 //listView->updateList();
149 if ( isVisible() ) { 149 if ( isVisible() ) {
150 updateView(); 150 updateView();
151 //qDebug("SearchDialog::updated "); 151 //qDebug("SearchDialog::updated ");
152 } 152 }
153 else { 153 else {
154 listView->clear(); 154 listView->clear();
155 //qDebug("SearchDialog::cleared "); 155 //qDebug("SearchDialog::cleared ");
156 156
157 } 157 }
158} 158}
159void SearchDialog::searchTextChanged( const QString &_text ) 159void SearchDialog::searchTextChanged( const QString &_text )
160{ 160{
161 enableButton( KDialogBase::User1, !_text.isEmpty() ); 161 enableButton( KDialogBase::User1, !_text.isEmpty() );
162} 162}
163 163
164void SearchDialog::doSearch() 164void SearchDialog::doSearch()
165{ 165{
166 QRegExp re; 166 QRegExp re;
167 167
168 re.setWildcard(true); // most people understand these better. 168 re.setWildcard(true); // most people understand these better.
169 re.setCaseSensitive(false); 169 re.setCaseSensitive(false);
170 re.setPattern(searchEdit->text()); 170 re.setPattern(searchEdit->text());
171 if (!re.isValid() ) { 171 if (!re.isValid() ) {
172 KMessageBox::sorry(this, 172 KMessageBox::sorry(this,
173 i18n("Invalid search expression,\ncannot perform " 173 i18n("Invalid search expression,\ncannot perform "
174 "the search.\nPlease enter a search expression\n" 174 "the search.\nPlease enter a search expression\n"
175 "using the wildcard characters\n '*' and '?'" 175 "using the wildcard characters\n '*' and '?'"
176 "where needed.")); 176 "where needed."));
177 return; 177 return;
178 } 178 }
179 179
180 search(re); 180 search(re);
181 181
182 listView->setStartDate( mStartDate->date() ); 182 listView->setStartDate( mStartDate->date() );
183 listView->showEvents(mMatchedEvents); 183 listView->showEvents(mMatchedEvents);
184 listView->addTodos(mMatchedTodos); 184 listView->addTodos(mMatchedTodos);
185 listView->addJournals(mMatchedJournals); 185 listView->addJournals(mMatchedJournals);
186 186
187 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 187 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
188 KMessageBox::information(this, 188 KMessageBox::information(this,
189 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed.")); 189 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed."));
190#ifndef DESKTOP_VERSION 190#ifndef DESKTOP_VERSION
191 setCaption(i18n("Click OK to search ->")); 191 setCaption(i18n("Click OK to search ->"));
192#else 192#else
193 setCaption(i18n("KO/Pi Find ")); 193 setCaption(i18n("KO/Pi Find "));
194#endif 194#endif
195 } else { 195 } else {
196 QString mess; 196 QString mess;
197 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 197 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
198 setCaption( i18n("KO/Pi Find: ") + mess); 198 setCaption( i18n("KO/Pi Find: ") + mess);
199 199
200 } 200 }
201} 201}
202void SearchDialog::updateConfig() 202void SearchDialog::updateConfig()
203{ 203{
204 listView->updateConfig(); 204 listView->updateConfig();
205} 205}
206void SearchDialog::updateView() 206void SearchDialog::updateView()
207{ 207{
208 208
209 QRegExp re; 209 QRegExp re;
210 re.setWildcard(true); // most people understand these better. 210 re.setWildcard(true); // most people understand these better.
211 re.setCaseSensitive(false); 211 re.setCaseSensitive(false);
212 re.setPattern(searchEdit->text()); 212 re.setPattern(searchEdit->text());
213 if (re.isValid()) { 213 if (re.isValid()) {
214 search(re); 214 search(re);
215 } else { 215 } else {
216 mMatchedEvents.clear(); 216 mMatchedEvents.clear();
217 mMatchedTodos.clear(); 217 mMatchedTodos.clear();
218 mMatchedJournals.clear(); 218 mMatchedJournals.clear();
219 } 219 }
220 listView->setStartDate( mStartDate->date() ); 220 listView->setStartDate( mStartDate->date() );
221 listView->showEvents(mMatchedEvents); 221 listView->showEvents(mMatchedEvents);
222 listView->addTodos(mMatchedTodos); 222 listView->addTodos(mMatchedTodos);
223 listView->addJournals(mMatchedJournals); 223 listView->addJournals(mMatchedJournals);
224} 224}
225 225
226void SearchDialog::search(const QRegExp &re) 226void SearchDialog::search(const QRegExp &re)
227{ 227{
228 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 228 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
229 mEndDate->date(), 229 mEndDate->date(),
230 false /*mInclusiveCheck->isChecked()*/ ); 230 false /*mInclusiveCheck->isChecked()*/ );
231 231
232 mMatchedEvents.clear(); 232 mMatchedEvents.clear();
233 if ( mSearchEvent->isChecked() ) { 233 if ( mSearchEvent->isChecked() ) {
234 Event *ev; 234 Event *ev;
235 for(ev=events.first();ev;ev=events.next()) { 235 for(ev=events.first();ev;ev=events.next()) {
236 if (mSummaryCheck->isChecked()) { 236 if (mSummaryCheck->isChecked()) {
237#if QT_VERSION >= 300 237#if QT_VERSION >= 0x030000
238 if (re.search(ev->summary()) != -1) 238 if (re.search(ev->summary()) != -1)
239#else 239#else
240 if (re.match(ev->summary()) != -1) 240 if (re.match(ev->summary()) != -1)
241#endif 241#endif
242 { 242 {
243 mMatchedEvents.append(ev); 243 mMatchedEvents.append(ev);
244 continue; 244 continue;
245 } 245 }
246 } 246 }
247 if (mDescriptionCheck->isChecked()) { 247 if (mDescriptionCheck->isChecked()) {
248#if QT_VERSION >= 300 248#if QT_VERSION >= 0x030000
249 if (re.search(ev->description()) != -1) 249 if (re.search(ev->description()) != -1)
250#else 250#else
251 if (re.match(ev->description()) != -1) 251 if (re.match(ev->description()) != -1)
252#endif 252#endif
253 { 253 {
254 mMatchedEvents.append(ev); 254 mMatchedEvents.append(ev);
255 continue; 255 continue;
256 } 256 }
257 } 257 }
258 if (mCategoryCheck->isChecked()) { 258 if (mCategoryCheck->isChecked()) {
259#if QT_VERSION >= 300 259#if QT_VERSION >= 0x030000
260 if (re.search(ev->categoriesStr()) != -1) 260 if (re.search(ev->categoriesStr()) != -1)
261#else 261#else
262 if (re.match(ev->categoriesStr()) != -1) 262 if (re.match(ev->categoriesStr()) != -1)
263#endif 263#endif
264 { 264 {
265 mMatchedEvents.append(ev); 265 mMatchedEvents.append(ev);
266 continue; 266 continue;
267 } 267 }
268 } 268 }
269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
270 QPtrList<Attendee> tmpAList = ev->attendees(); 270 QPtrList<Attendee> tmpAList = ev->attendees();
271 Attendee *a; 271 Attendee *a;
272 for (a = tmpAList.first(); a; a = tmpAList.next()) { 272 for (a = tmpAList.first(); a; a = tmpAList.next()) {
273 if (mSearchAName->isChecked()) { 273 if (mSearchAName->isChecked()) {
274#if QT_VERSION >= 300 274#if QT_VERSION >= 0x030000
275 if (re.search(a->name()) != -1) 275 if (re.search(a->name()) != -1)
276#else 276#else
277 if (re.match(a->name()) != -1) 277 if (re.match(a->name()) != -1)
278#endif 278#endif
279 { 279 {
280 mMatchedEvents.append(ev); 280 mMatchedEvents.append(ev);
281 break; 281 break;
282 } 282 }
283 } 283 }
284 if (mSearchAEmail->isChecked()) { 284 if (mSearchAEmail->isChecked()) {
285#if QT_VERSION >= 300 285#if QT_VERSION >= 0x030000
286 if (re.search(a->email()) != -1) 286 if (re.search(a->email()) != -1)
287#else 287#else
288 if (re.match(a->email()) != -1) 288 if (re.match(a->email()) != -1)
289#endif 289#endif
290 { 290 {
291 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
292 break; 292 break;
293 } 293 }
294 } 294 }
295 } 295 }
296 } 296 }
297 } 297 }
298 } 298 }
299 QPtrList<Todo> todos = mCalendar->todos( ); 299 QPtrList<Todo> todos = mCalendar->todos( );
300 mMatchedTodos.clear(); 300 mMatchedTodos.clear();
301 if ( mSearchTodo->isChecked() ) { 301 if ( mSearchTodo->isChecked() ) {
302 Todo *tod; 302 Todo *tod;
303 for(tod=todos.first();tod;tod=todos.next()) { 303 for(tod=todos.first();tod;tod=todos.next()) {
304 if (mSummaryCheck->isChecked()) { 304 if (mSummaryCheck->isChecked()) {
305#if QT_VERSION >= 300 305#if QT_VERSION >= 0x030000
306 if (re.search(tod->summary()) != -1) 306 if (re.search(tod->summary()) != -1)
307#else 307#else
308 if (re.match(tod->summary()) != -1) 308 if (re.match(tod->summary()) != -1)
309#endif 309#endif
310 { 310 {
311 mMatchedTodos.append(tod); 311 mMatchedTodos.append(tod);
312 continue; 312 continue;
313 } 313 }
314 } 314 }
315 if (mDescriptionCheck->isChecked()) { 315 if (mDescriptionCheck->isChecked()) {
316#if QT_VERSION >= 300 316#if QT_VERSION >= 0x030000
317 if (re.search(tod->description()) != -1) 317 if (re.search(tod->description()) != -1)
318#else 318#else
319 if (re.match(tod->description()) != -1) 319 if (re.match(tod->description()) != -1)
320#endif 320#endif
321 { 321 {
322 mMatchedTodos.append(tod); 322 mMatchedTodos.append(tod);
323 continue; 323 continue;
324 } 324 }
325 } 325 }
326 if (mCategoryCheck->isChecked()) { 326 if (mCategoryCheck->isChecked()) {
327#if QT_VERSION >= 300 327#if QT_VERSION >= 0x030000
328 if (re.search(tod->categoriesStr()) != -1) 328 if (re.search(tod->categoriesStr()) != -1)
329#else 329#else
330 if (re.match(tod->categoriesStr()) != -1) 330 if (re.match(tod->categoriesStr()) != -1)
331#endif 331#endif
332 { 332 {
333 mMatchedTodos.append(tod); 333 mMatchedTodos.append(tod);
334 continue; 334 continue;
335 } 335 }
336 } 336 }
337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
338 QPtrList<Attendee> tmpAList = tod->attendees(); 338 QPtrList<Attendee> tmpAList = tod->attendees();
339 Attendee *a; 339 Attendee *a;
340 for (a = tmpAList.first(); a; a = tmpAList.next()) { 340 for (a = tmpAList.first(); a; a = tmpAList.next()) {
341 if (mSearchAName->isChecked()) { 341 if (mSearchAName->isChecked()) {
342#if QT_VERSION >= 300 342#if QT_VERSION >= 0x030000
343 if (re.search(a->name()) != -1) 343 if (re.search(a->name()) != -1)
344#else 344#else
345 if (re.match(a->name()) != -1) 345 if (re.match(a->name()) != -1)
346#endif 346#endif
347 { 347 {
348 mMatchedTodos.append(tod); 348 mMatchedTodos.append(tod);
349 break; 349 break;
350 } 350 }
351 } 351 }
352 if (mSearchAEmail->isChecked()) { 352 if (mSearchAEmail->isChecked()) {
353#if QT_VERSION >= 300 353#if QT_VERSION >= 0x030000
354 if (re.search(a->email()) != -1) 354 if (re.search(a->email()) != -1)
355#else 355#else
356 if (re.match(a->email()) != -1) 356 if (re.match(a->email()) != -1)
357#endif 357#endif
358 { 358 {
359 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
360 break; 360 break;
361 } 361 }
362 } 362 }
363 } 363 }
364 } 364 }
365 } 365 }
366 } 366 }
367 mMatchedJournals.clear(); 367 mMatchedJournals.clear();
368 if (mSearchJournal->isChecked() ) { 368 if (mSearchJournal->isChecked() ) {
369 QPtrList<Journal> journals = mCalendar->journals( ); 369 QPtrList<Journal> journals = mCalendar->journals( );
370 Journal* journ; 370 Journal* journ;
371 371
372 for(journ=journals.first();journ;journ=journals.next()) { 372 for(journ=journals.first();journ;journ=journals.next()) {
373 if ( journ->dtStart().date() <= mEndDate->date() 373 if ( journ->dtStart().date() <= mEndDate->date()
374 &&journ->dtStart().date() >= mStartDate->date()) { 374 &&journ->dtStart().date() >= mStartDate->date()) {
375#if QT_VERSION >= 300 375#if QT_VERSION >= 0x030000
376 if (re.search(journ->description()) != -1) 376 if (re.search(journ->description()) != -1)
377#else 377#else
378 if (re.match(journ->description()) != -1) 378 if (re.match(journ->description()) != -1)
379#endif 379#endif
380 { 380 {
381 mMatchedJournals.append(journ); 381 mMatchedJournals.append(journ);
382 continue; 382 continue;
383 } 383 }
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388} 388}
389/* 389/*
390void SearchDialog::keyPressEvent ( QKeyEvent *e) 390void SearchDialog::keyPressEvent ( QKeyEvent *e)
391{ 391{
392 392
393 e->ignore(); 393 e->ignore();
394 394
395} 395}
396*/ 396*/
397//mMatchedJournals; 397//mMatchedJournals;
diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp
index 67a3811..df8ff88 100644
--- a/korganizer/timespanview.cpp
+++ b/korganizer/timespanview.cpp
@@ -1,157 +1,157 @@
1 1
2#ifndef DESKTOP_VERSION 2#ifndef DESKTOP_VERSION
3#include <qksplitter.h> 3#include <qksplitter.h>
4#else 4#else
5#include <qsplitter.h> 5#include <qsplitter.h>
6#endif 6#endif
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qheader.h> 9#include <qheader.h>
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11 11
12#include <klocale.h> 12#include <klocale.h>
13#include <kdebug.h> 13#include <kdebug.h>
14 14
15#include "lineview.h" 15#include "lineview.h"
16#include "timeline.h" 16#include "timeline.h"
17 17
18#include "timespanview.h" 18#include "timespanview.h"
19 19
20 20
21TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : 21TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) :
22 QWidget( parent, name ) 22 QWidget( parent, name )
23{ 23{
24 QBoxLayout *topLayout = new QVBoxLayout( this ); 24 QBoxLayout *topLayout = new QVBoxLayout( this );
25#ifndef DESKTOP_VERSION 25#ifndef DESKTOP_VERSION
26 mSplitter = new QKSplitter( this ); 26 mSplitter = new QKSplitter( this );
27#else 27#else
28 mSplitter = new QSplitter( this ); 28 mSplitter = new QSplitter( this );
29#endif 29#endif
30 topLayout->addWidget( mSplitter ); 30 topLayout->addWidget( mSplitter );
31 31
32 mList = new QListView( mSplitter ); 32 mList = new QListView( mSplitter );
33 mList->addColumn( i18n("Summary") ); 33 mList->addColumn( i18n("Summary") );
34 34
35 QWidget *rightPane = new QWidget( mSplitter ); 35 QWidget *rightPane = new QWidget( mSplitter );
36 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane ); 36 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane );
37 37
38 mTimeLine = new TimeLine( rightPane ); 38 mTimeLine = new TimeLine( rightPane );
39 mTimeLine->setFixedHeight( mList->header()->height() ); 39 mTimeLine->setFixedHeight( mList->header()->height() );
40 rightPaneLayout->addWidget( mTimeLine ); 40 rightPaneLayout->addWidget( mTimeLine );
41 41
42 mLineView = new LineView( rightPane ); 42 mLineView = new LineView( rightPane );
43 rightPaneLayout->addWidget( mLineView ); 43 rightPaneLayout->addWidget( mLineView );
44 44
45 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout ); 45 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout );
46 46
47 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); 47 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane );
48 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); 48 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) );
49 buttonLayout->addWidget( zoomInButton ); 49 buttonLayout->addWidget( zoomInButton );
50 50
51 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); 51 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane );
52 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); 52 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) );
53 buttonLayout->addWidget( zoomOutButton ); 53 buttonLayout->addWidget( zoomOutButton );
54 54
55 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); 55 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane );
56 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); 56 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) );
57 buttonLayout->addWidget( centerButton ); 57 buttonLayout->addWidget( centerButton );
58 58
59 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), 59 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)),
60 mTimeLine,SLOT(setContentsPos(int))); 60 mTimeLine,SLOT(setContentsPos(int)));
61} 61}
62 62
63TimeSpanView::~TimeSpanView() 63TimeSpanView::~TimeSpanView()
64{ 64{
65} 65}
66 66
67QValueList<int> TimeSpanView::splitterSizes() 67QValueList<int> TimeSpanView::splitterSizes()
68{ 68{
69 return mSplitter->sizes(); 69 return mSplitter->sizes();
70} 70}
71 71
72void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) 72void TimeSpanView::setSplitterSizes( QValueList<int> sizes )
73{ 73{
74 mSplitter->setSizes( sizes ); 74 mSplitter->setSizes( sizes );
75} 75}
76 76
77void TimeSpanView::addItem( KCal::Event *event ) 77void TimeSpanView::addItem( KCal::Event *event )
78{ 78{
79 new QListViewItem( mList, event->summary() ); 79 new QListViewItem( mList, event->summary() );
80 80
81 QDateTime startDt = event->dtStart(); 81 QDateTime startDt = event->dtStart();
82 QDateTime endDt = event->dtEnd(); 82 QDateTime endDt = event->dtEnd();
83 83
84// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() 84// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString()
85// << " end: " << endDt.toString() << endl; 85// << " end: " << endDt.toString() << endl;
86 86
87 int startSecs = mStartDate.secsTo( startDt ); 87 int startSecs = mStartDate.secsTo( startDt );
88 int durationSecs = startDt.secsTo( endDt ); 88 int durationSecs = startDt.secsTo( endDt );
89 89
90// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; 90// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl;
91 91
92 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; 92 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel;
93 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; 93 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel;
94 94
95// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; 95// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl;
96 96
97 mLineView->addLine( startX, endX ); 97 mLineView->addLine( startX, endX );
98} 98}
99 99
100void TimeSpanView::clear() 100void TimeSpanView::clear()
101{ 101{
102 mList->clear(); 102 mList->clear();
103 mLineView->clear(); 103 mLineView->clear();
104} 104}
105 105
106void TimeSpanView::updateView() 106void TimeSpanView::updateView()
107{ 107{
108#if QT_VERSION >= 300 108#if QT_VERSION >= 0x030000
109 mLineView->updateContents(); 109 mLineView->updateContents();
110 mTimeLine->updateContents(); 110 mTimeLine->updateContents();
111#else 111#else
112#endif 112#endif
113} 113}
114 114
115void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) 115void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end )
116{ 116{
117 mStartDate = start; 117 mStartDate = start;
118 mEndDate = end; 118 mEndDate = end;
119 119
120 mTimeLine->setDateRange( start, end ); 120 mTimeLine->setDateRange( start, end );
121 121
122 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); 122 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth();
123} 123}
124 124
125QDateTime TimeSpanView::startDateTime() 125QDateTime TimeSpanView::startDateTime()
126{ 126{
127 return mStartDate; 127 return mStartDate;
128} 128}
129 129
130QDateTime TimeSpanView::endDateTime() 130QDateTime TimeSpanView::endDateTime()
131{ 131{
132 return mEndDate; 132 return mEndDate;
133} 133}
134 134
135void TimeSpanView::zoomIn() 135void TimeSpanView::zoomIn()
136{ 136{
137 int span = mStartDate.daysTo( mEndDate ); 137 int span = mStartDate.daysTo( mEndDate );
138 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); 138 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) );
139 139
140 emit dateRangeChanged(); 140 emit dateRangeChanged();
141} 141}
142 142
143void TimeSpanView::zoomOut() 143void TimeSpanView::zoomOut()
144{ 144{
145 int span = mStartDate.daysTo( mEndDate ); 145 int span = mStartDate.daysTo( mEndDate );
146 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); 146 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) );
147 147
148 emit dateRangeChanged(); 148 emit dateRangeChanged();
149} 149}
150 150
151void TimeSpanView::centerView() 151void TimeSpanView::centerView()
152{ 152{
153 QScrollBar *scrollBar = mLineView->horizontalScrollBar(); 153 QScrollBar *scrollBar = mLineView->horizontalScrollBar();
154 int min = scrollBar->minValue(); 154 int min = scrollBar->minValue();
155 int max = scrollBar->maxValue(); 155 int max = scrollBar->maxValue();
156 scrollBar->setValue( min + (max-min) / 2 ); 156 scrollBar->setValue( min + (max-min) / 2 );
157} 157}
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index c23978d..bd13132 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -14,389 +14,385 @@
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qfile.h> 24#include <qfile.h>
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <kglobal.h> 28#include <kglobal.h>
29 29
30extern "C" { 30extern "C" {
31 #include <ical.h> 31 #include <ical.h>
32 #include <icalss.h> 32 #include <icalss.h>
33 #include <icalparser.h> 33 #include <icalparser.h>
34 #include <icalrestriction.h> 34 #include <icalrestriction.h>
35} 35}
36 36
37#include "calendar.h" 37#include "calendar.h"
38#include "journal.h" 38#include "journal.h"
39#include "icalformat.h" 39#include "icalformat.h"
40#include "icalformatimpl.h" 40#include "icalformatimpl.h"
41#include "compat.h" 41#include "compat.h"
42 42
43#define _ICAL_VERSION "2.0" 43#define _ICAL_VERSION "2.0"
44 44
45using namespace KCal; 45using namespace KCal;
46 46
47const int gSecondsPerMinute = 60; 47const int gSecondsPerMinute = 60;
48const int gSecondsPerHour = gSecondsPerMinute * 60; 48const int gSecondsPerHour = gSecondsPerMinute * 60;
49const int gSecondsPerDay = gSecondsPerHour * 24; 49const int gSecondsPerDay = gSecondsPerHour * 24;
50const int gSecondsPerWeek = gSecondsPerDay * 7; 50const int gSecondsPerWeek = gSecondsPerDay * 7;
51 51
52ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : 52ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) :
53 mParent( parent ), mCalendarVersion( 0 ) 53 mParent( parent ), mCalendarVersion( 0 )
54{ 54{
55 mCompat = new Compat; 55 mCompat = new Compat;
56} 56}
57 57
58ICalFormatImpl::~ICalFormatImpl() 58ICalFormatImpl::~ICalFormatImpl()
59{ 59{
60 delete mCompat; 60 delete mCompat;
61} 61}
62 62
63class ToStringVisitor : public Incidence::Visitor 63class ToStringVisitor : public Incidence::Visitor
64{ 64{
65 public: 65 public:
66 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} 66 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {}
67 67
68 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } 68 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; }
69 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } 69 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; }
70 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } 70 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; }
71 71
72 icalcomponent *component() { return mComponent; } 72 icalcomponent *component() { return mComponent; }
73 73
74 private: 74 private:
75 ICalFormatImpl *mImpl; 75 ICalFormatImpl *mImpl;
76 icalcomponent *mComponent; 76 icalcomponent *mComponent;
77}; 77};
78 78
79icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) 79icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence)
80{ 80{
81 ToStringVisitor v( this ); 81 ToStringVisitor v( this );
82 incidence->accept(v); 82 incidence->accept(v);
83 return v.component(); 83 return v.component();
84} 84}
85 85
86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) 86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo)
87{ 87{
88 QString tmpStr; 88 QString tmpStr;
89 QStringList tmpStrList; 89 QStringList tmpStrList;
90 90
91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); 91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
92 92
93 writeIncidence(vtodo,todo); 93 writeIncidence(vtodo,todo);
94 94
95 // due date 95 // due date
96 if (todo->hasDueDate()) { 96 if (todo->hasDueDate()) {
97 icaltimetype due; 97 icaltimetype due;
98 if (todo->doesFloat()) { 98 if (todo->doesFloat()) {
99 due = writeICalDate(todo->dtDue().date()); 99 due = writeICalDate(todo->dtDue().date());
100 } else { 100 } else {
101 due = writeICalDateTime(todo->dtDue()); 101 due = writeICalDateTime(todo->dtDue());
102 } 102 }
103 icalcomponent_add_property(vtodo,icalproperty_new_due(due)); 103 icalcomponent_add_property(vtodo,icalproperty_new_due(due));
104 } 104 }
105 105
106 // start time 106 // start time
107 if (todo->hasStartDate()) { 107 if (todo->hasStartDate()) {
108 icaltimetype start; 108 icaltimetype start;
109 if (todo->doesFloat()) { 109 if (todo->doesFloat()) {
110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; 110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl;
111 start = writeICalDate(todo->dtStart().date()); 111 start = writeICalDate(todo->dtStart().date());
112 } else { 112 } else {
113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; 113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl;
114 start = writeICalDateTime(todo->dtStart()); 114 start = writeICalDateTime(todo->dtStart());
115 } 115 }
116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); 116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start));
117 } 117 }
118 118
119 // completion date 119 // completion date
120 if (todo->isCompleted()) { 120 if (todo->isCompleted()) {
121 if (!todo->hasCompletedDate()) { 121 if (!todo->hasCompletedDate()) {
122 // If todo was created by KOrganizer <2.2 it has no correct completion 122 // If todo was created by KOrganizer <2.2 it has no correct completion
123 // date. Set it to now. 123 // date. Set it to now.
124 todo->setCompleted(QDateTime::currentDateTime()); 124 todo->setCompleted(QDateTime::currentDateTime());
125 } 125 }
126 icaltimetype completed = writeICalDateTime(todo->completed()); 126 icaltimetype completed = writeICalDateTime(todo->completed());
127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); 127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed));
128 } 128 }
129 129
130 icalcomponent_add_property(vtodo, 130 icalcomponent_add_property(vtodo,
131 icalproperty_new_percentcomplete(todo->percentComplete())); 131 icalproperty_new_percentcomplete(todo->percentComplete()));
132 132
133 return vtodo; 133 return vtodo;
134} 134}
135 135
136icalcomponent *ICalFormatImpl::writeEvent(Event *event) 136icalcomponent *ICalFormatImpl::writeEvent(Event *event)
137{ 137{
138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() 138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid()
139 << ")" << endl; 139 << ")" << endl;
140 140
141 QString tmpStr; 141 QString tmpStr;
142 QStringList tmpStrList; 142 QStringList tmpStrList;
143 143
144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); 144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
145 145
146 writeIncidence(vevent,event); 146 writeIncidence(vevent,event);
147 147
148 // start time 148 // start time
149 icaltimetype start; 149 icaltimetype start;
150 if (event->doesFloat()) { 150 if (event->doesFloat()) {
151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
152 start = writeICalDate(event->dtStart().date()); 152 start = writeICalDate(event->dtStart().date());
153 } else { 153 } else {
154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
155 start = writeICalDateTime(event->dtStart()); 155 start = writeICalDateTime(event->dtStart());
156 } 156 }
157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); 157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start));
158 158
159 if (event->hasEndDate()) { 159 if (event->hasEndDate()) {
160 // end time 160 // end time
161 icaltimetype end; 161 icaltimetype end;
162 if (event->doesFloat()) { 162 if (event->doesFloat()) {
163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; 163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl;
164 // +1 day because end date is non-inclusive. 164 // +1 day because end date is non-inclusive.
165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); 165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) );
166 } else { 166 } else {
167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; 167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl;
168 end = writeICalDateTime(event->dtEnd()); 168 end = writeICalDateTime(event->dtEnd());
169 } 169 }
170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); 170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end));
171 } 171 }
172 172
173// TODO: attachments, resources 173// TODO: attachments, resources
174#if 0 174#if 0
175 // attachments 175 // attachments
176 tmpStrList = anEvent->attachments(); 176 tmpStrList = anEvent->attachments();
177 for ( QStringList::Iterator it = tmpStrList.begin(); 177 for ( QStringList::Iterator it = tmpStrList.begin();
178 it != tmpStrList.end(); 178 it != tmpStrList.end();
179 ++it ) 179 ++it )
180 addPropValue(vevent, VCAttachProp, (*it).utf8()); 180 addPropValue(vevent, VCAttachProp, (*it).utf8());
181 181
182 // resources 182 // resources
183 tmpStrList = anEvent->resources(); 183 tmpStrList = anEvent->resources();
184 tmpStr = tmpStrList.join(";"); 184 tmpStr = tmpStrList.join(";");
185 if (!tmpStr.isEmpty()) 185 if (!tmpStr.isEmpty())
186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); 186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8());
187 187
188#endif 188#endif
189 189
190 // Transparency 190 // Transparency
191 switch( event->transparency() ) { 191 switch( event->transparency() ) {
192 case Event::Transparent: 192 case Event::Transparent:
193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); 193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT));
194 break; 194 break;
195 case Event::Opaque: 195 case Event::Opaque:
196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); 196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
197 break; 197 break;
198 } 198 }
199 199
200 return vevent; 200 return vevent;
201} 201}
202 202
203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, 203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
204 Scheduler::Method method) 204 Scheduler::Method method)
205{ 205{
206#if QT_VERSION >= 300 206
207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: "
208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: "
209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl;
210#endif
211 207
212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); 208 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
213 209
214 writeIncidenceBase(vfreebusy,freebusy); 210 writeIncidenceBase(vfreebusy,freebusy);
215 211
216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 212 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
217 writeICalDateTime(freebusy->dtStart()))); 213 writeICalDateTime(freebusy->dtStart())));
218 214
219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
220 writeICalDateTime(freebusy->dtEnd()))); 216 writeICalDateTime(freebusy->dtEnd())));
221 217
222 if (method == Scheduler::Request) { 218 if (method == Scheduler::Request) {
223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
224 freebusy->uid().utf8())); 220 freebusy->uid().utf8()));
225 } 221 }
226 222
227 //Loops through all the periods in the freebusy object 223 //Loops through all the periods in the freebusy object
228 QValueList<Period> list = freebusy->busyPeriods(); 224 QValueList<Period> list = freebusy->busyPeriods();
229 QValueList<Period>::Iterator it; 225 QValueList<Period>::Iterator it;
230 icalperiodtype period; 226 icalperiodtype period;
231 for (it = list.begin(); it!= list.end(); ++it) { 227 for (it = list.begin(); it!= list.end(); ++it) {
232 period.start = writeICalDateTime((*it).start()); 228 period.start = writeICalDateTime((*it).start());
233 period.end = writeICalDateTime((*it).end()); 229 period.end = writeICalDateTime((*it).end());
234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
235 } 231 }
236 232
237 return vfreebusy; 233 return vfreebusy;
238} 234}
239 235
240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
241{ 237{
242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 238 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
243 239
244 writeIncidence(vjournal,journal); 240 writeIncidence(vjournal,journal);
245 241
246 // start time 242 // start time
247 if (journal->dtStart().isValid()) { 243 if (journal->dtStart().isValid()) {
248 icaltimetype start; 244 icaltimetype start;
249 if (journal->doesFloat()) { 245 if (journal->doesFloat()) {
250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 246// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
251 start = writeICalDate(journal->dtStart().date()); 247 start = writeICalDate(journal->dtStart().date());
252 } else { 248 } else {
253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 249// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
254 start = writeICalDateTime(journal->dtStart()); 250 start = writeICalDateTime(journal->dtStart());
255 } 251 }
256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 252 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
257 } 253 }
258 254
259 return vjournal; 255 return vjournal;
260} 256}
261 257
262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 258void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
263{ 259{
264 // pilot sync stuff 260 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 261// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 262 if (incidence->pilotId()) {
267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 263 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 264 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
269 } 265 }
270 if ( !incidence->IDStr().isEmpty()) { 266 if ( !incidence->IDStr().isEmpty()) {
271 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); 267 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
272 } 268 }
273 269
274 270
275 writeIncidenceBase(parent,incidence); 271 writeIncidenceBase(parent,incidence);
276 if (incidence->cancelled()) { 272 if (incidence->cancelled()) {
277 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 273 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
278 } 274 }
279 275
280 // creation date 276 // creation date
281 icalcomponent_add_property(parent,icalproperty_new_created( 277 icalcomponent_add_property(parent,icalproperty_new_created(
282 writeICalDateTime(incidence->created()))); 278 writeICalDateTime(incidence->created())));
283 279
284 // unique id 280 // unique id
285 icalcomponent_add_property(parent,icalproperty_new_uid( 281 icalcomponent_add_property(parent,icalproperty_new_uid(
286 incidence->uid().utf8())); 282 incidence->uid().utf8()));
287 283
288 // revision 284 // revision
289 icalcomponent_add_property(parent,icalproperty_new_sequence( 285 icalcomponent_add_property(parent,icalproperty_new_sequence(
290 incidence->revision())); 286 incidence->revision()));
291 287
292 // last modification date 288 // last modification date
293 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 289 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
294 writeICalDateTime(incidence->lastModified()))); 290 writeICalDateTime(incidence->lastModified())));
295 291
296 // description 292 // description
297 if (!incidence->description().isEmpty()) { 293 if (!incidence->description().isEmpty()) {
298 icalcomponent_add_property(parent,icalproperty_new_description( 294 icalcomponent_add_property(parent,icalproperty_new_description(
299 incidence->description().utf8())); 295 incidence->description().utf8()));
300 } 296 }
301 297
302 // summary 298 // summary
303 if (!incidence->summary().isEmpty()) { 299 if (!incidence->summary().isEmpty()) {
304 icalcomponent_add_property(parent,icalproperty_new_summary( 300 icalcomponent_add_property(parent,icalproperty_new_summary(
305 incidence->summary().utf8())); 301 incidence->summary().utf8()));
306 } 302 }
307 303
308 // location 304 // location
309 if (!incidence->location().isEmpty()) { 305 if (!incidence->location().isEmpty()) {
310 icalcomponent_add_property(parent,icalproperty_new_location( 306 icalcomponent_add_property(parent,icalproperty_new_location(
311 incidence->location().utf8())); 307 incidence->location().utf8()));
312 } 308 }
313 309
314// TODO: 310// TODO:
315 // status 311 // status
316// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
317 313
318 // secrecy 314 // secrecy
319 enum icalproperty_class classInt; 315 enum icalproperty_class classInt;
320 switch (incidence->secrecy()) { 316 switch (incidence->secrecy()) {
321 case Incidence::SecrecyPublic: 317 case Incidence::SecrecyPublic:
322 classInt = ICAL_CLASS_PUBLIC; 318 classInt = ICAL_CLASS_PUBLIC;
323 break; 319 break;
324 case Incidence::SecrecyConfidential: 320 case Incidence::SecrecyConfidential:
325 classInt = ICAL_CLASS_CONFIDENTIAL; 321 classInt = ICAL_CLASS_CONFIDENTIAL;
326 break; 322 break;
327 case Incidence::SecrecyPrivate: 323 case Incidence::SecrecyPrivate:
328 classInt =ICAL_CLASS_PRIVATE ; 324 classInt =ICAL_CLASS_PRIVATE ;
329 default: 325 default:
330 classInt =ICAL_CLASS_PRIVATE ; 326 classInt =ICAL_CLASS_PRIVATE ;
331 break; 327 break;
332 } 328 }
333 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 329 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
334 330
335 // priority 331 // priority
336 icalcomponent_add_property(parent,icalproperty_new_priority( 332 icalcomponent_add_property(parent,icalproperty_new_priority(
337 incidence->priority())); 333 incidence->priority()));
338 334
339 // categories 335 // categories
340 QStringList categories = incidence->categories(); 336 QStringList categories = incidence->categories();
341 QStringList::Iterator it; 337 QStringList::Iterator it;
342 for(it = categories.begin(); it != categories.end(); ++it ) { 338 for(it = categories.begin(); it != categories.end(); ++it ) {
343 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
344 } 340 }
345// TODO: Ensure correct concatenation of categories properties. 341// TODO: Ensure correct concatenation of categories properties.
346 342
347/* 343/*
348 // categories 344 // categories
349 tmpStrList = incidence->getCategories(); 345 tmpStrList = incidence->getCategories();
350 tmpStr = ""; 346 tmpStr = "";
351 QString catStr; 347 QString catStr;
352 for ( QStringList::Iterator it = tmpStrList.begin(); 348 for ( QStringList::Iterator it = tmpStrList.begin();
353 it != tmpStrList.end(); 349 it != tmpStrList.end();
354 ++it ) { 350 ++it ) {
355 catStr = *it; 351 catStr = *it;
356 if (catStr[0] == ' ') 352 if (catStr[0] == ' ')
357 tmpStr += catStr.mid(1); 353 tmpStr += catStr.mid(1);
358 else 354 else
359 tmpStr += catStr; 355 tmpStr += catStr;
360 // this must be a ';' character as the vCalendar specification requires! 356 // this must be a ';' character as the vCalendar specification requires!
361 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
362 // read in. 358 // read in.
363 tmpStr += ";"; 359 tmpStr += ";";
364 } 360 }
365 if (!tmpStr.isEmpty()) { 361 if (!tmpStr.isEmpty()) {
366 tmpStr.truncate(tmpStr.length()-1); 362 tmpStr.truncate(tmpStr.length()-1);
367 icalcomponent_add_property(parent,icalproperty_new_categories( 363 icalcomponent_add_property(parent,icalproperty_new_categories(
368 writeText(incidence->getCategories().join(";")))); 364 writeText(incidence->getCategories().join(";"))));
369 } 365 }
370*/ 366*/
371 367
372 // related event 368 // related event
373 if (incidence->relatedTo()) { 369 if (incidence->relatedTo()) {
374 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
375 incidence->relatedTo()->uid().utf8())); 371 incidence->relatedTo()->uid().utf8()));
376 } 372 }
377 373
378 // recurrence rule stuff 374 // recurrence rule stuff
379 Recurrence *recur = incidence->recurrence(); 375 Recurrence *recur = incidence->recurrence();
380 if (recur->doesRecur()) { 376 if (recur->doesRecur()) {
381 377
382 icalcomponent_add_property(parent,writeRecurrenceRule(recur)); 378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
383 } 379 }
384 380
385 // recurrence excpetion dates 381 // recurrence excpetion dates
386 DateList dateList = incidence->exDates(); 382 DateList dateList = incidence->exDates();
387 DateList::ConstIterator exIt; 383 DateList::ConstIterator exIt;
388 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
389 icalcomponent_add_property(parent,icalproperty_new_exdate( 385 icalcomponent_add_property(parent,icalproperty_new_exdate(
390 writeICalDate(*exIt))); 386 writeICalDate(*exIt)));
391 } 387 }
392 388
393 // attachments 389 // attachments
394 QPtrList<Attachment> attachments = incidence->attachments(); 390 QPtrList<Attachment> attachments = incidence->attachments();
395 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
396 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
397 393
398 // alarms 394 // alarms
399 QPtrList<Alarm> alarms = incidence->alarms(); 395 QPtrList<Alarm> alarms = incidence->alarms();
400 Alarm* alarm; 396 Alarm* alarm;
401 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
402 if (alarm->enabled()) { 398 if (alarm->enabled()) {
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 60b8bc7..567ae54 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,232 +1,232 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 300 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 //setMaximumHeight( 5 ); // test only 83 //setMaximumHeight( 5 ); // test only
84} 84}
85 85
86QSize KDGanttSplitterHandle::sizeHint() const 86QSize KDGanttSplitterHandle::sizeHint() const
87{ 87{
88 return mSizeHint; 88 return mSizeHint;
89} 89}
90 90
91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
92{ 92{
93 orient = o; 93 orient = o;
94#ifndef QT_NO_CURSOR 94#ifndef QT_NO_CURSOR
95 if ( o == KDGanttMinimizeSplitter::Horizontal ) 95 if ( o == KDGanttMinimizeSplitter::Horizontal )
96 setCursor( splitHCursor ); 96 setCursor( splitHCursor );
97 else 97 else
98 setCursor( splitVCursor ); 98 setCursor( splitVCursor );
99#endif 99#endif
100} 100}
101 101
102 102
103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
104{ 104{
105 updateCursor( e->pos() ); 105 updateCursor( e->pos() );
106 if ( !(e->state()&LeftButton) ) 106 if ( !(e->state()&LeftButton) )
107 return; 107 return;
108 108
109 if ( _activeButton != 0) 109 if ( _activeButton != 0)
110 return; 110 return;
111 111
112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
113 - mouseOffset; 113 - mouseOffset;
114 if ( true /*opaque()*/ ) { 114 if ( true /*opaque()*/ ) {
115 s->moveSplitter( pos, id() ); 115 s->moveSplitter( pos, id() );
116 } else { 116 } else {
117 int min = pos; int max = pos; 117 int min = pos; int max = pos;
118 s->getRange( id(), &min, &max ); 118 s->getRange( id(), &min, &max );
119 s->setRubberband( QMAX( min, QMIN(max, pos ))); 119 s->setRubberband( QMAX( min, QMIN(max, pos )));
120 } 120 }
121 _collapsed = false; 121 _collapsed = false;
122} 122}
123 123
124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
125{ 125{
126 if ( e->button() == LeftButton ) { 126 if ( e->button() == LeftButton ) {
127 _activeButton = onButton( e->pos() ); 127 _activeButton = onButton( e->pos() );
128 mouseOffset = s->pick(e->pos()); 128 mouseOffset = s->pick(e->pos());
129 if ( _activeButton != 0) 129 if ( _activeButton != 0)
130 repaint(); 130 repaint();
131 updateCursor( e->pos() ); 131 updateCursor( e->pos() );
132 } 132 }
133} 133}
134 134
135void KDGanttSplitterHandle::updateCursor( const QPoint& p) 135void KDGanttSplitterHandle::updateCursor( const QPoint& p)
136{ 136{
137 if ( onButton( p ) != 0 ) { 137 if ( onButton( p ) != 0 ) {
138 setCursor( arrowCursor ); 138 setCursor( arrowCursor );
139 } 139 }
140 else { 140 else {
141 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 141 if ( orient == KDGanttMinimizeSplitter::Horizontal )
142 setCursor( splitHCursor ); 142 setCursor( splitHCursor );
143 else 143 else
144 setCursor( splitVCursor ); 144 setCursor( splitVCursor );
145 } 145 }
146} 146}
147void KDGanttSplitterHandle::toggle() 147void KDGanttSplitterHandle::toggle()
148{ 148{
149 int pos; 149 int pos;
150 int min, max; 150 int min, max;
151 if ( !_collapsed ) { 151 if ( !_collapsed ) {
152 s->expandPos( id(), &min, &max ); 152 s->expandPos( id(), &min, &max );
153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
155 pos = min; 155 pos = min;
156 } 156 }
157 else { 157 else {
158 pos = max; 158 pos = max;
159 } 159 }
160 160
161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
162 s->moveSplitter( pos, id() ); 162 s->moveSplitter( pos, id() );
163 _collapsed = true; 163 _collapsed = true;
164 } 164 }
165 else { 165 else {
166 s->moveSplitter( _origPos, id() ); 166 s->moveSplitter( _origPos, id() );
167 _collapsed = false; 167 _collapsed = false;
168 } 168 }
169} 169}
170 170
171void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 171void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
172{ 172{
173 if ( _activeButton != 0 ) { 173 if ( _activeButton != 0 ) {
174 if ( onButton( e->pos() ) == _activeButton ) 174 if ( onButton( e->pos() ) == _activeButton )
175 { 175 {
176 toggle(); 176 toggle();
177 } 177 }
178 _activeButton = 0; 178 _activeButton = 0;
179 updateCursor( e->pos() ); 179 updateCursor( e->pos() );
180 } 180 }
181 else { 181 else {
182 if ( !opaque() && e->button() == LeftButton ) { 182 if ( !opaque() && e->button() == LeftButton ) {
183 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 183 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
184 - mouseOffset; 184 - mouseOffset;
185 s->setRubberband( -1 ); 185 s->setRubberband( -1 );
186 s->moveSplitter( pos, id() ); 186 s->moveSplitter( pos, id() );
187 } 187 }
188 } 188 }
189 repaint(); 189 repaint();
190} 190}
191 191
192int KDGanttSplitterHandle::onButton( const QPoint& p ) 192int KDGanttSplitterHandle::onButton( const QPoint& p )
193{ 193{
194 QValueList<QPointArray> list = buttonRegions(); 194 QValueList<QPointArray> list = buttonRegions();
195 int index = 1; 195 int index = 1;
196 int add = 12; 196 int add = 12;
197 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 197 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
198 QRect rect = (*it).boundingRect(); 198 QRect rect = (*it).boundingRect();
199 rect.setLeft( rect.left()- add ); 199 rect.setLeft( rect.left()- add );
200 rect.setRight( rect.right() + add); 200 rect.setRight( rect.right() + add);
201 rect.setTop( rect.top()- add ); 201 rect.setTop( rect.top()- add );
202 rect.setBottom( rect.bottom() + add); 202 rect.setBottom( rect.bottom() + add);
203 if ( rect.contains( p ) ) { 203 if ( rect.contains( p ) ) {
204 return index; 204 return index;
205 } 205 }
206 index++; 206 index++;
207 } 207 }
208 return 0; 208 return 0;
209} 209}
210 210
211 211
212QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 212QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
213{ 213{
214 QValueList<QPointArray> list; 214 QValueList<QPointArray> list;
215 215
216 int sw = 8; 216 int sw = 8;
217 int yyy = 1; 217 int yyy = 1;
218 int xxx = 1; 218 int xxx = 1;
219 int voffset[] = { (int) -sw*3, (int) sw*3 }; 219 int voffset[] = { (int) -sw*3, (int) sw*3 };
220 for ( int i = 0; i < 2; i++ ) { 220 for ( int i = 0; i < 2; i++ ) {
221 QPointArray arr; 221 QPointArray arr;
222 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 222 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
223 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 223 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
224 int mid = height()/2 + voffset[i]; 224 int mid = height()/2 + voffset[i];
225 arr.setPoints( 3, 225 arr.setPoints( 3,
226 1-xxx, mid - sw + 4, 226 1-xxx, mid - sw + 4,
227 sw-3-xxx, mid, 227 sw-3-xxx, mid,
228 1-xxx, mid + sw -4); 228 1-xxx, mid + sw -4);
229 } 229 }
230 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 230 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
231 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 231 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
232 int mid = height()/2 + voffset[i]; 232 int mid = height()/2 + voffset[i];
@@ -438,667 +438,667 @@ KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *n
438 mFirstHandle = 0; 438 mFirstHandle = 0;
439#if QT_VERSION >= 232 439#if QT_VERSION >= 232
440 orient = Horizontal; 440 orient = Horizontal;
441 init(); 441 init();
442#endif 442#endif
443} 443}
444 444
445/*! 445/*!
446 Constructs a splitter with orientation \a o with the \a parent 446 Constructs a splitter with orientation \a o with the \a parent
447 and \a name arguments being passed on to the QFrame constructor. 447 and \a name arguments being passed on to the QFrame constructor.
448*/ 448*/
449KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 449KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
450 :QFrame(parent,name,WPaintUnclipped) 450 :QFrame(parent,name,WPaintUnclipped)
451{ 451{
452 mFirstHandle = 0; 452 mFirstHandle = 0;
453#if QT_VERSION >= 232 453#if QT_VERSION >= 232
454 orient = o; 454 orient = o;
455 init(); 455 init();
456#endif 456#endif
457} 457}
458 458
459/*! 459/*!
460 Destroys the splitter and any children. 460 Destroys the splitter and any children.
461*/ 461*/
462KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 462KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
463{ 463{
464#if QT_VERSION >= 232 464#if QT_VERSION >= 232
465 data->list.setAutoDelete( TRUE ); 465 data->list.setAutoDelete( TRUE );
466 delete data; 466 delete data;
467#endif 467#endif
468} 468}
469 469
470 470
471#if QT_VERSION >= 232 471#if QT_VERSION >= 232
472void KDGanttMinimizeSplitter::init() 472void KDGanttMinimizeSplitter::init()
473{ 473{
474 data = new QSplitterData; 474 data = new QSplitterData;
475 if ( orient == Horizontal ) 475 if ( orient == Horizontal )
476 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 476 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
477 else 477 else
478 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 478 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
479} 479}
480#endif 480#endif
481 481
482 482
483 483
484/*! 484/*!
485 \brief the orientation of the splitter 485 \brief the orientation of the splitter
486 486
487 By default the orientation is horizontal (the widgets are side by side). 487 By default the orientation is horizontal (the widgets are side by side).
488 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 488 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
489*/ 489*/
490void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 490void KDGanttMinimizeSplitter::setOrientation( Orientation o )
491{ 491{
492#if QT_VERSION >= 232 492#if QT_VERSION >= 232
493 if ( orient == o ) 493 if ( orient == o )
494 return; 494 return;
495 orient = o; 495 orient = o;
496 496
497 if ( orient == Horizontal ) 497 if ( orient == Horizontal )
498 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 498 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
499 else 499 else
500 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 500 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
501 501
502 QSplitterLayoutStruct *s = data->list.first(); 502 QSplitterLayoutStruct *s = data->list.first();
503 while ( s ) { 503 while ( s ) {
504 if ( s->isSplitter ) 504 if ( s->isSplitter )
505 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 505 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
506 s = data->list.next(); // ### next at end of loop, no iterator 506 s = data->list.next(); // ### next at end of loop, no iterator
507 } 507 }
508 recalc( isVisible() ); 508 recalc( isVisible() );
509#endif 509#endif
510} 510}
511 511
512 512
513#if QT_VERSION >= 232 513#if QT_VERSION >= 232
514/*! 514/*!
515 \reimp 515 \reimp
516*/ 516*/
517void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 517void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
518{ 518{
519 doResize(); 519 doResize();
520} 520}
521 521
522 522
523/* 523/*
524 Inserts the widget \a w at the end (or at the beginning if \a first 524 Inserts the widget \a w at the end (or at the beginning if \a first
525 is TRUE) of the splitter's list of widgets. 525 is TRUE) of the splitter's list of widgets.
526 526
527 It is the responsibility of the caller of this function to make sure 527 It is the responsibility of the caller of this function to make sure
528 that \a w is not already in the splitter and to call recalcId if 528 that \a w is not already in the splitter and to call recalcId if
529 needed. (If \a first is TRUE, then recalcId is very probably 529 needed. (If \a first is TRUE, then recalcId is very probably
530 needed.) 530 needed.)
531*/ 531*/
532QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 532QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
533{ 533{
534 QSplitterLayoutStruct *s; 534 QSplitterLayoutStruct *s;
535 KDGanttSplitterHandle *newHandle = 0; 535 KDGanttSplitterHandle *newHandle = 0;
536 if ( data->list.count() > 0 ) { 536 if ( data->list.count() > 0 ) {
537 s = new QSplitterLayoutStruct; 537 s = new QSplitterLayoutStruct;
538 s->mode = KeepSize; 538 s->mode = KeepSize;
539 QString tmp = "qt_splithandle_"; 539 QString tmp = "qt_splithandle_";
540 tmp += w->name(); 540 tmp += w->name();
541 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 541 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
542 if ( ! mFirstHandle ) 542 if ( ! mFirstHandle )
543 mFirstHandle = newHandle; 543 mFirstHandle = newHandle;
544 s->wid = newHandle; 544 s->wid = newHandle;
545 newHandle->setId(data->list.count()); 545 newHandle->setId(data->list.count());
546 s->isSplitter = TRUE; 546 s->isSplitter = TRUE;
547 s->sizer = pick( newHandle->sizeHint() ); 547 s->sizer = pick( newHandle->sizeHint() );
548 if ( first ) 548 if ( first )
549 data->list.insert( 0, s ); 549 data->list.insert( 0, s );
550 else 550 else
551 data->list.append( s ); 551 data->list.append( s );
552 } 552 }
553 s = new QSplitterLayoutStruct; 553 s = new QSplitterLayoutStruct;
554 s->mode = Stretch; 554 s->mode = Stretch;
555 s->wid = w; 555 s->wid = w;
556 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 556 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
557 s->sizer = pick( w->sizeHint() ); 557 s->sizer = pick( w->sizeHint() );
558 else 558 else
559 s->sizer = pick( w->size() ); 559 s->sizer = pick( w->size() );
560 s->isSplitter = FALSE; 560 s->isSplitter = FALSE;
561 if ( first ) 561 if ( first )
562 data->list.insert( 0, s ); 562 data->list.insert( 0, s );
563 else 563 else
564 data->list.append( s ); 564 data->list.append( s );
565 if ( newHandle && isVisible() ) 565 if ( newHandle && isVisible() )
566 newHandle->show(); //will trigger sending of post events 566 newHandle->show(); //will trigger sending of post events
567 return s; 567 return s;
568} 568}
569 569
570 570
571/*! 571/*!
572 Tells the splitter that a child widget has been inserted or removed. 572 Tells the splitter that a child widget has been inserted or removed.
573 The event is passed in \a c. 573 The event is passed in \a c.
574*/ 574*/
575void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 575void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
576{ 576{
577 if ( c->type() == QEvent::ChildInserted ) { 577 if ( c->type() == QEvent::ChildInserted ) {
578 if ( !c->child()->isWidgetType() ) 578 if ( !c->child()->isWidgetType() )
579 return; 579 return;
580 580
581 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 581 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
582 return; 582 return;
583 583
584 QSplitterLayoutStruct *s = data->list.first(); 584 QSplitterLayoutStruct *s = data->list.first();
585 while ( s ) { 585 while ( s ) {
586 if ( s->wid == c->child() ) 586 if ( s->wid == c->child() )
587 return; 587 return;
588 s = data->list.next(); 588 s = data->list.next();
589 } 589 }
590 addWidget( (QWidget*)c->child() ); 590 addWidget( (QWidget*)c->child() );
591 recalc( isVisible() ); 591 recalc( isVisible() );
592 592
593 } else if ( c->type() == QEvent::ChildRemoved ) { 593 } else if ( c->type() == QEvent::ChildRemoved ) {
594 QSplitterLayoutStruct *p = 0; 594 QSplitterLayoutStruct *p = 0;
595 if ( data->list.count() > 1 ) 595 if ( data->list.count() > 1 )
596 p = data->list.at(1); //remove handle _after_ first widget. 596 p = data->list.at(1); //remove handle _after_ first widget.
597 QSplitterLayoutStruct *s = data->list.first(); 597 QSplitterLayoutStruct *s = data->list.first();
598 while ( s ) { 598 while ( s ) {
599 if ( s->wid == c->child() ) { 599 if ( s->wid == c->child() ) {
600 data->list.removeRef( s ); 600 data->list.removeRef( s );
601 delete s; 601 delete s;
602 if ( p && p->isSplitter ) { 602 if ( p && p->isSplitter ) {
603 data->list.removeRef( p ); 603 data->list.removeRef( p );
604 delete p->wid; //will call childEvent 604 delete p->wid; //will call childEvent
605 delete p; 605 delete p;
606 } 606 }
607 recalcId(); 607 recalcId();
608 doResize(); 608 doResize();
609 return; 609 return;
610 } 610 }
611 p = s; 611 p = s;
612 s = data->list.next(); 612 s = data->list.next();
613 } 613 }
614 } 614 }
615} 615}
616 616
617 617
618/*! 618/*!
619 Shows a rubber band at position \a p. If \a p is negative, the 619 Shows a rubber band at position \a p. If \a p is negative, the
620 rubber band is removed. 620 rubber band is removed.
621*/ 621*/
622void KDGanttMinimizeSplitter::setRubberband( int p ) 622void KDGanttMinimizeSplitter::setRubberband( int p )
623{ 623{
624 QPainter paint( this ); 624 QPainter paint( this );
625 paint.setPen( gray ); 625 paint.setPen( gray );
626 paint.setBrush( gray ); 626 paint.setBrush( gray );
627 paint.setRasterOp( XorROP ); 627 paint.setRasterOp( XorROP );
628 QRect r = contentsRect(); 628 QRect r = contentsRect();
629 const int rBord = 3; //Themable???? 629 const int rBord = 3; //Themable????
630#if QT_VERSION >= 300 630#if QT_VERSION >= 0x030000
631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
632#else 632#else
633 int sw = style().splitterWidth(); 633 int sw = style().splitterWidth();
634#endif 634#endif
635 if ( orient == Horizontal ) { 635 if ( orient == Horizontal ) {
636 if ( opaqueOldPos >= 0 ) 636 if ( opaqueOldPos >= 0 )
637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
638 2*rBord, r.height() ); 638 2*rBord, r.height() );
639 if ( p >= 0 ) 639 if ( p >= 0 )
640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
641 } else { 641 } else {
642 if ( opaqueOldPos >= 0 ) 642 if ( opaqueOldPos >= 0 )
643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
644 r.width(), 2*rBord ); 644 r.width(), 2*rBord );
645 if ( p >= 0 ) 645 if ( p >= 0 )
646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
647 } 647 }
648 opaqueOldPos = p; 648 opaqueOldPos = p;
649} 649}
650 650
651 651
652/*! \reimp */ 652/*! \reimp */
653bool KDGanttMinimizeSplitter::event( QEvent *e ) 653bool KDGanttMinimizeSplitter::event( QEvent *e )
654{ 654{
655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
656 recalc( isVisible() ); 656 recalc( isVisible() );
657 if ( e->type() == QEvent::Show ) 657 if ( e->type() == QEvent::Show )
658 data->firstShow = FALSE; 658 data->firstShow = FALSE;
659 } 659 }
660 return QWidget::event( e ); 660 return QWidget::event( e );
661} 661}
662 662
663 663
664/*! 664/*!
665 \obsolete 665 \obsolete
666 666
667 Draws the splitter handle in the rectangle described by \a x, \a y, 667 Draws the splitter handle in the rectangle described by \a x, \a y,
668 \a w, \a h using painter \a p. 668 \a w, \a h using painter \a p.
669 \sa QStyle::drawPrimitive() 669 \sa QStyle::drawPrimitive()
670*/ 670*/
671void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 671void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
672 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 672 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
673{ 673{
674#if 0 674#if 0
675 // LR 675 // LR
676 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 676 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
677 (orientation() == Qt::Horizontal ? 677 (orientation() == Qt::Horizontal ?
678 QStyle::Style_Horizontal : 0)); 678 QStyle::Style_Horizontal : 0));
679#endif 679#endif
680} 680}
681 681
682 682
683/*! 683/*!
684 Returns the id of the splitter to the right of or below the widget \a w, 684 Returns the id of the splitter to the right of or below the widget \a w,
685 or 0 if there is no such splitter 685 or 0 if there is no such splitter
686 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 686 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
687*/ 687*/
688int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 688int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
689{ 689{
690 QSplitterLayoutStruct *s = data->list.first(); 690 QSplitterLayoutStruct *s = data->list.first();
691 bool seen_w = FALSE; 691 bool seen_w = FALSE;
692 while ( s ) { 692 while ( s ) {
693 if ( s->isSplitter && seen_w ) 693 if ( s->isSplitter && seen_w )
694 return data->list.at(); 694 return data->list.at();
695 if ( !s->isSplitter && s->wid == w ) 695 if ( !s->isSplitter && s->wid == w )
696 seen_w = TRUE; 696 seen_w = TRUE;
697 s = data->list.next(); 697 s = data->list.next();
698 } 698 }
699 return 0; 699 return 0;
700} 700}
701 701
702 702
703/*! 703/*!
704 Moves the left/top edge of the splitter handle with id \a id as 704 Moves the left/top edge of the splitter handle with id \a id as
705 close as possible to position \a p, which is the distance from the 705 close as possible to position \a p, which is the distance from the
706 left (or top) edge of the widget. 706 left (or top) edge of the widget.
707 707
708 For Arabic and Hebrew the layout is reversed, and using this 708 For Arabic and Hebrew the layout is reversed, and using this
709 function to set the position of the splitter might lead to 709 function to set the position of the splitter might lead to
710 unexpected results, since in Arabic and Hebrew the position of 710 unexpected results, since in Arabic and Hebrew the position of
711 splitter one is to the left of the position of splitter zero. 711 splitter one is to the left of the position of splitter zero.
712 712
713 \sa idAfter() 713 \sa idAfter()
714*/ 714*/
715void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 715void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
716{ 716{
717 p = adjustPos( p, id ); 717 p = adjustPos( p, id );
718 QSplitterLayoutStruct *s = data->list.at(id); 718 QSplitterLayoutStruct *s = data->list.at(id);
719 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 719 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
720 bool upLeft; 720 bool upLeft;
721 if ( false && orient == Horizontal ) { 721 if ( false && orient == Horizontal ) {
722 p += s->wid->width(); 722 p += s->wid->width();
723 upLeft = p > oldP; 723 upLeft = p > oldP;
724 } else 724 } else
725 upLeft = p < oldP; 725 upLeft = p < oldP;
726 726
727 moveAfter( p, id, upLeft ); 727 moveAfter( p, id, upLeft );
728 moveBefore( p-1, id-1, upLeft ); 728 moveBefore( p-1, id-1, upLeft );
729 729
730 storeSizes(); 730 storeSizes();
731} 731}
732 732
733 733
734void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 734void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
735{ 735{
736 if ( orient == Horizontal ) { 736 if ( orient == Horizontal ) {
737 if ( false && orient == Horizontal && !isSplitter ) 737 if ( false && orient == Horizontal && !isSplitter )
738 p = contentsRect().width() - p - s; 738 p = contentsRect().width() - p - s;
739 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 739 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
740 } else 740 } else
741 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 741 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
742} 742}
743 743
744 744
745/* 745/*
746 Places the right/bottom edge of the widget at \a id at position \a pos. 746 Places the right/bottom edge of the widget at \a id at position \a pos.
747 747
748 \sa idAfter() 748 \sa idAfter()
749*/ 749*/
750void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 750void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
751{ 751{
752 if( id < 0 ) 752 if( id < 0 )
753 return; 753 return;
754 QSplitterLayoutStruct *s = data->list.at(id); 754 QSplitterLayoutStruct *s = data->list.at(id);
755 if ( !s ) 755 if ( !s )
756 return; 756 return;
757 QWidget *w = s->wid; 757 QWidget *w = s->wid;
758 if ( w->isHidden() ) { 758 if ( w->isHidden() ) {
759 moveBefore( pos, id-1, upLeft ); 759 moveBefore( pos, id-1, upLeft );
760 } else if ( s->isSplitter ) { 760 } else if ( s->isSplitter ) {
761 int pos1, pos2; 761 int pos1, pos2;
762 int dd = s->sizer; 762 int dd = s->sizer;
763 if( false && orient == Horizontal ) { 763 if( false && orient == Horizontal ) {
764 pos1 = pos; 764 pos1 = pos;
765 pos2 = pos + dd; 765 pos2 = pos + dd;
766 } else { 766 } else {
767 pos2 = pos - dd; 767 pos2 = pos - dd;
768 pos1 = pos2 + 1; 768 pos1 = pos2 + 1;
769 } 769 }
770 if ( upLeft ) { 770 if ( upLeft ) {
771 setG( w, pos1, dd, TRUE ); 771 setG( w, pos1, dd, TRUE );
772 moveBefore( pos2, id-1, upLeft ); 772 moveBefore( pos2, id-1, upLeft );
773 } else { 773 } else {
774 moveBefore( pos2, id-1, upLeft ); 774 moveBefore( pos2, id-1, upLeft );
775 setG( w, pos1, dd, TRUE ); 775 setG( w, pos1, dd, TRUE );
776 } 776 }
777 } else { 777 } else {
778 int dd, newLeft, nextPos; 778 int dd, newLeft, nextPos;
779 if( false && orient == Horizontal ) { 779 if( false && orient == Horizontal ) {
780 dd = w->geometry().right() - pos; 780 dd = w->geometry().right() - pos;
781 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 781 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
782 newLeft = pos+1; 782 newLeft = pos+1;
783 nextPos = newLeft + dd; 783 nextPos = newLeft + dd;
784 } else { 784 } else {
785 dd = pos - pick( w->pos() ) + 1; 785 dd = pos - pick( w->pos() ) + 1;
786 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 786 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
787 newLeft = pos-dd+1; 787 newLeft = pos-dd+1;
788 nextPos = newLeft - 1; 788 nextPos = newLeft - 1;
789 } 789 }
790 setG( w, newLeft, dd, TRUE ); 790 setG( w, newLeft, dd, TRUE );
791 moveBefore( nextPos, id-1, upLeft ); 791 moveBefore( nextPos, id-1, upLeft );
792 } 792 }
793} 793}
794 794
795 795
796/* 796/*
797 Places the left/top edge of the widget at \a id at position \a pos. 797 Places the left/top edge of the widget at \a id at position \a pos.
798 798
799 \sa idAfter() 799 \sa idAfter()
800*/ 800*/
801void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 801void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
802{ 802{
803 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 803 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
804 data->list.at(id) : 0; 804 data->list.at(id) : 0;
805 if ( !s ) 805 if ( !s )
806 return; 806 return;
807 QWidget *w = s->wid; 807 QWidget *w = s->wid;
808 if ( w->isHidden() ) { 808 if ( w->isHidden() ) {
809 moveAfter( pos, id+1, upLeft ); 809 moveAfter( pos, id+1, upLeft );
810 } else if ( pick( w->pos() ) == pos ) { 810 } else if ( pick( w->pos() ) == pos ) {
811 //No need to do anything if it's already there. 811 //No need to do anything if it's already there.
812 return; 812 return;
813 } else if ( s->isSplitter ) { 813 } else if ( s->isSplitter ) {
814 int dd = s->sizer; 814 int dd = s->sizer;
815 int pos1, pos2; 815 int pos1, pos2;
816 if( false && orient == Horizontal ) { 816 if( false && orient == Horizontal ) {
817 pos2 = pos - dd; 817 pos2 = pos - dd;
818 pos1 = pos2 + 1; 818 pos1 = pos2 + 1;
819 } else { 819 } else {
820 pos1 = pos; 820 pos1 = pos;
821 pos2 = pos + dd; 821 pos2 = pos + dd;
822 } 822 }
823 if ( upLeft ) { 823 if ( upLeft ) {
824 setG( w, pos1, dd, TRUE ); 824 setG( w, pos1, dd, TRUE );
825 moveAfter( pos2, id+1, upLeft ); 825 moveAfter( pos2, id+1, upLeft );
826 } else { 826 } else {
827 moveAfter( pos2, id+1, upLeft ); 827 moveAfter( pos2, id+1, upLeft );
828 setG( w, pos1, dd, TRUE ); 828 setG( w, pos1, dd, TRUE );
829 } 829 }
830 } else { 830 } else {
831 int left = pick( w->pos() ); 831 int left = pick( w->pos() );
832 int right, dd,/* newRight,*/ newLeft, nextPos; 832 int right, dd,/* newRight,*/ newLeft, nextPos;
833 if ( false && orient == Horizontal ) { 833 if ( false && orient == Horizontal ) {
834 dd = pos - left + 1; 834 dd = pos - left + 1;
835 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 835 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
836 newLeft = pos-dd+1; 836 newLeft = pos-dd+1;
837 nextPos = newLeft - 1; 837 nextPos = newLeft - 1;
838 } else { 838 } else {
839 right = pick( w->geometry().bottomRight() ); 839 right = pick( w->geometry().bottomRight() );
840 dd = right - pos + 1; 840 dd = right - pos + 1;
841 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 841 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
842 /*newRight = pos+dd-1;*/ 842 /*newRight = pos+dd-1;*/
843 newLeft = pos; 843 newLeft = pos;
844 nextPos = newLeft + dd; 844 nextPos = newLeft + dd;
845 } 845 }
846 setG( w, newLeft, dd, TRUE ); 846 setG( w, newLeft, dd, TRUE );
847 /*if( right != newRight )*/ 847 /*if( right != newRight )*/
848 moveAfter( nextPos, id+1, upLeft ); 848 moveAfter( nextPos, id+1, upLeft );
849 } 849 }
850} 850}
851 851
852 852
853void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 853void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
854{ 854{
855 QSplitterLayoutStruct *s = data->list.at(id-1); 855 QSplitterLayoutStruct *s = data->list.at(id-1);
856 QWidget* w = s->wid; 856 QWidget* w = s->wid;
857 *min = pick( w->mapToParent( QPoint(0,0) ) ); 857 *min = pick( w->mapToParent( QPoint(0,0) ) );
858 858
859 if ( (uint) id == data->list.count() ) { 859 if ( (uint) id == data->list.count() ) {
860 pick( size() ); 860 pick( size() );
861 } 861 }
862 else { 862 else {
863 QSplitterLayoutStruct *s = data->list.at(id+1); 863 QSplitterLayoutStruct *s = data->list.at(id+1);
864 QWidget* w = s->wid; 864 QWidget* w = s->wid;
865 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 865 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
866 } 866 }
867} 867}
868 868
869 869
870/*! 870/*!
871 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 871 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
872 872
873 \sa idAfter() 873 \sa idAfter()
874*/ 874*/
875 875
876void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 876void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
877{ 877{
878 int minB = 0;//before 878 int minB = 0;//before
879 int maxB = 0; 879 int maxB = 0;
880 int minA = 0; 880 int minA = 0;
881 int maxA = 0;//after 881 int maxA = 0;//after
882 int n = data->list.count(); 882 int n = data->list.count();
883 if ( id < 0 || id >= n ) 883 if ( id < 0 || id >= n )
884 return; 884 return;
885 int i; 885 int i;
886 for ( i = 0; i < id; i++ ) { 886 for ( i = 0; i < id; i++ ) {
887 QSplitterLayoutStruct *s = data->list.at(i); 887 QSplitterLayoutStruct *s = data->list.at(i);
888 if ( s->wid->isHidden() ) { 888 if ( s->wid->isHidden() ) {
889 //ignore 889 //ignore
890 } else if ( s->isSplitter ) { 890 } else if ( s->isSplitter ) {
891 minB += s->sizer; 891 minB += s->sizer;
892 maxB += s->sizer; 892 maxB += s->sizer;
893 } else { 893 } else {
894 minB += pick( minSize(s->wid) ); 894 minB += pick( minSize(s->wid) );
895 maxB += pick( s->wid->maximumSize() ); 895 maxB += pick( s->wid->maximumSize() );
896 } 896 }
897 } 897 }
898 for ( i = id; i < n; i++ ) { 898 for ( i = id; i < n; i++ ) {
899 QSplitterLayoutStruct *s = data->list.at(i); 899 QSplitterLayoutStruct *s = data->list.at(i);
900 if ( s->wid->isHidden() ) { 900 if ( s->wid->isHidden() ) {
901 //ignore 901 //ignore
902 } else if ( s->isSplitter ) { 902 } else if ( s->isSplitter ) {
903 minA += s->sizer; 903 minA += s->sizer;
904 maxA += s->sizer; 904 maxA += s->sizer;
905 } else { 905 } else {
906 minA += pick( minSize(s->wid) ); 906 minA += pick( minSize(s->wid) );
907 maxA += pick( s->wid->maximumSize() ); 907 maxA += pick( s->wid->maximumSize() );
908 } 908 }
909 } 909 }
910 QRect r = contentsRect(); 910 QRect r = contentsRect();
911 if ( orient == Horizontal && false ) { 911 if ( orient == Horizontal && false ) {
912#if QT_VERSION >= 300 912#if QT_VERSION >= 0x030000
913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
914#else 914#else
915 int splitterWidth = style().splitterWidth(); 915 int splitterWidth = style().splitterWidth();
916#endif 916#endif
917 917
918 if ( min ) 918 if ( min )
919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
920 if ( max ) 920 if ( max )
921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
922 } else { 922 } else {
923 if ( min ) 923 if ( min )
924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
925 if ( max ) 925 if ( max )
926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
927 } 927 }
928} 928}
929 929
930 930
931/*! 931/*!
932 Returns the closest legal position to \a p of the splitter with id \a id. 932 Returns the closest legal position to \a p of the splitter with id \a id.
933 933
934 \sa idAfter() 934 \sa idAfter()
935*/ 935*/
936 936
937int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 937int KDGanttMinimizeSplitter::adjustPos( int p, int id )
938{ 938{
939 int min = 0; 939 int min = 0;
940 int max = 0; 940 int max = 0;
941 getRange( id, &min, &max ); 941 getRange( id, &min, &max );
942 p = QMAX( min, QMIN( p, max ) ); 942 p = QMAX( min, QMIN( p, max ) );
943 943
944 return p; 944 return p;
945} 945}
946 946
947 947
948void KDGanttMinimizeSplitter::doResize() 948void KDGanttMinimizeSplitter::doResize()
949{ 949{
950 QRect r = contentsRect(); 950 QRect r = contentsRect();
951 int i; 951 int i;
952 int n = data->list.count(); 952 int n = data->list.count();
953 QMemArray<QLayoutStruct> a( n ); 953 QMemArray<QLayoutStruct> a( n );
954 for ( i = 0; i< n; i++ ) { 954 for ( i = 0; i< n; i++ ) {
955 a[i].init(); 955 a[i].init();
956 QSplitterLayoutStruct *s = data->list.at(i); 956 QSplitterLayoutStruct *s = data->list.at(i);
957 if ( s->wid->isHidden() ) { 957 if ( s->wid->isHidden() ) {
958 a[i].stretch = 0; 958 a[i].stretch = 0;
959 a[i].sizeHint = a[i].minimumSize = 0; 959 a[i].sizeHint = a[i].minimumSize = 0;
960 a[i].maximumSize = 0; 960 a[i].maximumSize = 0;
961 } else if ( s->isSplitter ) { 961 } else if ( s->isSplitter ) {
962 a[i].stretch = 0; 962 a[i].stretch = 0;
963 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 963 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
964 a[i].empty = FALSE; 964 a[i].empty = FALSE;
965 } else if ( s->mode == KeepSize ) { 965 } else if ( s->mode == KeepSize ) {
966 a[i].stretch = 0; 966 a[i].stretch = 0;
967 a[i].minimumSize = pick( minSize(s->wid) ); 967 a[i].minimumSize = pick( minSize(s->wid) );
968 a[i].sizeHint = s->sizer; 968 a[i].sizeHint = s->sizer;
969 a[i].maximumSize = pick( s->wid->maximumSize() ); 969 a[i].maximumSize = pick( s->wid->maximumSize() );
970 a[i].empty = FALSE; 970 a[i].empty = FALSE;
971 } else if ( s->mode == FollowSizeHint ) { 971 } else if ( s->mode == FollowSizeHint ) {
972 a[i].stretch = 0; 972 a[i].stretch = 0;
973 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 973 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
974 a[i].maximumSize = pick( s->wid->maximumSize() ); 974 a[i].maximumSize = pick( s->wid->maximumSize() );
975 a[i].empty = FALSE; 975 a[i].empty = FALSE;
976 } else { //proportional 976 } else { //proportional
977 a[i].stretch = s->sizer; 977 a[i].stretch = s->sizer;
978 a[i].maximumSize = pick( s->wid->maximumSize() ); 978 a[i].maximumSize = pick( s->wid->maximumSize() );
979 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 979 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
980 a[i].empty = FALSE; 980 a[i].empty = FALSE;
981 } 981 }
982 } 982 }
983 983
984 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 984 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
985 985
986 for ( i = 0; i< n; i++ ) { 986 for ( i = 0; i< n; i++ ) {
987 QSplitterLayoutStruct *s = data->list.at(i); 987 QSplitterLayoutStruct *s = data->list.at(i);
988 setG( s->wid, a[i].pos, a[i].size ); 988 setG( s->wid, a[i].pos, a[i].size );
989 } 989 }
990 990
991} 991}
992 992
993 993
994void KDGanttMinimizeSplitter::recalc( bool update ) 994void KDGanttMinimizeSplitter::recalc( bool update )
995{ 995{
996 int fi = 2*frameWidth(); 996 int fi = 2*frameWidth();
997 int maxl = fi; 997 int maxl = fi;
998 int minl = fi; 998 int minl = fi;
999 int maxt = QWIDGETSIZE_MAX; 999 int maxt = QWIDGETSIZE_MAX;
1000 int mint = fi; 1000 int mint = fi;
1001 int n = data->list.count(); 1001 int n = data->list.count();
1002 bool first = TRUE; 1002 bool first = TRUE;
1003 /* 1003 /*
1004 The splitter before a hidden widget is always hidden. 1004 The splitter before a hidden widget is always hidden.
1005 The splitter before the first visible widget is hidden. 1005 The splitter before the first visible widget is hidden.
1006 The splitter before any other visible widget is visible. 1006 The splitter before any other visible widget is visible.
1007 */ 1007 */
1008 for ( int i = 0; i< n; i++ ) { 1008 for ( int i = 0; i< n; i++ ) {
1009 QSplitterLayoutStruct *s = data->list.at(i); 1009 QSplitterLayoutStruct *s = data->list.at(i);
1010 if ( !s->isSplitter ) { 1010 if ( !s->isSplitter ) {
1011 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1011 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1012 if ( p && p->isSplitter ) 1012 if ( p && p->isSplitter )
1013 if ( first || s->wid->isHidden() ) 1013 if ( first || s->wid->isHidden() )
1014 p->wid->hide(); //may trigger new recalc 1014 p->wid->hide(); //may trigger new recalc
1015 else 1015 else
1016 p->wid->show(); //may trigger new recalc 1016 p->wid->show(); //may trigger new recalc
1017 if ( !s->wid->isHidden() ) 1017 if ( !s->wid->isHidden() )
1018 first = FALSE; 1018 first = FALSE;
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 bool empty=TRUE; 1022 bool empty=TRUE;
1023 for ( int j = 0; j< n; j++ ) { 1023 for ( int j = 0; j< n; j++ ) {
1024 QSplitterLayoutStruct *s = data->list.at(j); 1024 QSplitterLayoutStruct *s = data->list.at(j);
1025 if ( !s->wid->isHidden() ) { 1025 if ( !s->wid->isHidden() ) {
1026 empty = FALSE; 1026 empty = FALSE;
1027 if ( s->isSplitter ) { 1027 if ( s->isSplitter ) {
1028 minl += s->sizer; 1028 minl += s->sizer;
1029 maxl += s->sizer; 1029 maxl += s->sizer;
1030 } else { 1030 } else {
1031 QSize minS = minSize(s->wid); 1031 QSize minS = minSize(s->wid);
1032 minl += pick( minS ); 1032 minl += pick( minS );
1033 maxl += pick( s->wid->maximumSize() ); 1033 maxl += pick( s->wid->maximumSize() );
1034 mint = QMAX( mint, trans( minS )); 1034 mint = QMAX( mint, trans( minS ));
1035 int tm = trans( s->wid->maximumSize() ); 1035 int tm = trans( s->wid->maximumSize() );
1036 if ( tm > 0 ) 1036 if ( tm > 0 )
1037 maxt = QMIN( maxt, tm ); 1037 maxt = QMIN( maxt, tm );
1038 } 1038 }
1039 } 1039 }
1040 } 1040 }
1041 if ( empty ) { 1041 if ( empty ) {
1042 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1042 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1043 // nested splitters; be nice 1043 // nested splitters; be nice
1044 maxl = maxt = 0; 1044 maxl = maxt = 0;
1045 } else { 1045 } else {
1046 // KDGanttMinimizeSplitter with no children yet 1046 // KDGanttMinimizeSplitter with no children yet
1047 maxl = QWIDGETSIZE_MAX; 1047 maxl = QWIDGETSIZE_MAX;
1048 } 1048 }
1049 } else { 1049 } else {
1050 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1050 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1051 } 1051 }
1052 if ( maxt < mint ) 1052 if ( maxt < mint )
1053 maxt = mint; 1053 maxt = mint;
1054 1054
1055 if ( orient == Horizontal ) { 1055 if ( orient == Horizontal ) {
1056 setMaximumSize( maxl, maxt ); 1056 setMaximumSize( maxl, maxt );
1057 setMinimumSize( minl, mint ); 1057 setMinimumSize( minl, mint );
1058 } else { 1058 } else {
1059 setMaximumSize( maxt, maxl ); 1059 setMaximumSize( maxt, maxl );
1060 setMinimumSize( mint, minl ); 1060 setMinimumSize( mint, minl );
1061 } 1061 }
1062 if ( update ) 1062 if ( update )
1063 doResize(); 1063 doResize();
1064} 1064}
1065 1065
1066/*! 1066/*!
1067 Sets resize mode of \a w to \a mode. 1067 Sets resize mode of \a w to \a mode.
1068 1068
1069 \sa ResizeMode 1069 \sa ResizeMode
1070*/ 1070*/
1071 1071
1072void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1072void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1073{ 1073{
1074 processChildEvents(); 1074 processChildEvents();
1075 QSplitterLayoutStruct *s = data->list.first(); 1075 QSplitterLayoutStruct *s = data->list.first();
1076 while ( s ) { 1076 while ( s ) {
1077 if ( s->wid == w ) { 1077 if ( s->wid == w ) {
1078 s->mode = mode; 1078 s->mode = mode;
1079 return; 1079 return;
1080 } 1080 }
1081 s = data->list.next(); 1081 s = data->list.next();
1082 } 1082 }
1083 s = addWidget( w, TRUE ); 1083 s = addWidget( w, TRUE );
1084 s->mode = mode; 1084 s->mode = mode;
1085} 1085}
1086 1086
1087 1087
1088/*! 1088/*!
1089 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1089 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1090 1090
1091 \sa setOpaqueResize() 1091 \sa setOpaqueResize()
1092*/ 1092*/
1093 1093
1094bool KDGanttMinimizeSplitter::opaqueResize() const 1094bool KDGanttMinimizeSplitter::opaqueResize() const
1095{ 1095{
1096 return data->opaque; 1096 return data->opaque;
1097} 1097}
1098 1098
1099 1099
1100/*! 1100/*!
1101 If \a on is TRUE then opaque resizing is turned on; otherwise 1101 If \a on is TRUE then opaque resizing is turned on; otherwise
1102 opaque resizing is turned off. 1102 opaque resizing is turned off.
1103 Opaque resizing is initially turned off. 1103 Opaque resizing is initially turned off.
1104 1104
@@ -1198,385 +1198,385 @@ QSize KDGanttMinimizeSplitter::sizeHint() const
1198 !((QWidget*)o)->isHidden() ) { 1198 !((QWidget*)o)->isHidden() ) {
1199 QSize s = ((QWidget*)o)->sizeHint(); 1199 QSize s = ((QWidget*)o)->sizeHint();
1200 if ( s.isValid() ) { 1200 if ( s.isValid() ) {
1201 l += pick( s ); 1201 l += pick( s );
1202 t = QMAX( t, trans( s ) ); 1202 t = QMAX( t, trans( s ) );
1203 } 1203 }
1204 } 1204 }
1205 } 1205 }
1206 } 1206 }
1207 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1207 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1208} 1208}
1209 1209
1210 1210
1211/*! 1211/*!
1212\reimp 1212\reimp
1213*/ 1213*/
1214 1214
1215QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1215QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1216{ 1216{
1217 constPolish(); 1217 constPolish();
1218 int l = 0; 1218 int l = 0;
1219 int t = 0; 1219 int t = 0;
1220 if ( children() ) { 1220 if ( children() ) {
1221 const QObjectList * c = children(); 1221 const QObjectList * c = children();
1222 QObjectListIt it( *c ); 1222 QObjectListIt it( *c );
1223 QObject * o; 1223 QObject * o;
1224 1224
1225 while( (o=it.current()) != 0 ) { 1225 while( (o=it.current()) != 0 ) {
1226 ++it; 1226 ++it;
1227 if ( o->isWidgetType() && 1227 if ( o->isWidgetType() &&
1228 !((QWidget*)o)->isHidden() ) { 1228 !((QWidget*)o)->isHidden() ) {
1229 QSize s = minSizeHint((QWidget*)o); 1229 QSize s = minSizeHint((QWidget*)o);
1230 if ( s.isValid() ) { 1230 if ( s.isValid() ) {
1231 l += pick( s ); 1231 l += pick( s );
1232 t = QMAX( t, trans( s ) ); 1232 t = QMAX( t, trans( s ) );
1233 } 1233 }
1234 } 1234 }
1235 } 1235 }
1236 } 1236 }
1237 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1237 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1238} 1238}
1239 1239
1240 1240
1241/* 1241/*
1242 Calculates stretch parameters from current sizes 1242 Calculates stretch parameters from current sizes
1243*/ 1243*/
1244 1244
1245void KDGanttMinimizeSplitter::storeSizes() 1245void KDGanttMinimizeSplitter::storeSizes()
1246{ 1246{
1247 QSplitterLayoutStruct *s = data->list.first(); 1247 QSplitterLayoutStruct *s = data->list.first();
1248 while ( s ) { 1248 while ( s ) {
1249 if ( !s->isSplitter ) 1249 if ( !s->isSplitter )
1250 s->sizer = pick( s->wid->size() ); 1250 s->sizer = pick( s->wid->size() );
1251 s = data->list.next(); 1251 s = data->list.next();
1252 } 1252 }
1253} 1253}
1254 1254
1255 1255
1256#if 0 // ### remove this code ASAP 1256#if 0 // ### remove this code ASAP
1257 1257
1258/*! 1258/*!
1259 Hides \a w if \a hide is TRUE and updates the splitter. 1259 Hides \a w if \a hide is TRUE and updates the splitter.
1260 1260
1261 \warning Due to a limitation in the current implementation, 1261 \warning Due to a limitation in the current implementation,
1262 calling QWidget::hide() will not work. 1262 calling QWidget::hide() will not work.
1263*/ 1263*/
1264 1264
1265void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1265void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1266{ 1266{
1267 if ( w == w1 ) { 1267 if ( w == w1 ) {
1268 w1show = !hide; 1268 w1show = !hide;
1269 } else if ( w == w2 ) { 1269 } else if ( w == w2 ) {
1270 w2show = !hide; 1270 w2show = !hide;
1271 } else { 1271 } else {
1272#ifdef QT_CHECK_RANGE 1272#ifdef QT_CHECK_RANGE
1273 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1273 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1274#endif 1274#endif
1275 return; 1275 return;
1276 } 1276 }
1277 if ( hide ) 1277 if ( hide )
1278 w->hide(); 1278 w->hide();
1279 else 1279 else
1280 w->show(); 1280 w->show();
1281 recalc( TRUE ); 1281 recalc( TRUE );
1282} 1282}
1283 1283
1284 1284
1285/*! 1285/*!
1286 Returns the hidden status of \a w 1286 Returns the hidden status of \a w
1287*/ 1287*/
1288 1288
1289bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1289bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1290{ 1290{
1291 if ( w == w1 ) 1291 if ( w == w1 )
1292 return !w1show; 1292 return !w1show;
1293 else if ( w == w2 ) 1293 else if ( w == w2 )
1294 return !w2show; 1294 return !w2show;
1295#ifdef QT_CHECK_RANGE 1295#ifdef QT_CHECK_RANGE
1296 else 1296 else
1297 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1297 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1298#endif 1298#endif
1299 return FALSE; 1299 return FALSE;
1300} 1300}
1301#endif 1301#endif
1302 1302
1303 1303
1304/*! 1304/*!
1305 Returns a list of the size parameters of all the widgets in this 1305 Returns a list of the size parameters of all the widgets in this
1306 splitter. 1306 splitter.
1307 1307
1308 Giving the values to another splitter's setSizes() function will 1308 Giving the values to another splitter's setSizes() function will
1309 produce a splitter with the same layout as this one. 1309 produce a splitter with the same layout as this one.
1310 1310
1311 Note that if you want to iterate over the list, you should 1311 Note that if you want to iterate over the list, you should
1312 iterate over a copy, e.g. 1312 iterate over a copy, e.g.
1313 \code 1313 \code
1314 QValueList<int> list = mySplitter.sizes(); 1314 QValueList<int> list = mySplitter.sizes();
1315 QValueList<int>::Iterator it = list.begin(); 1315 QValueList<int>::Iterator it = list.begin();
1316 while( it != list.end() ) { 1316 while( it != list.end() ) {
1317 myProcessing( *it ); 1317 myProcessing( *it );
1318 ++it; 1318 ++it;
1319 } 1319 }
1320 \endcode 1320 \endcode
1321 1321
1322 \sa setSizes() 1322 \sa setSizes()
1323*/ 1323*/
1324 1324
1325QValueList<int> KDGanttMinimizeSplitter::sizes() const 1325QValueList<int> KDGanttMinimizeSplitter::sizes() const
1326{ 1326{
1327 if ( !testWState(WState_Polished) ) { 1327 if ( !testWState(WState_Polished) ) {
1328 QWidget* that = (QWidget*) this; 1328 QWidget* that = (QWidget*) this;
1329 that->polish(); 1329 that->polish();
1330 } 1330 }
1331 QValueList<int> list; 1331 QValueList<int> list;
1332 QSplitterLayoutStruct *s = data->list.first(); 1332 QSplitterLayoutStruct *s = data->list.first();
1333 while ( s ) { 1333 while ( s ) {
1334 if ( !s->isSplitter ) 1334 if ( !s->isSplitter )
1335 list.append( s->sizer ); 1335 list.append( s->sizer );
1336 s = data->list.next(); 1336 s = data->list.next();
1337 } 1337 }
1338 return list; 1338 return list;
1339} 1339}
1340 1340
1341 1341
1342 1342
1343/*! 1343/*!
1344 Sets the size parameters to the values given in \a list. 1344 Sets the size parameters to the values given in \a list.
1345 If the splitter is horizontal, the values set the sizes from 1345 If the splitter is horizontal, the values set the sizes from
1346 left to right. If it is vertical, the sizes are applied from 1346 left to right. If it is vertical, the sizes are applied from
1347 top to bottom. 1347 top to bottom.
1348 Extra values in \a list are ignored. 1348 Extra values in \a list are ignored.
1349 1349
1350 If \a list contains too few values, the result is undefined 1350 If \a list contains too few values, the result is undefined
1351 but the program will still be well-behaved. 1351 but the program will still be well-behaved.
1352 1352
1353 \sa sizes() 1353 \sa sizes()
1354*/ 1354*/
1355 1355
1356void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1356void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1357{ 1357{
1358 processChildEvents(); 1358 processChildEvents();
1359 QValueList<int>::Iterator it = list.begin(); 1359 QValueList<int>::Iterator it = list.begin();
1360 QSplitterLayoutStruct *s = data->list.first(); 1360 QSplitterLayoutStruct *s = data->list.first();
1361 while ( s && it != list.end() ) { 1361 while ( s && it != list.end() ) {
1362 if ( !s->isSplitter ) { 1362 if ( !s->isSplitter ) {
1363 s->sizer = *it; 1363 s->sizer = *it;
1364 ++it; 1364 ++it;
1365 } 1365 }
1366 s = data->list.next(); 1366 s = data->list.next();
1367 } 1367 }
1368 doResize(); 1368 doResize();
1369} 1369}
1370 1370
1371 1371
1372/*! 1372/*!
1373 Gets all posted child events, ensuring that the internal state of 1373 Gets all posted child events, ensuring that the internal state of
1374 the splitter is consistent. 1374 the splitter is consistent.
1375*/ 1375*/
1376 1376
1377void KDGanttMinimizeSplitter::processChildEvents() 1377void KDGanttMinimizeSplitter::processChildEvents()
1378{ 1378{
1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1380} 1380}
1381 1381
1382 1382
1383/*! 1383/*!
1384 \reimp 1384 \reimp
1385*/ 1385*/
1386 1386
1387void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1387void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1388{ 1388{
1389 1389
1390#if QT_VERSION >= 300 1390#if QT_VERSION >= 0x030000
1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1392#else 1392#else
1393 int sw = style().splitterWidth(); 1393 int sw = style().splitterWidth();
1394#endif 1394#endif
1395 QSplitterLayoutStruct *s = data->list.first(); 1395 QSplitterLayoutStruct *s = data->list.first();
1396 while ( s ) { 1396 while ( s ) {
1397 if ( s->isSplitter ) 1397 if ( s->isSplitter )
1398 s->sizer = sw; 1398 s->sizer = sw;
1399 s = data->list.next(); 1399 s = data->list.next();
1400 } 1400 }
1401 doResize(); 1401 doResize();
1402 QFrame::styleChange( old ); 1402 QFrame::styleChange( old );
1403} 1403}
1404 1404
1405#endif 1405#endif
1406 1406
1407/*! 1407/*!
1408 Specifies the direction of the minimize buttons. 1408 Specifies the direction of the minimize buttons.
1409 If the orientation of the splitter is horizontal then with 1409 If the orientation of the splitter is horizontal then with
1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1412 should be used. 1412 should be used.
1413*/ 1413*/
1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1415{ 1415{
1416 _direction = direction; 1416 _direction = direction;
1417} 1417}
1418 1418
1419/*! 1419/*!
1420 Returns the direction of the minimize buttons. 1420 Returns the direction of the minimize buttons.
1421*/ 1421*/
1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1423{ 1423{
1424 return _direction; 1424 return _direction;
1425} 1425}
1426 1426
1427/* 1427/*
1428 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1428 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1429 unfortunately isn't exported. 1429 unfortunately isn't exported.
1430*/ 1430*/
1431static inline int toFixed( int i ) { return i * 256; } 1431static inline int toFixed( int i ) { return i * 256; }
1432static inline int fRound( int i ) { 1432static inline int fRound( int i ) {
1433 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1433 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1434} 1434}
1435void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1435void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
1436 int space, int spacer ) 1436 int space, int spacer )
1437{ 1437{
1438 typedef int fixed; 1438 typedef int fixed;
1439 int cHint = 0; 1439 int cHint = 0;
1440 int cMin = 0; 1440 int cMin = 0;
1441 int cMax = 0; 1441 int cMax = 0;
1442 int sumStretch = 0; 1442 int sumStretch = 0;
1443 int spacerCount = 0; 1443 int spacerCount = 0;
1444 1444
1445 bool wannaGrow = FALSE; // anyone who really wants to grow? 1445 bool wannaGrow = FALSE; // anyone who really wants to grow?
1446 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1446 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1447 1447
1448 int i; 1448 int i;
1449 for ( i = start; i < start + count; i++ ) { 1449 for ( i = start; i < start + count; i++ ) {
1450 chain[i].done = FALSE; 1450 chain[i].done = FALSE;
1451 cHint += chain[i].sizeHint; 1451 cHint += chain[i].sizeHint;
1452 cMin += chain[i].minimumSize; 1452 cMin += chain[i].minimumSize;
1453 cMax += chain[i].maximumSize; 1453 cMax += chain[i].maximumSize;
1454 sumStretch += chain[i].stretch; 1454 sumStretch += chain[i].stretch;
1455 if ( !chain[i].empty ) 1455 if ( !chain[i].empty )
1456 spacerCount++; 1456 spacerCount++;
1457 wannaGrow = wannaGrow || chain[i].expansive; 1457 wannaGrow = wannaGrow || chain[i].expansive;
1458 } 1458 }
1459 1459
1460 int extraspace = 0; 1460 int extraspace = 0;
1461 if ( spacerCount ) 1461 if ( spacerCount )
1462 spacerCount--; // only spacers between things 1462 spacerCount--; // only spacers between things
1463 if ( space < cMin + spacerCount * spacer ) { 1463 if ( space < cMin + spacerCount * spacer ) {
1464 //qDebug("not enough space"); 1464 //qDebug("not enough space");
1465 for ( i = start; i < start+count; i++ ) { 1465 for ( i = start; i < start+count; i++ ) {
1466 chain[i].size = chain[i].minimumSize; 1466 chain[i].size = chain[i].minimumSize;
1467 chain[i].done = TRUE; 1467 chain[i].done = TRUE;
1468 } 1468 }
1469 } else if ( space < cHint + spacerCount*spacer ) { 1469 } else if ( space < cHint + spacerCount*spacer ) {
1470 // Less space than sizeHint, but more than minimum. 1470 // Less space than sizeHint, but more than minimum.
1471 // Currently take space equally from each, like in Qt 2.x. 1471 // Currently take space equally from each, like in Qt 2.x.
1472 // Commented-out lines will give more space to stretchier items. 1472 // Commented-out lines will give more space to stretchier items.
1473 int n = count; 1473 int n = count;
1474 int space_left = space - spacerCount*spacer; 1474 int space_left = space - spacerCount*spacer;
1475 int overdraft = cHint - space_left; 1475 int overdraft = cHint - space_left;
1476 //first give to the fixed ones: 1476 //first give to the fixed ones:
1477 for ( i = start; i < start+count; i++ ) { 1477 for ( i = start; i < start+count; i++ ) {
1478 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1478 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1479 chain[i].size = chain[i].sizeHint; 1479 chain[i].size = chain[i].sizeHint;
1480 chain[i].done = TRUE; 1480 chain[i].done = TRUE;
1481 space_left -= chain[i].sizeHint; 1481 space_left -= chain[i].sizeHint;
1482 // sumStretch -= chain[i].stretch; 1482 // sumStretch -= chain[i].stretch;
1483 n--; 1483 n--;
1484 } 1484 }
1485 } 1485 }
1486 bool finished = n == 0; 1486 bool finished = n == 0;
1487 while ( !finished ) { 1487 while ( !finished ) {
1488 finished = TRUE; 1488 finished = TRUE;
1489 fixed fp_over = toFixed( overdraft ); 1489 fixed fp_over = toFixed( overdraft );
1490 fixed fp_w = 0; 1490 fixed fp_w = 0;
1491 1491
1492 for ( i = start; i < start+count; i++ ) { 1492 for ( i = start; i < start+count; i++ ) {
1493 if ( chain[i].done ) 1493 if ( chain[i].done )
1494 continue; 1494 continue;
1495 // if ( sumStretch <= 0 ) 1495 // if ( sumStretch <= 0 )
1496 fp_w += fp_over / n; 1496 fp_w += fp_over / n;
1497 // else 1497 // else
1498 // fp_w += (fp_over * chain[i].stretch) / sumStretch; 1498 // fp_w += (fp_over * chain[i].stretch) / sumStretch;
1499 int w = fRound( fp_w ); 1499 int w = fRound( fp_w );
1500 chain[i].size = chain[i].sizeHint - w; 1500 chain[i].size = chain[i].sizeHint - w;
1501 fp_w -= toFixed( w ); //give the difference to the next 1501 fp_w -= toFixed( w ); //give the difference to the next
1502 if ( chain[i].size < chain[i].minimumSize ) { 1502 if ( chain[i].size < chain[i].minimumSize ) {
1503 chain[i].done = TRUE; 1503 chain[i].done = TRUE;
1504 chain[i].size = chain[i].minimumSize; 1504 chain[i].size = chain[i].minimumSize;
1505 finished = FALSE; 1505 finished = FALSE;
1506 overdraft -= chain[i].sizeHint - chain[i].minimumSize; 1506 overdraft -= chain[i].sizeHint - chain[i].minimumSize;
1507 // sumStretch -= chain[i].stretch; 1507 // sumStretch -= chain[i].stretch;
1508 n--; 1508 n--;
1509 break; 1509 break;
1510 } 1510 }
1511 } 1511 }
1512 } 1512 }
1513 } else { //extra space 1513 } else { //extra space
1514 int n = count; 1514 int n = count;
1515 int space_left = space - spacerCount*spacer; 1515 int space_left = space - spacerCount*spacer;
1516 // first give to the fixed ones, and handle non-expansiveness 1516 // first give to the fixed ones, and handle non-expansiveness
1517 for ( i = start; i < start + count; i++ ) { 1517 for ( i = start; i < start + count; i++ ) {
1518 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint 1518 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint
1519 || wannaGrow && !chain[i].expansive) ) { 1519 || wannaGrow && !chain[i].expansive) ) {
1520 chain[i].size = chain[i].sizeHint; 1520 chain[i].size = chain[i].sizeHint;
1521 chain[i].done = TRUE; 1521 chain[i].done = TRUE;
1522 space_left -= chain[i].sizeHint; 1522 space_left -= chain[i].sizeHint;
1523 sumStretch -= chain[i].stretch; 1523 sumStretch -= chain[i].stretch;
1524 n--; 1524 n--;
1525 } 1525 }
1526 } 1526 }
1527 extraspace = space_left; 1527 extraspace = space_left;
1528 /* 1528 /*
1529 Do a trial distribution and calculate how much it is off. 1529 Do a trial distribution and calculate how much it is off.
1530 If there are more deficit pixels than surplus pixels, give 1530 If there are more deficit pixels than surplus pixels, give
1531 the minimum size items what they need, and repeat. 1531 the minimum size items what they need, and repeat.
1532 Otherwise give to the maximum size items, and repeat. 1532 Otherwise give to the maximum size items, and repeat.
1533 1533
1534 I have a wonderful mathematical proof for the correctness 1534 I have a wonderful mathematical proof for the correctness
1535 of this principle, but unfortunately this comment is too 1535 of this principle, but unfortunately this comment is too
1536 small to contain it. 1536 small to contain it.
1537 */ 1537 */
1538 int surplus, deficit; 1538 int surplus, deficit;
1539 do { 1539 do {
1540 surplus = deficit = 0; 1540 surplus = deficit = 0;
1541 fixed fp_space = toFixed( space_left ); 1541 fixed fp_space = toFixed( space_left );
1542 fixed fp_w = 0; 1542 fixed fp_w = 0;
1543 for ( i = start; i < start+count; i++ ) { 1543 for ( i = start; i < start+count; i++ ) {
1544 if ( chain[i].done ) 1544 if ( chain[i].done )
1545 continue; 1545 continue;
1546 extraspace = 0; 1546 extraspace = 0;
1547 if ( sumStretch <= 0 ) 1547 if ( sumStretch <= 0 )
1548 fp_w += fp_space / n; 1548 fp_w += fp_space / n;
1549 else 1549 else
1550 fp_w += (fp_space * chain[i].stretch) / sumStretch; 1550 fp_w += (fp_space * chain[i].stretch) / sumStretch;
1551 int w = fRound( fp_w ); 1551 int w = fRound( fp_w );
1552 chain[i].size = w; 1552 chain[i].size = w;
1553 fp_w -= toFixed( w ); // give the difference to the next 1553 fp_w -= toFixed( w ); // give the difference to the next
1554 if ( w < chain[i].sizeHint ) { 1554 if ( w < chain[i].sizeHint ) {
1555 deficit += chain[i].sizeHint - w; 1555 deficit += chain[i].sizeHint - w;
1556 } else if ( w > chain[i].maximumSize ) { 1556 } else if ( w > chain[i].maximumSize ) {
1557 surplus += w - chain[i].maximumSize; 1557 surplus += w - chain[i].maximumSize;
1558 } 1558 }
1559 } 1559 }
1560 if ( deficit > 0 && surplus <= deficit ) { 1560 if ( deficit > 0 && surplus <= deficit ) {
1561 // give to the ones that have too little 1561 // give to the ones that have too little
1562 for ( i = start; i < start+count; i++ ) { 1562 for ( i = start; i < start+count; i++ ) {
1563 if ( !chain[i].done && 1563 if ( !chain[i].done &&
1564 chain[i].size < chain[i].sizeHint ) { 1564 chain[i].size < chain[i].sizeHint ) {
1565 chain[i].size = chain[i].sizeHint; 1565 chain[i].size = chain[i].sizeHint;
1566 chain[i].done = TRUE; 1566 chain[i].done = TRUE;
1567 space_left -= chain[i].sizeHint; 1567 space_left -= chain[i].sizeHint;
1568 sumStretch -= chain[i].stretch; 1568 sumStretch -= chain[i].stretch;
1569 n--; 1569 n--;
1570 } 1570 }
1571 } 1571 }
1572 } 1572 }
1573 if ( surplus > 0 && surplus >= deficit ) { 1573 if ( surplus > 0 && surplus >= deficit ) {
1574 // take from the ones that have too much 1574 // take from the ones that have too much
1575 for ( i = start; i < start+count; i++ ) { 1575 for ( i = start; i < start+count; i++ ) {
1576 if ( !chain[i].done && 1576 if ( !chain[i].done &&
1577 chain[i].size > chain[i].maximumSize ) { 1577 chain[i].size > chain[i].maximumSize ) {
1578 chain[i].size = chain[i].maximumSize; 1578 chain[i].size = chain[i].maximumSize;
1579 chain[i].done = TRUE; 1579 chain[i].done = TRUE;
1580 space_left -= chain[i].maximumSize; 1580 space_left -= chain[i].maximumSize;
1581 sumStretch -= chain[i].stretch; 1581 sumStretch -= chain[i].stretch;
1582 n--; 1582 n--;
diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp
index 7c5b62a..cc12b9f 100644
--- a/microkde/kcalendarsystemgregorian.cpp
+++ b/microkde/kcalendarsystemgregorian.cpp
@@ -1,359 +1,359 @@
1/* 1/*
2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> 2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
3 Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> 3 Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// Derived gregorian kde calendar class 21// Derived gregorian kde calendar class
22// Just a schema. 22// Just a schema.
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "kcalendarsystemgregorian.h" 30#include "kcalendarsystemgregorian.h"
31 31
32KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) 32KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale)
33 : KCalendarSystem(locale) 33 : KCalendarSystem(locale)
34{ 34{
35 kdDebug(5400) << "Created gregorian calendar" << endl; 35 kdDebug(5400) << "Created gregorian calendar" << endl;
36} 36}
37 37
38KCalendarSystemGregorian::~KCalendarSystemGregorian() 38KCalendarSystemGregorian::~KCalendarSystemGregorian()
39{ 39{
40} 40}
41 41
42int KCalendarSystemGregorian::year(const QDate& date) const 42int KCalendarSystemGregorian::year(const QDate& date) const
43{ 43{
44// kdDebug(5400) << "Gregorian year..." << endl; 44// kdDebug(5400) << "Gregorian year..." << endl;
45 return date.year(); 45 return date.year();
46} 46}
47 47
48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const 48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const
49{ 49{
50// kdDebug(5400) << "Gregorian monthsInYear" << endl; 50// kdDebug(5400) << "Gregorian monthsInYear" << endl;
51 51
52 return 12; 52 return 12;
53} 53}
54 54
55int KCalendarSystemGregorian::weeksInYear(int year) const 55int KCalendarSystemGregorian::weeksInYear(int year) const
56{ 56{
57#if QT_VERSION >= 300 57#if QT_VERSION >= 0x030000
58 QDate temp; 58 QDate temp;
59 temp.setYMD(year, 12, 31); 59 temp.setYMD(year, 12, 31);
60 60
61 // If the last day of the year is in the first week, we have to check the 61 // If the last day of the year is in the first week, we have to check the
62 // week before 62 // week before
63 if ( temp.weekNumber() == 1 ) 63 if ( temp.weekNumber() == 1 )
64 temp.addDays(-7); 64 temp.addDays(-7);
65 65
66 return temp.weekNumber(); 66 return temp.weekNumber();
67#else 67#else
68 return 52; 68 return 52;
69#endif 69#endif
70} 70}
71 71
72int KCalendarSystemGregorian::weekNumber(const QDate& date, 72int KCalendarSystemGregorian::weekNumber(const QDate& date,
73 int * yearNum) const 73 int * yearNum) const
74{ 74{
75#if QT_VERSION >= 300 75#if QT_VERSION >= 0x030000
76 return date.weekNumber(yearNum); 76 return date.weekNumber(yearNum);
77#else 77#else
78 return 1; 78 return 1;
79#endif 79#endif
80} 80}
81 81
82QString KCalendarSystemGregorian::monthName(const QDate& date, 82QString KCalendarSystemGregorian::monthName(const QDate& date,
83 bool shortName) const 83 bool shortName) const
84{ 84{
85 return monthName(month(date), shortName); 85 return monthName(month(date), shortName);
86} 86}
87 87
88QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const 88QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const
89{ 89{
90 return monthNamePossessive(month(date), shortName); 90 return monthNamePossessive(month(date), shortName);
91} 91}
92 92
93QString KCalendarSystemGregorian::monthName(int month, bool shortName) const 93QString KCalendarSystemGregorian::monthName(int month, bool shortName) const
94{ 94{
95// kdDebug(5400) << "Gregorian getMonthName" << endl; 95// kdDebug(5400) << "Gregorian getMonthName" << endl;
96 96
97 if ( shortName ) 97 if ( shortName )
98 switch ( month ) 98 switch ( month )
99 { 99 {
100 case 1: 100 case 1:
101 return locale()->translate("January", "Jan"); 101 return locale()->translate("January", "Jan");
102 case 2: 102 case 2:
103 return locale()->translate("February", "Feb"); 103 return locale()->translate("February", "Feb");
104 case 3: 104 case 3:
105 return locale()->translate("March", "Mar"); 105 return locale()->translate("March", "Mar");
106 case 4: 106 case 4:
107 return locale()->translate("April", "Apr"); 107 return locale()->translate("April", "Apr");
108 case 5: 108 case 5:
109 return locale()->translate("May short", "May"); 109 return locale()->translate("May short", "May");
110 case 6: 110 case 6:
111 return locale()->translate("June", "Jun"); 111 return locale()->translate("June", "Jun");
112 case 7: 112 case 7:
113 return locale()->translate("July", "Jul"); 113 return locale()->translate("July", "Jul");
114 case 8: 114 case 8:
115 return locale()->translate("August", "Aug"); 115 return locale()->translate("August", "Aug");
116 case 9: 116 case 9:
117 return locale()->translate("September", "Sep"); 117 return locale()->translate("September", "Sep");
118 case 10: 118 case 10:
119 return locale()->translate("October", "Oct"); 119 return locale()->translate("October", "Oct");
120 case 11: 120 case 11:
121 return locale()->translate("November", "Nov"); 121 return locale()->translate("November", "Nov");
122 case 12: 122 case 12:
123 return locale()->translate("December", "Dec"); 123 return locale()->translate("December", "Dec");
124 } 124 }
125 else 125 else
126 switch ( month ) 126 switch ( month )
127 { 127 {
128 case 1: 128 case 1:
129 return locale()->translate("January"); 129 return locale()->translate("January");
130 case 2: 130 case 2:
131 return locale()->translate("February"); 131 return locale()->translate("February");
132 case 3: 132 case 3:
133 return locale()->translate("March"); 133 return locale()->translate("March");
134 case 4: 134 case 4:
135 return locale()->translate("April"); 135 return locale()->translate("April");
136 case 5: 136 case 5:
137 return locale()->translate("May long", "May"); 137 return locale()->translate("May long", "May");
138 case 6: 138 case 6:
139 return locale()->translate("June"); 139 return locale()->translate("June");
140 case 7: 140 case 7:
141 return locale()->translate("July"); 141 return locale()->translate("July");
142 case 8: 142 case 8:
143 return locale()->translate("August"); 143 return locale()->translate("August");
144 case 9: 144 case 9:
145 return locale()->translate("September"); 145 return locale()->translate("September");
146 case 10: 146 case 10:
147 return locale()->translate("October"); 147 return locale()->translate("October");
148 case 11: 148 case 11:
149 return locale()->translate("November"); 149 return locale()->translate("November");
150 case 12: 150 case 12:
151 return locale()->translate("December"); 151 return locale()->translate("December");
152 } 152 }
153 153
154 return QString::null; 154 return QString::null;
155} 155}
156 156
157QString KCalendarSystemGregorian::monthNamePossessive(int month, 157QString KCalendarSystemGregorian::monthNamePossessive(int month,
158 bool shortName) const 158 bool shortName) const
159{ 159{
160// kdDebug(5400) << "Gregorian getMonthName" << endl; 160// kdDebug(5400) << "Gregorian getMonthName" << endl;
161 161
162 if ( shortName ) 162 if ( shortName )
163 switch ( month ) 163 switch ( month )
164 { 164 {
165 case 1: 165 case 1:
166 return locale()->translate("of January", "of Jan"); 166 return locale()->translate("of January", "of Jan");
167 case 2: 167 case 2:
168 return locale()->translate("of February", "of Feb"); 168 return locale()->translate("of February", "of Feb");
169 case 3: 169 case 3:
170 return locale()->translate("of March", "of Mar"); 170 return locale()->translate("of March", "of Mar");
171 case 4: 171 case 4:
172 return locale()->translate("of April", "of Apr"); 172 return locale()->translate("of April", "of Apr");
173 case 5: 173 case 5:
174 return locale()->translate("of May short", "of May"); 174 return locale()->translate("of May short", "of May");
175 case 6: 175 case 6:
176 return locale()->translate("of June", "of Jun"); 176 return locale()->translate("of June", "of Jun");
177 case 7: 177 case 7:
178 return locale()->translate("of July", "of Jul"); 178 return locale()->translate("of July", "of Jul");
179 case 8: 179 case 8:
180 return locale()->translate("of August", "of Aug"); 180 return locale()->translate("of August", "of Aug");
181 case 9: 181 case 9:
182 return locale()->translate("of September", "of Sep"); 182 return locale()->translate("of September", "of Sep");
183 case 10: 183 case 10:
184 return locale()->translate("of October", "of Oct"); 184 return locale()->translate("of October", "of Oct");
185 case 11: 185 case 11:
186 return locale()->translate("of November", "of Nov"); 186 return locale()->translate("of November", "of Nov");
187 case 12: 187 case 12:
188 return locale()->translate("of December", "of Dec"); 188 return locale()->translate("of December", "of Dec");
189 } 189 }
190 else 190 else
191 switch ( month ) 191 switch ( month )
192 { 192 {
193 case 1: 193 case 1:
194 return locale()->translate("of January"); 194 return locale()->translate("of January");
195 case 2: 195 case 2:
196 return locale()->translate("of February"); 196 return locale()->translate("of February");
197 case 3: 197 case 3:
198 return locale()->translate("of March"); 198 return locale()->translate("of March");
199 case 4: 199 case 4:
200 return locale()->translate("of April"); 200 return locale()->translate("of April");
201 case 5: 201 case 5:
202 return locale()->translate("of May long", "of May"); 202 return locale()->translate("of May long", "of May");
203 case 6: 203 case 6:
204 return locale()->translate("of June"); 204 return locale()->translate("of June");
205 case 7: 205 case 7:
206 return locale()->translate("of July"); 206 return locale()->translate("of July");
207 case 8: 207 case 8:
208 return locale()->translate("of August"); 208 return locale()->translate("of August");
209 case 9: 209 case 9:
210 return locale()->translate("of September"); 210 return locale()->translate("of September");
211 case 10: 211 case 10:
212 return locale()->translate("of October"); 212 return locale()->translate("of October");
213 case 11: 213 case 11:
214 return locale()->translate("of November"); 214 return locale()->translate("of November");
215 case 12: 215 case 12:
216 return locale()->translate("of December"); 216 return locale()->translate("of December");
217 } 217 }
218 218
219 return QString::null; 219 return QString::null;
220} 220}
221 221
222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const 222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const
223{ 223{
224 // We don't want Qt to add 1900 to them 224 // We don't want Qt to add 1900 to them
225 if ( y >= 0 && y <= 99 ) 225 if ( y >= 0 && y <= 99 )
226 return false; 226 return false;
227 227
228 // QDate supports gregorian internally 228 // QDate supports gregorian internally
229 return date.setYMD(y, m, d); 229 return date.setYMD(y, m, d);
230} 230}
231 231
232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const 232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const
233{ 233{
234#if QT_VERSION >= 300 234#if QT_VERSION >= 0x030000
235 return date.addYears(nyears); 235 return date.addYears(nyears);
236#else 236#else
237 int year = date.year() + nyears; 237 int year = date.year() + nyears;
238 int month = date.month(); 238 int month = date.month();
239 int day = date.day(); 239 int day = date.day();
240 QDate newDate( year, month, 1 ); 240 QDate newDate( year, month, 1 );
241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); 241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth();
242 return QDate( year, month, day ); 242 return QDate( year, month, day );
243#endif 243#endif
244} 244}
245 245
246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const 246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const
247{ 247{
248#if QT_VERSION >= 300 248#if QT_VERSION >= 0x030000
249 return date.addMonths(nmonths); 249 return date.addMonths(nmonths);
250#else 250#else
251 int month = date.month(); 251 int month = date.month();
252 int nyears; 252 int nyears;
253 if ( nmonths >= 0 ) { 253 if ( nmonths >= 0 ) {
254 month += nmonths; 254 month += nmonths;
255 nyears = ( month - 1 ) / 12; 255 nyears = ( month - 1 ) / 12;
256 month = ( ( month - 1 ) % 12 ) + 1; 256 month = ( ( month - 1 ) % 12 ) + 1;
257 } else { 257 } else {
258 nyears = nmonths / 12; 258 nyears = nmonths / 12;
259 // nmonths += nyears * 12; 259 // nmonths += nyears * 12;
260 nmonths = nmonths % 12; 260 nmonths = nmonths % 12;
261 month += nmonths; 261 month += nmonths;
262 if ( month <= 0 ) { 262 if ( month <= 0 ) {
263 month += 12; 263 month += 12;
264 --nyears; 264 --nyears;
265 } 265 }
266 } 266 }
267 int year = date.year() + nyears; 267 int year = date.year() + nyears;
268 int day = date.day(); 268 int day = date.day();
269 QDate newDate( year, month, 1 ); 269 QDate newDate( year, month, 1 );
270 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); 270 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth();
271 return QDate( year, month, day ); 271 return QDate( year, month, day );
272#endif 272#endif
273} 273}
274 274
275QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const 275QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const
276{ 276{
277 return date.addDays(ndays); 277 return date.addDays(ndays);
278} 278}
279 279
280QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const 280QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const
281{ 281{
282 // ### Should this really be different to each calendar system? Or are we 282 // ### Should this really be different to each calendar system? Or are we
283 // only going to support weeks with 7 days? 283 // only going to support weeks with 7 days?
284 284
285 //kdDebug(5400) << "Gregorian wDayName" << endl; 285 //kdDebug(5400) << "Gregorian wDayName" << endl;
286 return locale()->weekDayName(col, shortName); 286 return locale()->weekDayName(col, shortName);
287} 287}
288 288
289QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const 289QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const
290{ 290{
291 return weekDayName(dayOfWeek(date), shortName); 291 return weekDayName(dayOfWeek(date), shortName);
292} 292}
293 293
294 294
295int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const 295int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const
296{ 296{
297 return date.dayOfWeek(); 297 return date.dayOfWeek();
298} 298}
299 299
300int KCalendarSystemGregorian::dayOfYear(const QDate & date) const 300int KCalendarSystemGregorian::dayOfYear(const QDate & date) const
301{ 301{
302 return date.dayOfYear(); 302 return date.dayOfYear();
303} 303}
304 304
305int KCalendarSystemGregorian::daysInMonth(const QDate& date) const 305int KCalendarSystemGregorian::daysInMonth(const QDate& date) const
306{ 306{
307// kdDebug(5400) << "Gregorian daysInMonth" << endl; 307// kdDebug(5400) << "Gregorian daysInMonth" << endl;
308 return date.daysInMonth(); 308 return date.daysInMonth();
309} 309}
310 310
311int KCalendarSystemGregorian::minValidYear() const 311int KCalendarSystemGregorian::minValidYear() const
312{ 312{
313 return 1753; // QDate limit 313 return 1753; // QDate limit
314} 314}
315 315
316int KCalendarSystemGregorian::maxValidYear() const 316int KCalendarSystemGregorian::maxValidYear() const
317{ 317{
318 return 8000; // QDate limit 318 return 8000; // QDate limit
319} 319}
320 320
321int KCalendarSystemGregorian::day(const QDate& date) const 321int KCalendarSystemGregorian::day(const QDate& date) const
322{ 322{
323 return date.day(); 323 return date.day();
324} 324}
325 325
326int KCalendarSystemGregorian::month(const QDate& date) const 326int KCalendarSystemGregorian::month(const QDate& date) const
327{ 327{
328 return date.month(); 328 return date.month();
329} 329}
330 330
331int KCalendarSystemGregorian::daysInYear(const QDate& date) const 331int KCalendarSystemGregorian::daysInYear(const QDate& date) const
332{ 332{
333 return date.daysInYear(); 333 return date.daysInYear();
334} 334}
335 335
336int KCalendarSystemGregorian::weekDayOfPray() const 336int KCalendarSystemGregorian::weekDayOfPray() const
337{ 337{
338 return 7; // sunday 338 return 7; // sunday
339} 339}
340 340
341QString KCalendarSystemGregorian::calendarName() const 341QString KCalendarSystemGregorian::calendarName() const
342{ 342{
343 return QString::fromLatin1("gregorian"); 343 return QString::fromLatin1("gregorian");
344} 344}
345 345
346bool KCalendarSystemGregorian::isLunar() const 346bool KCalendarSystemGregorian::isLunar() const
347{ 347{
348 return false; 348 return false;
349} 349}
350 350
351bool KCalendarSystemGregorian::isLunisolar() const 351bool KCalendarSystemGregorian::isLunisolar() const
352{ 352{
353 return false; 353 return false;
354} 354}
355 355
356bool KCalendarSystemGregorian::isSolar() const 356bool KCalendarSystemGregorian::isSolar() const
357{ 357{
358 return true; 358 return true;
359} 359}