-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.h | 2 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 2 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 22 | ||||
-rw-r--r-- | korganizer/timespanview.cpp | 2 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 6 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 | ||||
-rw-r--r-- | microkde/kcalendarsystemgregorian.cpp | 8 |
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 | |||
@@ -221,209 +221,209 @@ void KAddressBookCardView::readConfig(KConfig *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 | ||
291 | void KAddressBookCardView::writeConfig( KConfig *config ) | 291 | void 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 | } |
296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 296 | void 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 | } |
355 | QStringList KAddressBookCardView::selectedUids() | 355 | QStringList 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 | ||
378 | void KAddressBookCardView::refresh(QString uid) | 378 | void 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 | ||
426 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 426 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
427 | { | 427 | { |
428 | CardViewItem *item; | 428 | CardViewItem *item; |
429 | AddresseeCardViewItem *aItem; | 429 | AddresseeCardViewItem *aItem; |
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 | |||
@@ -179,209 +179,209 @@ class AddresseeIconViewItem : public QIconViewItem | |||
179 | KABC::Addressee mAddressee; | 179 | KABC::Addressee mAddressee; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /////////////////////////////// | 182 | /////////////////////////////// |
183 | // KAddressBookView | 183 | // KAddressBookView |
184 | 184 | ||
185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 185 | KAddressBookIconView::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 | ||
211 | KAddressBookIconView::~KAddressBookIconView() | 211 | KAddressBookIconView::~KAddressBookIconView() |
212 | { | 212 | { |
213 | } | 213 | } |
214 | void KAddressBookIconView::setFocusAV() | 214 | void KAddressBookIconView::setFocusAV() |
215 | { | 215 | { |
216 | if ( mIconView ) | 216 | if ( mIconView ) |
217 | mIconView->setFocus(); | 217 | mIconView->setFocus(); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void KAddressBookIconView::scrollUP() | 221 | void 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 | } |
226 | void KAddressBookIconView::scrollDOWN() | 226 | void 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 | } |
231 | void KAddressBookIconView::readConfig(KConfig *config) | 231 | void 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 | } |
254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 254 | void 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 | } |
311 | QStringList KAddressBookIconView::selectedUids() | 311 | QStringList 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 | ||
334 | void KAddressBookIconView::refresh(QString uid) | 334 | void 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 | ||
382 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 382 | void 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()) |
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 | |||
@@ -63,208 +63,208 @@ void KAddressBookTableView::scrollUP() | |||
63 | QApplication::postEvent( mListView, ev ); | 63 | QApplication::postEvent( mListView, ev ); |
64 | } | 64 | } |
65 | void KAddressBookTableView::scrollDOWN() | 65 | void 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 | } |
70 | void KAddressBookTableView::reconstructListView() | 70 | void 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 | ||
139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 139 | void 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 | } |
197 | void KAddressBookTableView::writeConfig(KConfig *config) | 197 | void 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 | ||
204 | void KAddressBookTableView::readConfig(KConfig *config) | 204 | void 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")); |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index ead8628..21ecb73 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,163 +1,163 @@ | |||
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 | ||
29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 29 | KOTodoViewItem::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 | ||
35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 35 | KOTodoViewItem::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 | ||
41 | QString KOTodoViewItem::key(int column,bool) const | 41 | QString 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 | ||
51 | void KOTodoViewItem:: setup() | 51 | void 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 | } |
62 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 62 | void 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 |
68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 68 | void 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 | ||
76 | void KOTodoViewItem::construct() | 76 | void 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 | ||
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 | ||
37 | using namespace KCal; | 37 | using namespace KCal; |
38 | 38 | ||
39 | class KOTodoView; | 39 | class 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 | */ |
48 | class KOTodoViewItem : public QCheckListItem | 48 | class 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 | |||
@@ -482,107 +482,107 @@ void KOViewManager::showTodoView() | |||
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 | ||
527 | void KOViewManager::showJournalView() | 527 | void 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 | ||
542 | void KOViewManager::showTimeSpanView() | 542 | void 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 | ||
556 | Incidence *KOViewManager::currentSelection() | 556 | Incidence *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 | ||
566 | QDate KOViewManager::currentSelectionDate() | 566 | QDate 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 | ||
576 | void KOViewManager::addView(KOrg::BaseView *view) | 576 | void 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 | ||
585 | void KOViewManager::setDocumentId( const QString &id ) | 585 | void 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 | |||
@@ -141,257 +141,257 @@ SearchDialog::~SearchDialog() | |||
141 | } | 141 | } |
142 | void SearchDialog::accept() | 142 | void SearchDialog::accept() |
143 | { | 143 | { |
144 | doSearch(); | 144 | doSearch(); |
145 | } | 145 | } |
146 | void SearchDialog::updateList() | 146 | void 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 | } |
159 | void SearchDialog::searchTextChanged( const QString &_text ) | 159 | void SearchDialog::searchTextChanged( const QString &_text ) |
160 | { | 160 | { |
161 | enableButton( KDialogBase::User1, !_text.isEmpty() ); | 161 | enableButton( KDialogBase::User1, !_text.isEmpty() ); |
162 | } | 162 | } |
163 | 163 | ||
164 | void SearchDialog::doSearch() | 164 | void 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 | } |
202 | void SearchDialog::updateConfig() | 202 | void SearchDialog::updateConfig() |
203 | { | 203 | { |
204 | listView->updateConfig(); | 204 | listView->updateConfig(); |
205 | } | 205 | } |
206 | void SearchDialog::updateView() | 206 | void 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 | ||
226 | void SearchDialog::search(const QRegExp &re) | 226 | void 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 | /* |
390 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 390 | void 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 | |||
@@ -12,146 +12,146 @@ | |||
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 | ||
21 | TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : | 21 | TimeSpanView::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 | ||
63 | TimeSpanView::~TimeSpanView() | 63 | TimeSpanView::~TimeSpanView() |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | QValueList<int> TimeSpanView::splitterSizes() | 67 | QValueList<int> TimeSpanView::splitterSizes() |
68 | { | 68 | { |
69 | return mSplitter->sizes(); | 69 | return mSplitter->sizes(); |
70 | } | 70 | } |
71 | 71 | ||
72 | void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) | 72 | void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) |
73 | { | 73 | { |
74 | mSplitter->setSizes( sizes ); | 74 | mSplitter->setSizes( sizes ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void TimeSpanView::addItem( KCal::Event *event ) | 77 | void 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 | ||
100 | void TimeSpanView::clear() | 100 | void TimeSpanView::clear() |
101 | { | 101 | { |
102 | mList->clear(); | 102 | mList->clear(); |
103 | mLineView->clear(); | 103 | mLineView->clear(); |
104 | } | 104 | } |
105 | 105 | ||
106 | void TimeSpanView::updateView() | 106 | void 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 | ||
115 | void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) | 115 | void 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 | ||
125 | QDateTime TimeSpanView::startDateTime() | 125 | QDateTime TimeSpanView::startDateTime() |
126 | { | 126 | { |
127 | return mStartDate; | 127 | return mStartDate; |
128 | } | 128 | } |
129 | 129 | ||
130 | QDateTime TimeSpanView::endDateTime() | 130 | QDateTime TimeSpanView::endDateTime() |
131 | { | 131 | { |
132 | return mEndDate; | 132 | return mEndDate; |
133 | } | 133 | } |
134 | 134 | ||
135 | void TimeSpanView::zoomIn() | 135 | void 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 | ||
143 | void TimeSpanView::zoomOut() | 143 | void 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 | ||
151 | void TimeSpanView::centerView() | 151 | void 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 | |||
@@ -110,197 +110,193 @@ icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) | |||
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 | ||
136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) | 136 | icalcomponent *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 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *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 | ||
240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 236 | icalcomponent *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 | ||
262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 258 | void 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 | } |
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 60b8bc7..567ae54 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -1,136 +1,136 @@ | |||
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 |
64 | static int mouseOffset; | 64 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 66 | ||
67 | 67 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 68 | KDGanttSplitterHandle::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 | ||
86 | QSize KDGanttSplitterHandle::sizeHint() const | 86 | QSize KDGanttSplitterHandle::sizeHint() const |
87 | { | 87 | { |
88 | return mSizeHint; | 88 | return mSizeHint; |
89 | } | 89 | } |
90 | 90 | ||
91 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 91 | void 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 | ||
103 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 103 | void 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 | ||
124 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 124 | void 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 | ||
135 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 135 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
136 | { | 136 | { |
@@ -534,193 +534,193 @@ QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool firs | |||
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 | */ |
575 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 575 | void 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 | */ |
622 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 622 | void 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 */ |
653 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 653 | bool 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 | */ |
671 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 671 | void 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 | */ |
688 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 688 | int 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 | */ |
715 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 715 | void 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 | ||
@@ -816,193 +816,193 @@ void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | |||
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 | ||
853 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) | 853 | void 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 | ||
876 | void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | 876 | void 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 | ||
937 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) | 937 | int 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 | ||
948 | void KDGanttMinimizeSplitter::doResize() | 948 | void 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 | ||
994 | void KDGanttMinimizeSplitter::recalc( bool update ) | 994 | void 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++ ) { |
@@ -1294,193 +1294,193 @@ bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const | |||
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 | ||
1325 | QValueList<int> KDGanttMinimizeSplitter::sizes() const | 1325 | QValueList<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 | ||
1356 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | 1356 | void 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 | ||
1377 | void KDGanttMinimizeSplitter::processChildEvents() | 1377 | void 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 | ||
1387 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | 1387 | void 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 | */ |
1414 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) | 1414 | void 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 | */ |
1422 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const | 1422 | KDGanttMinimizeSplitter::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 | */ |
1431 | static inline int toFixed( int i ) { return i * 256; } | 1431 | static inline int toFixed( int i ) { return i * 256; } |
1432 | static inline int fRound( int i ) { | 1432 | static 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 | } |
1435 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 1435 | void 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; |
diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp index 7c5b62a..cc12b9f 100644 --- a/microkde/kcalendarsystemgregorian.cpp +++ b/microkde/kcalendarsystemgregorian.cpp | |||
@@ -1,344 +1,344 @@ | |||
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 | ||
32 | KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) | 32 | KCalendarSystemGregorian::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 | ||
38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() | 38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | int KCalendarSystemGregorian::year(const QDate& date) const | 42 | int 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 | ||
48 | int KCalendarSystemGregorian::monthsInYear( const QDate & ) const | 48 | int 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 | ||
55 | int KCalendarSystemGregorian::weeksInYear(int year) const | 55 | int 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 | ||
72 | int KCalendarSystemGregorian::weekNumber(const QDate& date, | 72 | int 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 | ||
82 | QString KCalendarSystemGregorian::monthName(const QDate& date, | 82 | QString 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 | ||
88 | QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const | 88 | QString 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 | ||
93 | QString KCalendarSystemGregorian::monthName(int month, bool shortName) const | 93 | QString 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 | ||
157 | QString KCalendarSystemGregorian::monthNamePossessive(int month, | 157 | QString 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 | ||
222 | bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const | 222 | bool 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 | ||
232 | QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const | 232 | QDate 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 | ||
246 | QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const | 246 | QDate 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 | ||
275 | QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const | 275 | QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const |
276 | { | 276 | { |
277 | return date.addDays(ndays); | 277 | return date.addDays(ndays); |
278 | } | 278 | } |
279 | 279 | ||
280 | QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const | 280 | QString 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 | ||
289 | QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const | 289 | QString 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 | ||
295 | int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const | 295 | int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const |
296 | { | 296 | { |
297 | return date.dayOfWeek(); | 297 | return date.dayOfWeek(); |
298 | } | 298 | } |
299 | 299 | ||
300 | int KCalendarSystemGregorian::dayOfYear(const QDate & date) const | 300 | int KCalendarSystemGregorian::dayOfYear(const QDate & date) const |
301 | { | 301 | { |
302 | return date.dayOfYear(); | 302 | return date.dayOfYear(); |
303 | } | 303 | } |
304 | 304 | ||
305 | int KCalendarSystemGregorian::daysInMonth(const QDate& date) const | 305 | int 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 | ||
311 | int KCalendarSystemGregorian::minValidYear() const | 311 | int KCalendarSystemGregorian::minValidYear() const |
312 | { | 312 | { |
313 | return 1753; // QDate limit | 313 | return 1753; // QDate limit |
314 | } | 314 | } |
315 | 315 | ||
316 | int KCalendarSystemGregorian::maxValidYear() const | 316 | int KCalendarSystemGregorian::maxValidYear() const |
317 | { | 317 | { |
318 | return 8000; // QDate limit | 318 | return 8000; // QDate limit |
319 | } | 319 | } |
320 | 320 | ||
321 | int KCalendarSystemGregorian::day(const QDate& date) const | 321 | int KCalendarSystemGregorian::day(const QDate& date) const |
322 | { | 322 | { |
323 | return date.day(); | 323 | return date.day(); |
324 | } | 324 | } |
325 | 325 | ||
326 | int KCalendarSystemGregorian::month(const QDate& date) const | 326 | int KCalendarSystemGregorian::month(const QDate& date) const |
327 | { | 327 | { |
328 | return date.month(); | 328 | return date.month(); |
329 | } | 329 | } |
330 | 330 | ||
331 | int KCalendarSystemGregorian::daysInYear(const QDate& date) const | 331 | int KCalendarSystemGregorian::daysInYear(const QDate& date) const |
332 | { | 332 | { |
333 | return date.daysInYear(); | 333 | return date.daysInYear(); |
334 | } | 334 | } |
335 | 335 | ||
336 | int KCalendarSystemGregorian::weekDayOfPray() const | 336 | int KCalendarSystemGregorian::weekDayOfPray() const |
337 | { | 337 | { |
338 | return 7; // sunday | 338 | return 7; // sunday |
339 | } | 339 | } |
340 | 340 | ||
341 | QString KCalendarSystemGregorian::calendarName() const | 341 | QString KCalendarSystemGregorian::calendarName() const |
342 | { | 342 | { |
343 | return QString::fromLatin1("gregorian"); | 343 | return QString::fromLatin1("gregorian"); |
344 | } | 344 | } |