author | zautrix <zautrix> | 2005-04-01 13:07:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 13:07:01 (UTC) |
commit | 93003b1f8348f112648d3cc20acb21b062220e21 (patch) (unidiff) | |
tree | 901bebe154a15f05296158db5da3689b849e8281 | |
parent | f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772 (diff) | |
download | kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.zip kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.gz kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kolistview.cpp | 2 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 32 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.h | 2 |
3 files changed, 34 insertions, 2 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 09d70f1..15e094d 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -194,1049 +194,1049 @@ bool ListItemVisitor::visit(Journal * j) | |||
194 | des = des.simplifyWhiteSpace (); | 194 | des = des.simplifyWhiteSpace (); |
195 | des.replace (QRegExp ("\\n"),"" ); | 195 | des.replace (QRegExp ("\\n"),"" ); |
196 | des.replace (QRegExp ("\\r"),"" ); | 196 | des.replace (QRegExp ("\\r"),"" ); |
197 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 197 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
198 | mItem->setText(1,j->dtStartDateStr()); | 198 | mItem->setText(1,j->dtStartDateStr()); |
199 | mItem->setText(2,"---"); | 199 | mItem->setText(2,"---"); |
200 | mItem->setText(3,"---"); | 200 | mItem->setText(3,"---"); |
201 | mItem->setText(4,"---"); | 201 | mItem->setText(4,"---"); |
202 | mItem->setText(5,"---"); | 202 | mItem->setText(5,"---"); |
203 | mItem->setText(6,"---"); | 203 | mItem->setText(6,"---"); |
204 | mItem->setText(7,j->dtStartDateStr()); | 204 | mItem->setText(7,j->dtStartDateStr()); |
205 | mItem->setText(8,"---"); | 205 | mItem->setText(8,"---"); |
206 | mItem->setText(9,"---"); | 206 | mItem->setText(9,"---"); |
207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
208 | 208 | ||
209 | QString key; | 209 | QString key; |
210 | QDate d = j->dtStart().date(); | 210 | QDate d = j->dtStart().date(); |
211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
212 | mItem->setSortKey(1,key); | 212 | mItem->setSortKey(1,key); |
213 | mItem->setSortKey(7,key); | 213 | mItem->setSortKey(7,key); |
214 | 214 | ||
215 | return true; | 215 | return true; |
216 | } | 216 | } |
217 | 217 | ||
218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
219 | const char *name) | 219 | const char *name) |
220 | : KOEventView(calendar, parent, name) | 220 | : KOEventView(calendar, parent, name) |
221 | { | 221 | { |
222 | mActiveItem = 0; | 222 | mActiveItem = 0; |
223 | mListView = new KOListViewListView(this); | 223 | mListView = new KOListViewListView(this); |
224 | mListView->addColumn(i18n("Summary")); | 224 | mListView->addColumn(i18n("Summary")); |
225 | mListView->addColumn(i18n("Start Date")); | 225 | mListView->addColumn(i18n("Start Date")); |
226 | mListView->addColumn(i18n("Start Time")); | 226 | mListView->addColumn(i18n("Start Time")); |
227 | mListView->addColumn(i18n("End Date")); | 227 | mListView->addColumn(i18n("End Date")); |
228 | mListView->addColumn(i18n("End Time")); | 228 | mListView->addColumn(i18n("End Time")); |
229 | mListView->addColumn(i18n("Alarm")); // alarm set? | 229 | mListView->addColumn(i18n("Alarm")); // alarm set? |
230 | mListView->addColumn(i18n("Recurs")); // recurs? | 230 | mListView->addColumn(i18n("Recurs")); // recurs? |
231 | mListView->addColumn(i18n("Due Date")); | 231 | mListView->addColumn(i18n("Due Date")); |
232 | mListView->addColumn(i18n("Due Time")); | 232 | mListView->addColumn(i18n("Due Time")); |
233 | mListView->addColumn(i18n("Cancelled")); | 233 | mListView->addColumn(i18n("Cancelled")); |
234 | mListView->addColumn(i18n("Categories")); | 234 | mListView->addColumn(i18n("Categories")); |
235 | 235 | ||
236 | mListView->setColumnAlignment(0,AlignLeft); | 236 | mListView->setColumnAlignment(0,AlignLeft); |
237 | mListView->setColumnAlignment(1,AlignLeft); | 237 | mListView->setColumnAlignment(1,AlignLeft); |
238 | mListView->setColumnAlignment(2,AlignHCenter); | 238 | mListView->setColumnAlignment(2,AlignHCenter); |
239 | mListView->setColumnAlignment(3,AlignLeft); | 239 | mListView->setColumnAlignment(3,AlignLeft); |
240 | mListView->setColumnAlignment(4,AlignHCenter); | 240 | mListView->setColumnAlignment(4,AlignHCenter); |
241 | mListView->setColumnAlignment(5,AlignLeft); | 241 | mListView->setColumnAlignment(5,AlignLeft); |
242 | mListView->setColumnAlignment(6,AlignLeft); | 242 | mListView->setColumnAlignment(6,AlignLeft); |
243 | mListView->setColumnAlignment(7,AlignLeft); | 243 | mListView->setColumnAlignment(7,AlignLeft); |
244 | mListView->setColumnAlignment(8,AlignLeft); | 244 | mListView->setColumnAlignment(8,AlignLeft); |
245 | mListView->setColumnAlignment(9,AlignLeft); | 245 | mListView->setColumnAlignment(9,AlignLeft); |
246 | mListView->setColumnAlignment(10,AlignLeft); | 246 | mListView->setColumnAlignment(10,AlignLeft); |
247 | mListView->setColumnWidthMode(10, QListView::Manual); | 247 | mListView->setColumnWidthMode(10, QListView::Manual); |
248 | new KOListViewWhatsThis(mListView->viewport(),this); | 248 | new KOListViewWhatsThis(mListView->viewport(),this); |
249 | 249 | ||
250 | int iii = 0; | 250 | int iii = 0; |
251 | for ( iii = 0; iii< 10 ; ++iii ) | 251 | for ( iii = 0; iii< 10 ; ++iii ) |
252 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 252 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
253 | 253 | ||
254 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 254 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
255 | layoutTop->addWidget(mListView); | 255 | layoutTop->addWidget(mListView); |
256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
257 | mPopupMenu = eventPopup(); | 257 | mPopupMenu = eventPopup(); |
258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
259 | i18n("Select all"),this, | 259 | i18n("Select all"),this, |
260 | SLOT(allSelection()),true); | 260 | SLOT(allSelection()),true); |
261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
262 | i18n("Deselect all"),this, | 262 | i18n("Deselect all"),this, |
263 | SLOT(clearSelection()),true); | 263 | SLOT(clearSelection()),true); |
264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
265 | i18n("Delete all selected"),this, | 265 | i18n("Delete all selected"),this, |
266 | SLOT(deleteAll()),true); | 266 | SLOT(deleteAll()),true); |
267 | mPopupMenu->insertSeparator(); | 267 | mPopupMenu->insertSeparator(); |
268 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 268 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
269 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 269 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
270 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 270 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
271 | SLOT(saveToFile())); | 271 | SLOT(saveToFile())); |
272 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 272 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
273 | SLOT(saveToFileVCS())); | 273 | SLOT(saveToFileVCS())); |
274 | exportPO->insertItem( i18n("Journal/Details..."),this, | 274 | exportPO->insertItem( i18n("Journal/Details..."),this, |
275 | SLOT(saveDescriptionToFile())); | 275 | SLOT(saveDescriptionToFile())); |
276 | // mPopupMenu->insertSeparator(); | 276 | // mPopupMenu->insertSeparator(); |
277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
278 | i18n("Add Categ. to selected..."),this, | 278 | i18n("Add Categ. to selected..."),this, |
279 | SLOT(addCat()),true); | 279 | SLOT(addCat()),true); |
280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
281 | i18n("Set Categ. for selected..."),this, | 281 | i18n("Set Categ. for selected..."),this, |
282 | SLOT(setCat()),true); | 282 | SLOT(setCat()),true); |
283 | //mPopupMenu->insertSeparator(); | 283 | //mPopupMenu->insertSeparator(); |
284 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 284 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
285 | i18n("Set alarm for selected..."),this, | 285 | i18n("Set alarm for selected..."),this, |
286 | SLOT(setAlarm()),true); | 286 | SLOT(setAlarm()),true); |
287 | 287 | ||
288 | 288 | ||
289 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
290 | mPopupMenu->insertSeparator(); | 290 | mPopupMenu->insertSeparator(); |
291 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 291 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
292 | i18n("Beam selected via IR"),this, | 292 | i18n("Beam selected via IR"),this, |
293 | SLOT(beamSelected()),true); | 293 | SLOT(beamSelected()),true); |
294 | #endif | 294 | #endif |
295 | /* | 295 | /* |
296 | mPopupMenu = new QPopupMenu; | 296 | mPopupMenu = new QPopupMenu; |
297 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 297 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
298 | SLOT (editEvent())); | 298 | SLOT (editEvent())); |
299 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 299 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
300 | SLOT (deleteEvent())); | 300 | SLOT (deleteEvent())); |
301 | mPopupMenu->insertSeparator(); | 301 | mPopupMenu->insertSeparator(); |
302 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 302 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
303 | SLOT(showDates())); | 303 | SLOT(showDates())); |
304 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 304 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
305 | SLOT(hideDates())); | 305 | SLOT(hideDates())); |
306 | */ | 306 | */ |
307 | QObject::connect(mListView,SIGNAL( newEvent()), | 307 | QObject::connect(mListView,SIGNAL( newEvent()), |
308 | this,SIGNAL(signalNewEvent())); | 308 | this,SIGNAL(signalNewEvent())); |
309 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 309 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
310 | this,SLOT(defaultItemAction(QListViewItem *))); | 310 | this,SLOT(defaultItemAction(QListViewItem *))); |
311 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 311 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
312 | const QPoint &, int )), | 312 | const QPoint &, int )), |
313 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 313 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
314 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 314 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
315 | SLOT(processSelectionChange(QListViewItem *))); | 315 | SLOT(processSelectionChange(QListViewItem *))); |
316 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 316 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
317 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 317 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
318 | 318 | ||
319 | readSettings(KOGlobals::config(),"KOListView Layout"); | 319 | readSettings(KOGlobals::config(),"KOListView Layout"); |
320 | } | 320 | } |
321 | 321 | ||
322 | KOListView::~KOListView() | 322 | KOListView::~KOListView() |
323 | { | 323 | { |
324 | delete mPopupMenu; | 324 | delete mPopupMenu; |
325 | } | 325 | } |
326 | QString KOListView::getWhatsThisText(QPoint p) | 326 | QString KOListView::getWhatsThisText(QPoint p) |
327 | { | 327 | { |
328 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 328 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
329 | if ( item ) | 329 | if ( item ) |
330 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 330 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
331 | KOPrefs::instance()->mWTshowDetails, | 331 | KOPrefs::instance()->mWTshowDetails, |
332 | KOPrefs::instance()->mWTshowCreated, | 332 | KOPrefs::instance()->mWTshowCreated, |
333 | KOPrefs::instance()->mWTshowChanged); | 333 | KOPrefs::instance()->mWTshowChanged); |
334 | return i18n("That is the list view" ); | 334 | return i18n("That is the list view" ); |
335 | 335 | ||
336 | } | 336 | } |
337 | 337 | ||
338 | void KOListView::updateList() | 338 | void KOListView::updateList() |
339 | { | 339 | { |
340 | // qDebug(" KOListView::updateList() "); | 340 | // qDebug(" KOListView::updateList() "); |
341 | 341 | ||
342 | } | 342 | } |
343 | 343 | ||
344 | void KOListView::addCat( ) | 344 | void KOListView::addCat( ) |
345 | { | 345 | { |
346 | setCategories( false ); | 346 | setCategories( false ); |
347 | } | 347 | } |
348 | void KOListView::setCat() | 348 | void KOListView::setCat() |
349 | { | 349 | { |
350 | setCategories( true ); | 350 | setCategories( true ); |
351 | } | 351 | } |
352 | void KOListView::setAlarm() | 352 | void KOListView::setAlarm() |
353 | { | 353 | { |
354 | KOAlarmPrefs kap( this); | 354 | KOAlarmPrefs kap( this); |
355 | if ( !kap.exec() ) | 355 | if ( !kap.exec() ) |
356 | return; | 356 | return; |
357 | 357 | ||
358 | 358 | ||
359 | QStringList itemList; | 359 | QStringList itemList; |
360 | QPtrList<KOListViewItem> sel ; | 360 | QPtrList<KOListViewItem> sel ; |
361 | QListViewItem *qitem = mListView->firstChild (); | 361 | QListViewItem *qitem = mListView->firstChild (); |
362 | while ( qitem ) { | 362 | while ( qitem ) { |
363 | if ( qitem->isSelected() ) { | 363 | if ( qitem->isSelected() ) { |
364 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 364 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
365 | if ( inc->type() != "Journal" ) { | 365 | if ( inc->type() != "Journal" ) { |
366 | if ( inc->type() == "Todo" ) { | 366 | if ( inc->type() == "Todo" ) { |
367 | if ( ((Todo*)inc)->hasDueDate() ) | 367 | if ( ((Todo*)inc)->hasDueDate() ) |
368 | sel.append(((KOListViewItem *)qitem)); | 368 | sel.append(((KOListViewItem *)qitem)); |
369 | } else | 369 | } else |
370 | sel.append(((KOListViewItem *)qitem)); | 370 | sel.append(((KOListViewItem *)qitem)); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | qitem = qitem->nextSibling(); | 373 | qitem = qitem->nextSibling(); |
374 | } | 374 | } |
375 | int count = 0; | 375 | int count = 0; |
376 | KOListViewItem * item, *temp; | 376 | KOListViewItem * item, *temp; |
377 | item = sel.first(); | 377 | item = sel.first(); |
378 | Incidence* inc; | 378 | Incidence* inc; |
379 | while ( item ) { | 379 | while ( item ) { |
380 | inc = item->data(); | 380 | inc = item->data(); |
381 | ++count; | 381 | ++count; |
382 | if (kap.mAlarmButton->isChecked()) { | 382 | if (kap.mAlarmButton->isChecked()) { |
383 | if (inc->alarms().count() == 0) | 383 | if (inc->alarms().count() == 0) |
384 | inc->newAlarm(); | 384 | inc->newAlarm(); |
385 | QPtrList<Alarm> alarms = inc->alarms(); | 385 | QPtrList<Alarm> alarms = inc->alarms(); |
386 | Alarm *alarm; | 386 | Alarm *alarm; |
387 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 387 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
388 | alarm->setEnabled(true); | 388 | alarm->setEnabled(true); |
389 | int j = kap.mAlarmTimeEdit->value()* -60; | 389 | int j = kap.mAlarmTimeEdit->value()* -60; |
390 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 390 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
391 | j = j * 60; | 391 | j = j * 60; |
392 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 392 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
393 | j = j * (60 * 24); | 393 | j = j * (60 * 24); |
394 | alarm->setStartOffset( j ); | 394 | alarm->setStartOffset( j ); |
395 | 395 | ||
396 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 396 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
397 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 397 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
398 | } | 398 | } |
399 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 399 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
400 | alarm->setAudioAlarm(kap.mAlarmSound); | 400 | alarm->setAudioAlarm(kap.mAlarmSound); |
401 | else | 401 | else |
402 | alarm->setType(Alarm::Invalid); | 402 | alarm->setType(Alarm::Invalid); |
403 | //alarm->setAudioAlarm("default"); | 403 | //alarm->setAudioAlarm("default"); |
404 | // TODO: Deal with multiple alarms | 404 | // TODO: Deal with multiple alarms |
405 | break; // For now, stop after the first alarm | 405 | break; // For now, stop after the first alarm |
406 | } | 406 | } |
407 | } else { | 407 | } else { |
408 | Alarm* alarm = inc->alarms().first(); | 408 | Alarm* alarm = inc->alarms().first(); |
409 | if ( alarm ) { | 409 | if ( alarm ) { |
410 | alarm->setEnabled(false); | 410 | alarm->setEnabled(false); |
411 | alarm->setType(Alarm::Invalid); | 411 | alarm->setType(Alarm::Invalid); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | temp = item; | 414 | temp = item; |
415 | item = sel.next(); | 415 | item = sel.next(); |
416 | mUidDict.remove( inc->uid() ); | 416 | mUidDict.remove( inc->uid() ); |
417 | delete temp;; | 417 | delete temp;; |
418 | addIncidence( inc ); | 418 | addIncidence( inc ); |
419 | } | 419 | } |
420 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | 420 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); |
421 | qDebug("KO: Set alarm for %d items", count); | 421 | qDebug("KO: Set alarm for %d items", count); |
422 | calendar()->reInitAlarmSettings(); | 422 | calendar()->reInitAlarmSettings(); |
423 | } | 423 | } |
424 | void KOListView::setCategories( bool removeOld ) | 424 | void KOListView::setCategories( bool removeOld ) |
425 | { | 425 | { |
426 | 426 | ||
427 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 427 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
428 | if (! csd->exec()) { | 428 | if (! csd->exec()) { |
429 | delete csd; | 429 | delete csd; |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | QStringList catList = csd->selectedCategories(); | 432 | QStringList catList = csd->selectedCategories(); |
433 | delete csd; | 433 | delete csd; |
434 | // if ( catList.count() == 0 ) | 434 | // if ( catList.count() == 0 ) |
435 | // return; | 435 | // return; |
436 | catList.sort(); | 436 | catList.sort(); |
437 | QString categoriesStr = catList.join(","); | 437 | QString categoriesStr = catList.join(","); |
438 | int i; | 438 | int i; |
439 | QStringList itemList; | 439 | QStringList itemList; |
440 | QPtrList<KOListViewItem> sel ; | 440 | QPtrList<KOListViewItem> sel ; |
441 | QListViewItem *qitem = mListView->firstChild (); | 441 | QListViewItem *qitem = mListView->firstChild (); |
442 | while ( qitem ) { | 442 | while ( qitem ) { |
443 | if ( qitem->isSelected() ) { | 443 | if ( qitem->isSelected() ) { |
444 | sel.append(((KOListViewItem *)qitem)); | 444 | sel.append(((KOListViewItem *)qitem)); |
445 | } | 445 | } |
446 | qitem = qitem->nextSibling(); | 446 | qitem = qitem->nextSibling(); |
447 | } | 447 | } |
448 | KOListViewItem * item, *temp; | 448 | KOListViewItem * item, *temp; |
449 | item = sel.first(); | 449 | item = sel.first(); |
450 | Incidence* inc; | 450 | Incidence* inc; |
451 | while ( item ) { | 451 | while ( item ) { |
452 | inc = item->data(); | 452 | inc = item->data(); |
453 | if ( removeOld ) { | 453 | if ( removeOld ) { |
454 | inc->setCategories( categoriesStr ); | 454 | inc->setCategories( categoriesStr ); |
455 | } else { | 455 | } else { |
456 | itemList = QStringList::split (",", inc->categoriesStr() ); | 456 | itemList = QStringList::split (",", inc->categoriesStr() ); |
457 | for( i = 0; i< catList.count(); ++i ) { | 457 | for( i = 0; i< catList.count(); ++i ) { |
458 | if ( !itemList.contains (catList[i])) | 458 | if ( !itemList.contains (catList[i])) |
459 | itemList.append( catList[i] ); | 459 | itemList.append( catList[i] ); |
460 | } | 460 | } |
461 | itemList.sort(); | 461 | itemList.sort(); |
462 | inc->setCategories( itemList.join(",") ); | 462 | inc->setCategories( itemList.join(",") ); |
463 | } | 463 | } |
464 | temp = item; | 464 | temp = item; |
465 | item = sel.next(); | 465 | item = sel.next(); |
466 | mUidDict.remove( inc->uid() ); | 466 | mUidDict.remove( inc->uid() ); |
467 | delete temp;; | 467 | delete temp;; |
468 | addIncidence( inc ); | 468 | addIncidence( inc ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | void KOListView::beamSelected() | 472 | void KOListView::beamSelected() |
473 | { | 473 | { |
474 | int icount = 0; | 474 | int icount = 0; |
475 | QPtrList<Incidence> delSel ; | 475 | QPtrList<Incidence> delSel ; |
476 | QListViewItem *item = mListView->firstChild (); | 476 | QListViewItem *item = mListView->firstChild (); |
477 | while ( item ) { | 477 | while ( item ) { |
478 | if ( item->isSelected() ) { | 478 | if ( item->isSelected() ) { |
479 | delSel.append(((KOListViewItem *)item)->data()); | 479 | delSel.append(((KOListViewItem *)item)->data()); |
480 | ++icount; | 480 | ++icount; |
481 | } | 481 | } |
482 | 482 | ||
483 | item = item->nextSibling(); | 483 | item = item->nextSibling(); |
484 | } | 484 | } |
485 | if ( icount ) { | 485 | if ( icount ) { |
486 | emit beamIncidenceList( delSel ); | 486 | emit beamIncidenceList( delSel ); |
487 | return; | 487 | return; |
488 | QString fn ; | 488 | QString fn ; |
489 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 489 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
490 | QString mes; | 490 | QString mes; |
491 | bool createbup = true; | 491 | bool createbup = true; |
492 | if ( createbup ) { | 492 | if ( createbup ) { |
493 | QString description = "\n"; | 493 | QString description = "\n"; |
494 | CalendarLocal* cal = new CalendarLocal(); | 494 | CalendarLocal* cal = new CalendarLocal(); |
495 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 495 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
496 | Incidence *incidence = delSel.first(); | 496 | Incidence *incidence = delSel.first(); |
497 | while ( incidence ) { | 497 | while ( incidence ) { |
498 | Incidence *in = incidence->clone(); | 498 | Incidence *in = incidence->clone(); |
499 | description += in->summary() + "\n"; | 499 | description += in->summary() + "\n"; |
500 | cal->addIncidence( in ); | 500 | cal->addIncidence( in ); |
501 | incidence = delSel.next(); | 501 | incidence = delSel.next(); |
502 | } | 502 | } |
503 | FileStorage storage( cal, fn, new VCalFormat ); | 503 | FileStorage storage( cal, fn, new VCalFormat ); |
504 | storage.save(); | 504 | storage.save(); |
505 | delete cal; | 505 | delete cal; |
506 | mes = i18n("KO/Pi: Ready for beaming"); | 506 | mes = i18n("KO/Pi: Ready for beaming"); |
507 | topLevelWidget()->setCaption(mes); | 507 | topLevelWidget()->setCaption(mes); |
508 | 508 | ||
509 | #ifndef DESKTOP_VERSION | 509 | #ifndef DESKTOP_VERSION |
510 | Ir *ir = new Ir( this ); | 510 | Ir *ir = new Ir( this ); |
511 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 511 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
512 | ir->send( fn, description, "text/x-vCalendar" ); | 512 | ir->send( fn, description, "text/x-vCalendar" ); |
513 | #endif | 513 | #endif |
514 | } | 514 | } |
515 | } | 515 | } |
516 | } | 516 | } |
517 | void KOListView::beamDone( Ir *ir ) | 517 | void KOListView::beamDone( Ir *ir ) |
518 | { | 518 | { |
519 | #ifndef DESKTOP_VERSION | 519 | #ifndef DESKTOP_VERSION |
520 | delete ir; | 520 | delete ir; |
521 | #endif | 521 | #endif |
522 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 522 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
523 | } | 523 | } |
524 | 524 | ||
525 | void KOListView::saveDescriptionToFile() | 525 | void KOListView::saveDescriptionToFile() |
526 | { | 526 | { |
527 | 527 | ||
528 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 528 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
529 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 529 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
530 | i18n("Continue"), i18n("Cancel"), 0, | 530 | i18n("Continue"), i18n("Cancel"), 0, |
531 | 0, 1 ); | 531 | 0, 1 ); |
532 | if ( result != 0 ) { | 532 | if ( result != 0 ) { |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | int icount = 0; | 535 | int icount = 0; |
536 | QPtrList<Incidence> delSel ; | 536 | QPtrList<Incidence> delSel ; |
537 | QListViewItem *item = mListView->firstChild (); | 537 | QListViewItem *item = mListView->firstChild (); |
538 | while ( item ) { | 538 | while ( item ) { |
539 | if ( item->isSelected() ) { | 539 | if ( item->isSelected() ) { |
540 | delSel.append(((KOListViewItem *)item)->data()); | 540 | delSel.append(((KOListViewItem *)item)->data()); |
541 | ++icount; | 541 | ++icount; |
542 | } | 542 | } |
543 | 543 | ||
544 | item = item->nextSibling(); | 544 | item = item->nextSibling(); |
545 | } | 545 | } |
546 | if ( icount ) { | 546 | if ( icount ) { |
547 | QString fn = KOPrefs::instance()->mLastSaveFile; | 547 | QString fn = KOPrefs::instance()->mLastSaveFile; |
548 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 548 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
549 | 549 | ||
550 | if ( fn == "" ) | 550 | if ( fn == "" ) |
551 | return; | 551 | return; |
552 | QFileInfo info; | 552 | QFileInfo info; |
553 | info.setFile( fn ); | 553 | info.setFile( fn ); |
554 | QString mes; | 554 | QString mes; |
555 | bool createbup = true; | 555 | bool createbup = true; |
556 | if ( info. exists() ) { | 556 | if ( info. exists() ) { |
557 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 557 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
558 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 558 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
559 | i18n("Overwrite!"), i18n("Cancel"), 0, | 559 | i18n("Overwrite!"), i18n("Cancel"), 0, |
560 | 0, 1 ); | 560 | 0, 1 ); |
561 | if ( result != 0 ) { | 561 | if ( result != 0 ) { |
562 | createbup = false; | 562 | createbup = false; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | if ( createbup ) { | 565 | if ( createbup ) { |
566 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 566 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
567 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 567 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
568 | Incidence *incidence = delSel.first(); | 568 | Incidence *incidence = delSel.first(); |
569 | icount = 0; | 569 | icount = 0; |
570 | while ( incidence ) { | 570 | while ( incidence ) { |
571 | if ( incidence->type() == "Journal" ) { | 571 | if ( incidence->type() == "Journal" ) { |
572 | text += "\n************************************\n"; | 572 | text += "\n************************************\n"; |
573 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 573 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
574 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 574 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
575 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 575 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
576 | ++icount; | 576 | ++icount; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( !incidence->description().isEmpty() ) { | 579 | if ( !incidence->description().isEmpty() ) { |
580 | text += "\n************************************\n"; | 580 | text += "\n************************************\n"; |
581 | if ( incidence->type() == "Todo" ) | 581 | if ( incidence->type() == "Todo" ) |
582 | text += i18n("To-Do: "); | 582 | text += i18n("To-Do: "); |
583 | text += incidence->summary(); | 583 | text += incidence->summary(); |
584 | if ( incidence->hasStartDate() ) | 584 | if ( incidence->hasStartDate() ) |
585 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 585 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
586 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 586 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
587 | if ( !incidence->location().isEmpty() ) | 587 | if ( !incidence->location().isEmpty() ) |
588 | text += "\n" +i18n("Location: ") + incidence->location(); | 588 | text += "\n" +i18n("Location: ") + incidence->location(); |
589 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 589 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
590 | ++icount; | 590 | ++icount; |
591 | 591 | ||
592 | } | 592 | } |
593 | } | 593 | } |
594 | incidence = delSel.next(); | 594 | incidence = delSel.next(); |
595 | } | 595 | } |
596 | QFile file( fn ); | 596 | QFile file( fn ); |
597 | if (!file.open( IO_WriteOnly ) ) { | 597 | if (!file.open( IO_WriteOnly ) ) { |
598 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 598 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
599 | return; | 599 | return; |
600 | } | 600 | } |
601 | QTextStream ts( &file ); | 601 | QTextStream ts( &file ); |
602 | ts << text; | 602 | ts << text; |
603 | file.close(); | 603 | file.close(); |
604 | //qDebug("%s ", text.latin1()); | 604 | //qDebug("%s ", text.latin1()); |
605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
606 | KOPrefs::instance()->mLastSaveFile = fn; | 606 | KOPrefs::instance()->mLastSaveFile = fn; |
607 | topLevelWidget()->setCaption(mes); | 607 | topLevelWidget()->setCaption(mes); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | void KOListView::saveToFileVCS() | 611 | void KOListView::saveToFileVCS() |
612 | { | 612 | { |
613 | writeToFile( false ); | 613 | writeToFile( false ); |
614 | } | 614 | } |
615 | void KOListView::saveToFile() | 615 | void KOListView::saveToFile() |
616 | { | 616 | { |
617 | writeToFile( true ); | 617 | writeToFile( true ); |
618 | } | 618 | } |
619 | void KOListView::writeToFile( bool iCal ) | 619 | void KOListView::writeToFile( bool iCal ) |
620 | { | 620 | { |
621 | 621 | ||
622 | int icount = 0; | 622 | int icount = 0; |
623 | QPtrList<Incidence> delSel ; | 623 | QPtrList<Incidence> delSel ; |
624 | QListViewItem *item = mListView->firstChild (); | 624 | QListViewItem *item = mListView->firstChild (); |
625 | bool journal = iCal; // warn only for vCal | 625 | bool journal = iCal; // warn only for vCal |
626 | while ( item ) { | 626 | while ( item ) { |
627 | if ( item->isSelected() ) { | 627 | if ( item->isSelected() ) { |
628 | if ( !journal ) | 628 | if ( !journal ) |
629 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") | 629 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") |
630 | journal = true; | 630 | journal = true; |
631 | delSel.append(((KOListViewItem *)item)->data()); | 631 | delSel.append(((KOListViewItem *)item)->data()); |
632 | ++icount; | 632 | ++icount; |
633 | } | 633 | } |
634 | 634 | ||
635 | item = item->nextSibling(); | 635 | item = item->nextSibling(); |
636 | } | 636 | } |
637 | if ( !iCal && journal ) { | 637 | if ( !iCal && journal ) { |
638 | int result = KMessageBox::warningContinueCancel(this, | 638 | int result = KMessageBox::warningContinueCancel(this, |
639 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 639 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
640 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 640 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
641 | true); | 641 | true); |
642 | if (result != KMessageBox::Continue) return; | 642 | if (result != KMessageBox::Continue) return; |
643 | } | 643 | } |
644 | if ( icount ) { | 644 | if ( icount ) { |
645 | QString fn = KOPrefs::instance()->mLastSaveFile; | 645 | QString fn = KOPrefs::instance()->mLastSaveFile; |
646 | QString extension; | 646 | QString extension; |
647 | if ( iCal ) { | 647 | if ( iCal ) { |
648 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 648 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
649 | fn = fn.left( fn.length() -3) + "ics"; | 649 | fn = fn.left( fn.length() -3) + "ics"; |
650 | } | 650 | } |
651 | } else { | 651 | } else { |
652 | if ( fn.right( 4 ).lower() == ".ics" ) { | 652 | if ( fn.right( 4 ).lower() == ".ics" ) { |
653 | fn = fn.left( fn.length() -3) + "vcs"; | 653 | fn = fn.left( fn.length() -3) + "vcs"; |
654 | } | 654 | } |
655 | } | 655 | } |
656 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 656 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
657 | 657 | ||
658 | if ( fn == "" ) | 658 | if ( fn == "" ) |
659 | return; | 659 | return; |
660 | QFileInfo info; | 660 | QFileInfo info; |
661 | info.setFile( fn ); | 661 | info.setFile( fn ); |
662 | QString mes; | 662 | QString mes; |
663 | bool createbup = true; | 663 | bool createbup = true; |
664 | if ( info. exists() ) { | 664 | if ( info. exists() ) { |
665 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 665 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
667 | i18n("Overwrite!"), i18n("Cancel"), 0, | 667 | i18n("Overwrite!"), i18n("Cancel"), 0, |
668 | 0, 1 ); | 668 | 0, 1 ); |
669 | if ( result != 0 ) { | 669 | if ( result != 0 ) { |
670 | createbup = false; | 670 | createbup = false; |
671 | } | 671 | } |
672 | } | 672 | } |
673 | if ( createbup ) { | 673 | if ( createbup ) { |
674 | CalendarLocal cal; | 674 | CalendarLocal cal; |
675 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 675 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
676 | Incidence *incidence = delSel.first(); | 676 | Incidence *incidence = delSel.first(); |
677 | while ( incidence ) { | 677 | while ( incidence ) { |
678 | cal.addIncidence( incidence->clone() ); | 678 | cal.addIncidence( incidence->clone() ); |
679 | incidence = delSel.next(); | 679 | incidence = delSel.next(); |
680 | } | 680 | } |
681 | if ( iCal ) { | 681 | if ( iCal ) { |
682 | ICalFormat format; | 682 | ICalFormat format; |
683 | format.save( &cal, fn ); | 683 | format.save( &cal, fn ); |
684 | } else { | 684 | } else { |
685 | 685 | ||
686 | VCalFormat format; | 686 | VCalFormat format; |
687 | format.save( &cal, fn ); | 687 | format.save( &cal, fn ); |
688 | } | 688 | } |
689 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 689 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
690 | KOPrefs::instance()->mLastSaveFile = fn; | 690 | KOPrefs::instance()->mLastSaveFile = fn; |
691 | topLevelWidget()->setCaption(mes); | 691 | topLevelWidget()->setCaption(mes); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | } | 694 | } |
695 | void KOListView::deleteAll() | 695 | void KOListView::deleteAll() |
696 | { | 696 | { |
697 | int icount = 0; | 697 | int icount = 0; |
698 | QPtrList<Incidence> delSel ; | 698 | QPtrList<Incidence> delSel ; |
699 | QListViewItem *item = mListView->firstChild (); | 699 | QListViewItem *item = mListView->firstChild (); |
700 | while ( item ) { | 700 | while ( item ) { |
701 | if ( item->isSelected() ) { | 701 | if ( item->isSelected() ) { |
702 | delSel.append(((KOListViewItem *)item)->data()); | 702 | delSel.append(((KOListViewItem *)item)->data()); |
703 | ++icount; | 703 | ++icount; |
704 | } | 704 | } |
705 | 705 | ||
706 | item = item->nextSibling(); | 706 | item = item->nextSibling(); |
707 | } | 707 | } |
708 | if ( icount ) { | 708 | if ( icount ) { |
709 | Incidence *incidence = delSel.first(); | 709 | Incidence *incidence = delSel.first(); |
710 | Incidence *toDelete; | 710 | Incidence *toDelete; |
711 | KOPrefs *p = KOPrefs::instance(); | 711 | KOPrefs *p = KOPrefs::instance(); |
712 | bool confirm = p->mConfirm; | 712 | bool confirm = p->mConfirm; |
713 | QString mess; | 713 | QString mess; |
714 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 714 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
715 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 715 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
716 | p->mConfirm = false; | 716 | p->mConfirm = false; |
717 | int delCounter = 0; | 717 | int delCounter = 0; |
718 | QDialog dia ( this, "p-dialog", true ); | 718 | QDialog dia ( this, "p-dialog", true ); |
719 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 719 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
720 | QVBoxLayout lay( &dia ); | 720 | QVBoxLayout lay( &dia ); |
721 | lay.setMargin(7); | 721 | lay.setMargin(7); |
722 | lay.setSpacing(7); | 722 | lay.setSpacing(7); |
723 | lay.addWidget( &lab); | 723 | lay.addWidget( &lab); |
724 | QProgressBar bar( icount, &dia ); | 724 | QProgressBar bar( icount, &dia ); |
725 | lay.addWidget( &bar); | 725 | lay.addWidget( &bar); |
726 | int w = 220; | 726 | int w = 220; |
727 | int h = 50; | 727 | int h = 50; |
728 | int dw = QApplication::desktop()->width(); | 728 | int dw = QApplication::desktop()->width(); |
729 | int dh = QApplication::desktop()->height(); | 729 | int dh = QApplication::desktop()->height(); |
730 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 730 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
731 | //dia.resize( 240,50 ); | 731 | //dia.resize( 240,50 ); |
732 | dia.show(); | 732 | dia.show(); |
733 | 733 | ||
734 | while ( incidence ) { | 734 | while ( incidence ) { |
735 | bar.setProgress( delCounter ); | 735 | bar.setProgress( delCounter ); |
736 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 736 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
737 | dia.setCaption( mess ); | 737 | dia.setCaption( mess ); |
738 | qApp->processEvents(); | 738 | qApp->processEvents(); |
739 | toDelete = (incidence); | 739 | toDelete = (incidence); |
740 | incidence = delSel.next(); | 740 | incidence = delSel.next(); |
741 | emit deleteIncidenceSignal(toDelete ); | 741 | emit deleteIncidenceSignal(toDelete ); |
742 | if ( dia.result() != 0 ) | 742 | if ( dia.result() != 0 ) |
743 | break; | 743 | break; |
744 | 744 | ||
745 | } | 745 | } |
746 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 746 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
747 | topLevelWidget ()->setCaption( mess ); | 747 | topLevelWidget ()->setCaption( mess ); |
748 | p->mConfirm = confirm; | 748 | p->mConfirm = confirm; |
749 | } | 749 | } |
750 | } | 750 | } |
751 | 751 | ||
752 | 752 | ||
753 | } | 753 | } |
754 | int KOListView::maxDatesHint() | 754 | int KOListView::maxDatesHint() |
755 | { | 755 | { |
756 | return 0; | 756 | return 0; |
757 | } | 757 | } |
758 | 758 | ||
759 | int KOListView::currentDateCount() | 759 | int KOListView::currentDateCount() |
760 | { | 760 | { |
761 | return 0; | 761 | return 0; |
762 | } | 762 | } |
763 | 763 | ||
764 | QPtrList<Incidence> KOListView::selectedIncidences() | 764 | QPtrList<Incidence> KOListView::selectedIncidences() |
765 | { | 765 | { |
766 | QPtrList<Incidence> eventList; | 766 | QPtrList<Incidence> eventList; |
767 | QListViewItem *item = mListView->firstChild (); | 767 | QListViewItem *item = mListView->firstChild (); |
768 | while ( item ) { | 768 | while ( item ) { |
769 | if ( item->isSelected() ) { | 769 | if ( item->isSelected() ) { |
770 | eventList.append(((KOListViewItem *)item)->data()); | 770 | eventList.append(((KOListViewItem *)item)->data()); |
771 | } | 771 | } |
772 | 772 | ||
773 | item = item->nextSibling(); | 773 | item = item->nextSibling(); |
774 | } | 774 | } |
775 | 775 | ||
776 | // // QListViewItem *item = mListView->selectedItem(); | 776 | // // QListViewItem *item = mListView->selectedItem(); |
777 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 777 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
778 | 778 | ||
779 | return eventList; | 779 | return eventList; |
780 | } | 780 | } |
781 | 781 | ||
782 | DateList KOListView::selectedDates() | 782 | DateList KOListView::selectedDates() |
783 | { | 783 | { |
784 | DateList eventList; | 784 | DateList eventList; |
785 | return eventList; | 785 | return eventList; |
786 | } | 786 | } |
787 | 787 | ||
788 | void KOListView::showDates(bool show) | 788 | void KOListView::showDates(bool show) |
789 | { | 789 | { |
790 | // Shouldn't we set it to a value greater 0? When showDates is called with | 790 | // Shouldn't we set it to a value greater 0? When showDates is called with |
791 | // show == true at first, then the columnwidths are set to zero. | 791 | // show == true at first, then the columnwidths are set to zero. |
792 | static int oldColWidth1 = 0; | 792 | static int oldColWidth1 = 0; |
793 | static int oldColWidth3 = 0; | 793 | static int oldColWidth3 = 0; |
794 | 794 | ||
795 | if (!show) { | 795 | if (!show) { |
796 | oldColWidth1 = mListView->columnWidth(1); | 796 | oldColWidth1 = mListView->columnWidth(1); |
797 | oldColWidth3 = mListView->columnWidth(3); | 797 | oldColWidth3 = mListView->columnWidth(3); |
798 | mListView->setColumnWidth(1, 0); | 798 | mListView->setColumnWidth(1, 0); |
799 | mListView->setColumnWidth(3, 0); | 799 | mListView->setColumnWidth(3, 0); |
800 | } else { | 800 | } else { |
801 | mListView->setColumnWidth(1, oldColWidth1); | 801 | mListView->setColumnWidth(1, oldColWidth1); |
802 | mListView->setColumnWidth(3, oldColWidth3); | 802 | mListView->setColumnWidth(3, oldColWidth3); |
803 | } | 803 | } |
804 | mListView->repaint(); | 804 | mListView->repaint(); |
805 | } | 805 | } |
806 | 806 | ||
807 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 807 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
808 | const QDate &td) | 808 | const QDate &td) |
809 | { | 809 | { |
810 | #ifndef KORG_NOPRINTER | 810 | #ifndef KORG_NOPRINTER |
811 | calPrinter->preview(CalPrinter::Day, fd, td); | 811 | calPrinter->preview(CalPrinter::Day, fd, td); |
812 | #endif | 812 | #endif |
813 | } | 813 | } |
814 | 814 | ||
815 | void KOListView::showDates() | 815 | void KOListView::showDates() |
816 | { | 816 | { |
817 | showDates(true); | 817 | showDates(true); |
818 | } | 818 | } |
819 | 819 | ||
820 | void KOListView::hideDates() | 820 | void KOListView::hideDates() |
821 | { | 821 | { |
822 | showDates(false); | 822 | showDates(false); |
823 | } | 823 | } |
824 | void KOListView::resetFocus() | 824 | void KOListView::resetFocus() |
825 | { | 825 | { |
826 | mListView->setFocus(); | 826 | mListView->setFocus(); |
827 | } | 827 | } |
828 | void KOListView::updateView() | 828 | void KOListView::updateView() |
829 | { | 829 | { |
830 | mListView->setFocus(); | 830 | mListView->setFocus(); |
831 | if ( mListView->firstChild () ) | 831 | if ( mListView->firstChild () ) |
832 | mListView->setCurrentItem( mListView->firstChild () ); | 832 | mListView->setCurrentItem( mListView->firstChild () ); |
833 | } | 833 | } |
834 | void KOListView::updateConfig() | 834 | void KOListView::updateConfig() |
835 | { | 835 | { |
836 | 836 | ||
837 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 837 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
838 | updateView(); | 838 | updateView(); |
839 | 839 | ||
840 | } | 840 | } |
841 | void KOListView::setStartDate(const QDate &start) | 841 | void KOListView::setStartDate(const QDate &start) |
842 | { | 842 | { |
843 | mStartDate = start; | 843 | mStartDate = start; |
844 | } | 844 | } |
845 | 845 | ||
846 | void KOListView::showDates(const QDate &start, const QDate &end) | 846 | void KOListView::showDates(const QDate &start, const QDate &end) |
847 | { | 847 | { |
848 | clear(); | 848 | clear(); |
849 | mStartDate = start; | 849 | mStartDate = start; |
850 | QDate date = start; | 850 | QDate date = start; |
851 | QPtrList<Journal> j_list; | 851 | QPtrList<Journal> j_list; |
852 | while( date <= end ) { | 852 | while( date <= end ) { |
853 | addEvents(calendar()->events(date)); | 853 | addEvents(calendar()->events(date)); |
854 | addTodos(calendar()->todos(date)); | 854 | addTodos(calendar()->todos(date)); |
855 | Journal* jo = calendar()->journal(date); | 855 | Journal* jo = calendar()->journal(date); |
856 | if ( jo ) | 856 | if ( jo ) |
857 | j_list.append( jo ); | 857 | j_list.append( jo ); |
858 | date = date.addDays( 1 ); | 858 | date = date.addDays( 1 ); |
859 | } | 859 | } |
860 | addJournals(j_list); | 860 | addJournals(j_list); |
861 | emit incidenceSelected( 0 ); | 861 | emit incidenceSelected( 0 ); |
862 | updateView(); | 862 | updateView(); |
863 | 863 | ||
864 | } | 864 | } |
865 | 865 | ||
866 | void KOListView::addEvents(QPtrList<Event> eventList) | 866 | void KOListView::addEvents(QPtrList<Event> eventList) |
867 | { | 867 | { |
868 | Event *ev; | 868 | Event *ev; |
869 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 869 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
870 | addIncidence(ev); | 870 | addIncidence(ev); |
871 | } | 871 | } |
872 | if ( !mListView->currentItem() ){ | 872 | if ( !mListView->currentItem() ){ |
873 | updateView(); | 873 | updateView(); |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void KOListView::addTodos(QPtrList<Todo> eventList) | 877 | void KOListView::addTodos(QPtrList<Todo> eventList) |
878 | { | 878 | { |
879 | Todo *ev; | 879 | Todo *ev; |
880 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 880 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
881 | addIncidence(ev); | 881 | addIncidence(ev); |
882 | } | 882 | } |
883 | if ( !mListView->currentItem() ){ | 883 | if ( !mListView->currentItem() ){ |
884 | updateView(); | 884 | updateView(); |
885 | } | 885 | } |
886 | } | 886 | } |
887 | void KOListView::addJournals(QPtrList<Journal> eventList) | 887 | void KOListView::addJournals(QPtrList<Journal> eventList) |
888 | { | 888 | { |
889 | Journal *ev; | 889 | Journal *ev; |
890 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 890 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
891 | addIncidence(ev); | 891 | addIncidence(ev); |
892 | } | 892 | } |
893 | if ( !mListView->currentItem() ){ | 893 | if ( !mListView->currentItem() ){ |
894 | updateView(); | 894 | updateView(); |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | void KOListView::addIncidence(Incidence *incidence) | 898 | void KOListView::addIncidence(Incidence *incidence) |
899 | { | 899 | { |
900 | if ( mUidDict.find( incidence->uid() ) ) return; | 900 | if ( mUidDict.find( incidence->uid() ) ) return; |
901 | 901 | ||
902 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 902 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
903 | mUidDict.insert( incidence->uid(), incidence ); | 903 | mUidDict.insert( incidence->uid(), incidence ); |
904 | 904 | ||
905 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 905 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
906 | ListItemVisitor v(item, mStartDate ); | 906 | ListItemVisitor v(item, mStartDate ); |
907 | if (incidence->accept(v)) return; | 907 | if (incidence->accept(v)) return; |
908 | else delete item; | 908 | else delete item; |
909 | //qDebug("delete item "); | 909 | //qDebug("delete item "); |
910 | } | 910 | } |
911 | 911 | ||
912 | void KOListView::showEvents(QPtrList<Event> eventList) | 912 | void KOListView::showEvents(QPtrList<Event> eventList) |
913 | { | 913 | { |
914 | clear(); | 914 | clear(); |
915 | 915 | ||
916 | addEvents(eventList); | 916 | addEvents(eventList); |
917 | 917 | ||
918 | // After new creation of list view no events are selected. | 918 | // After new creation of list view no events are selected. |
919 | emit incidenceSelected( 0 ); | 919 | emit incidenceSelected( 0 ); |
920 | } | 920 | } |
921 | int KOListView::count() | 921 | int KOListView::count() |
922 | { | 922 | { |
923 | return mListView->childCount(); | 923 | return mListView->childCount(); |
924 | } | 924 | } |
925 | 925 | ||
926 | void KOListView::changeEventDisplay(Event *event, int action) | 926 | void KOListView::changeEventDisplay(Event *event, int action) |
927 | { | 927 | { |
928 | KOListViewItem *item; | 928 | KOListViewItem *item; |
929 | 929 | ||
930 | switch(action) { | 930 | switch(action) { |
931 | case KOGlobals::EVENTADDED: | 931 | case KOGlobals::EVENTADDED: |
932 | addIncidence( event ); | 932 | addIncidence( event ); |
933 | break; | 933 | break; |
934 | case KOGlobals::EVENTEDITED: | 934 | case KOGlobals::EVENTEDITED: |
935 | item = getItemForEvent(event); | 935 | item = getItemForEvent(event); |
936 | if (item) { | 936 | if (item) { |
937 | mUidDict.remove( event->uid() ); | 937 | mUidDict.remove( event->uid() ); |
938 | delete item; | 938 | delete item; |
939 | addIncidence( event ); | 939 | addIncidence( event ); |
940 | } | 940 | } |
941 | break; | 941 | break; |
942 | case KOGlobals::EVENTDELETED: | 942 | case KOGlobals::EVENTDELETED: |
943 | item = getItemForEvent(event); | 943 | item = getItemForEvent(event); |
944 | if (item) { | 944 | if (item) { |
945 | mUidDict.remove( event->uid() ); | 945 | mUidDict.remove( event->uid() ); |
946 | delete item; | 946 | delete item; |
947 | } | 947 | } |
948 | break; | 948 | break; |
949 | default: | 949 | default: |
950 | ; | 950 | ; |
951 | } | 951 | } |
952 | } | 952 | } |
953 | 953 | ||
954 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 954 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
955 | { | 955 | { |
956 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 956 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
957 | while (item) { | 957 | while (item) { |
958 | if (item->data() == event) return item; | 958 | if (item->data() == event) return item; |
959 | item = (KOListViewItem *)item->nextSibling(); | 959 | item = (KOListViewItem *)item->nextSibling(); |
960 | } | 960 | } |
961 | return 0; | 961 | return 0; |
962 | } | 962 | } |
963 | 963 | ||
964 | void KOListView::defaultItemAction(QListViewItem *i) | 964 | void KOListView::defaultItemAction(QListViewItem *i) |
965 | { | 965 | { |
966 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 966 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
967 | if ( item ) defaultAction( item->data() ); | 967 | if ( item ) defaultAction( item->data() ); |
968 | 968 | ||
969 | } | 969 | } |
970 | 970 | ||
971 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 971 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
972 | { | 972 | { |
973 | mActiveItem = (KOListViewItem *)item; | 973 | mActiveItem = (KOListViewItem *)item; |
974 | if (mActiveItem) { | 974 | if (mActiveItem) { |
975 | Incidence *incidence = mActiveItem->data(); | 975 | Incidence *incidence = mActiveItem->data(); |
976 | mPopupMenu->showIncidencePopup(incidence); | 976 | mPopupMenu->showIncidencePopup(incidence); |
977 | 977 | ||
978 | /* | 978 | /* |
979 | if ( incidence && incidence->type() == "Event" ) { | 979 | if ( incidence && incidence->type() == "Event" ) { |
980 | Event *event = static_cast<Event *>( incidence ); | 980 | Event *event = static_cast<Event *>( incidence ); |
981 | mPopupMenu->showEventPopup(event); | 981 | mPopupMenu->showEventPopup(event); |
982 | } | 982 | } |
983 | */ | 983 | */ |
984 | } | 984 | } |
985 | } | 985 | } |
986 | 986 | ||
987 | void KOListView::readSettings(KConfig *config, QString setting) | 987 | void KOListView::readSettings(KConfig *config, QString setting) |
988 | { | 988 | { |
989 | // qDebug("KOListView::readSettings "); | 989 | // qDebug("KOListView::readSettings "); |
990 | mListView->restoreLayout(config,setting); | 990 | mListView->restoreLayout(config,setting); |
991 | } | 991 | } |
992 | 992 | ||
993 | void KOListView::writeSettings(KConfig *config, QString setting) | 993 | void KOListView::writeSettings(KConfig *config, QString setting) |
994 | { | 994 | { |
995 | // qDebug("KOListView::writeSettings "); | 995 | // qDebug("KOListView::writeSettings "); |
996 | mListView->saveLayout(config, setting); | 996 | mListView->saveLayout(config, setting); |
997 | } | 997 | } |
998 | 998 | ||
999 | void KOListView::processSelectionChange(QListViewItem *) | 999 | void KOListView::processSelectionChange(QListViewItem *) |
1000 | { | 1000 | { |
1001 | 1001 | ||
1002 | KOListViewItem *item = | 1002 | KOListViewItem *item = |
1003 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1003 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1004 | 1004 | ||
1005 | if ( !item ) { | 1005 | if ( !item ) { |
1006 | emit incidenceSelected( 0 ); | 1006 | emit incidenceSelected( 0 ); |
1007 | } else { | 1007 | } else { |
1008 | emit incidenceSelected( item->data() ); | 1008 | emit incidenceSelected( item->data() ); |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void KOListView::clearSelection() | 1012 | void KOListView::clearSelection() |
1013 | { | 1013 | { |
1014 | mListView->selectAll( false ); | 1014 | mListView->selectAll( false ); |
1015 | } | 1015 | } |
1016 | void KOListView::allSelection() | 1016 | void KOListView::allSelection() |
1017 | { | 1017 | { |
1018 | mListView->selectAll( true ); | 1018 | mListView->selectAll( true ); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | void KOListView::clear() | 1021 | void KOListView::clear() |
1022 | { | 1022 | { |
1023 | mListView->clear(); | 1023 | mListView->clear(); |
1024 | mUidDict.clear(); | 1024 | mUidDict.clear(); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | Incidence* KOListView::currentItem() | 1027 | Incidence* KOListView::currentItem() |
1028 | { | 1028 | { |
1029 | if ( mListView->currentItem() ) | 1029 | if ( mListView->currentItem() ) |
1030 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1030 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1031 | return 0; | 1031 | return 0; |
1032 | } | 1032 | } |
1033 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1033 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1034 | { | 1034 | { |
1035 | 1035 | ||
1036 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1036 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1037 | deleteAll(); | 1037 | deleteAll(); |
1038 | return; | 1038 | return; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | e->ignore(); | 1041 | e->ignore(); |
1042 | } | 1042 | } |
1043 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1043 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1044 | { | 1044 | { |
1045 | 1045 | ||
1046 | switch ( e->key() ) { | 1046 | switch ( e->key() ) { |
1047 | case Qt::Key_Down: | 1047 | case Qt::Key_Down: |
1048 | if ( e->state() == ShiftButton ) { | 1048 | if ( e->state() == ShiftButton ) { |
1049 | QListViewItem* cn = currentItem(); | 1049 | QListViewItem* cn = currentItem(); |
1050 | if ( !cn ) | 1050 | if ( !cn ) |
1051 | cn = firstChild(); | 1051 | cn = firstChild(); |
1052 | if ( !cn ) | 1052 | if ( !cn ) |
1053 | return; | 1053 | return; |
1054 | while ( cn->nextSibling() ) | 1054 | while ( cn->nextSibling() ) |
1055 | cn = cn->nextSibling(); | 1055 | cn = cn->nextSibling(); |
1056 | setCurrentItem ( cn ); | 1056 | setCurrentItem ( cn ); |
1057 | ensureItemVisible ( cn ); | 1057 | ensureItemVisible ( cn ); |
1058 | 1058 | ||
1059 | e->accept(); | 1059 | e->accept(); |
1060 | return; | 1060 | return; |
1061 | } | 1061 | } |
1062 | if ( e->state() == ControlButton ) { | 1062 | if ( e->state() == ControlButton ) { |
1063 | int count = childCount (); | 1063 | int count = childCount (); |
1064 | int jump = count / 5; | 1064 | int jump = count / 5; |
1065 | QListViewItem* cn; | 1065 | QListViewItem* cn; |
1066 | cn = currentItem(); | 1066 | cn = currentItem(); |
1067 | if ( ! cn ) | 1067 | if ( ! cn ) |
1068 | return; | 1068 | return; |
1069 | if ( jump == 0 ) | 1069 | if ( jump == 0 ) |
1070 | jump = 1; | 1070 | jump = 1; |
1071 | while ( jump && cn->nextSibling() ) { | 1071 | while ( jump && cn->nextSibling() ) { |
1072 | cn = cn->nextSibling(); | 1072 | cn = cn->nextSibling(); |
1073 | --jump; | 1073 | --jump; |
1074 | } | 1074 | } |
1075 | setCurrentItem ( cn ); | 1075 | setCurrentItem ( cn ); |
1076 | ensureItemVisible ( cn ); | 1076 | ensureItemVisible ( cn ); |
1077 | 1077 | ||
1078 | } else | 1078 | } else |
1079 | QListView::keyPressEvent ( e ) ; | 1079 | QListView::keyPressEvent ( e ) ; |
1080 | e->accept(); | 1080 | e->accept(); |
1081 | break; | 1081 | break; |
1082 | 1082 | ||
1083 | case Qt::Key_Up: | 1083 | case Qt::Key_Up: |
1084 | if ( e->state() == ShiftButton ) { | 1084 | if ( e->state() == ShiftButton ) { |
1085 | QListViewItem* cn = firstChild(); | 1085 | QListViewItem* cn = firstChild(); |
1086 | if ( cn ) { | 1086 | if ( cn ) { |
1087 | setCurrentItem ( cn ); | 1087 | setCurrentItem ( cn ); |
1088 | ensureItemVisible ( cn ); | 1088 | ensureItemVisible ( cn ); |
1089 | } | 1089 | } |
1090 | e->accept(); | 1090 | e->accept(); |
1091 | return; | 1091 | return; |
1092 | } | 1092 | } |
1093 | if ( e->state() == ControlButton ) { | 1093 | if ( e->state() == ControlButton ) { |
1094 | int count = childCount (); | 1094 | int count = childCount (); |
1095 | int jump = count / 5; | 1095 | int jump = count / 5; |
1096 | QListViewItem* cn; | 1096 | QListViewItem* cn; |
1097 | cn = currentItem(); | 1097 | cn = currentItem(); |
1098 | if ( ! cn ) | 1098 | if ( ! cn ) |
1099 | return; | 1099 | return; |
1100 | if ( jump == 0 ) | 1100 | if ( jump == 0 ) |
1101 | jump = 1; | 1101 | jump = 1; |
1102 | while ( jump && cn->itemAbove ()) { | 1102 | while ( jump && cn->itemAbove ()) { |
1103 | cn = cn->itemAbove (); | 1103 | cn = cn->itemAbove (); |
1104 | --jump; | 1104 | --jump; |
1105 | } | 1105 | } |
1106 | setCurrentItem ( cn ); | 1106 | setCurrentItem ( cn ); |
1107 | ensureItemVisible ( cn ); | 1107 | ensureItemVisible ( cn ); |
1108 | } else | 1108 | } else |
1109 | QListView::keyPressEvent ( e ) ; | 1109 | QListView::keyPressEvent ( e ) ; |
1110 | e->accept(); | 1110 | e->accept(); |
1111 | break; | 1111 | break; |
1112 | case Qt::Key_I: { | 1112 | case Qt::Key_I: { |
1113 | QListViewItem* cn; | 1113 | QListViewItem* cn; |
1114 | cn = currentItem(); | 1114 | cn = currentItem(); |
1115 | if ( cn ) { | 1115 | if ( cn ) { |
1116 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1116 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1117 | if ( ci ){ | 1117 | if ( ci ){ |
1118 | //emit showIncidence( ci->data()); | 1118 | //emit showIncidence( ci->data()); |
1119 | cn = cn->nextSibling(); | 1119 | cn = cn->nextSibling(); |
1120 | if ( cn ) { | 1120 | if ( cn ) { |
1121 | setCurrentItem ( cn ); | 1121 | setCurrentItem ( cn ); |
1122 | ensureItemVisible ( cn ); | 1122 | ensureItemVisible ( cn ); |
1123 | } | 1123 | } |
1124 | emit showIncidence( ci->data()); | 1124 | emit showIncidence( ci->data()); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | e->accept(); | 1127 | e->accept(); |
1128 | } | 1128 | } |
1129 | break; | 1129 | break; |
1130 | case Qt::Key_Return: | 1130 | case Qt::Key_Return: |
1131 | case Qt::Key_Enter: | 1131 | case Qt::Key_Enter: |
1132 | { | 1132 | { |
1133 | QListViewItem* cn; | 1133 | QListViewItem* cn; |
1134 | cn = currentItem(); | 1134 | cn = currentItem(); |
1135 | if ( cn ) { | 1135 | if ( cn ) { |
1136 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1136 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1137 | if ( ci ){ | 1137 | if ( ci ){ |
1138 | if ( e->state() == ShiftButton ) | 1138 | if ( e->state() == ShiftButton ) |
1139 | ci->setSelected( false ); | 1139 | ci->setSelected( false ); |
1140 | else | 1140 | else |
1141 | ci->setSelected( true ); | 1141 | ci->setSelected( true ); |
1142 | cn = cn->nextSibling(); | 1142 | cn = cn->nextSibling(); |
1143 | if ( cn ) { | 1143 | if ( cn ) { |
1144 | setCurrentItem ( cn ); | 1144 | setCurrentItem ( cn ); |
1145 | ensureItemVisible ( cn ); | 1145 | ensureItemVisible ( cn ); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | e->accept(); | 1149 | e->accept(); |
1150 | } | 1150 | } |
1151 | break; | 1151 | break; |
1152 | default: | 1152 | default: |
1153 | e->ignore(); | 1153 | e->ignore(); |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1156 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1157 | : KListView( lv, "kolistlistview", false ) | 1157 | : KListView( lv, "kolistlistview", false ) |
1158 | { | 1158 | { |
1159 | mPopupTimer = new QTimer(this); | 1159 | mPopupTimer = new QTimer(this); |
1160 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1160 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1161 | #ifndef DESKTOP_VERSION | 1161 | #ifndef DESKTOP_VERSION |
1162 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1162 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1163 | #endif | 1163 | #endif |
1164 | setSelectionMode( QListView::Multi ); | 1164 | setSelectionMode( QListView::Multi ); |
1165 | setMultiSelection( true); | 1165 | setMultiSelection( true); |
1166 | } | 1166 | } |
1167 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1167 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1168 | { | 1168 | { |
1169 | if (!e) return; | 1169 | if (!e) return; |
1170 | QPoint vp = contentsToViewport(e->pos()); | 1170 | QPoint vp = contentsToViewport(e->pos()); |
1171 | QListViewItem *item = itemAt(vp); | 1171 | QListViewItem *item = itemAt(vp); |
1172 | if (!item) { | 1172 | if (!item) { |
1173 | emit newEvent(); | 1173 | emit newEvent(); |
1174 | return; | 1174 | return; |
1175 | } | 1175 | } |
1176 | KListView::contentsMouseDoubleClickEvent(e); | 1176 | KListView::contentsMouseDoubleClickEvent(e); |
1177 | } | 1177 | } |
1178 | #if 0 | 1178 | #if 0 |
1179 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1179 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1180 | { | 1180 | { |
1181 | //qDebug("contentsMousePressEvent++++ "); | 1181 | //qDebug("contentsMousePressEvent++++ "); |
1182 | KListView::contentsMousePressEvent( e ); | 1182 | KListView::contentsMousePressEvent( e ); |
1183 | if ( e->button() == RightButton ) { | 1183 | if ( e->button() == RightButton ) { |
1184 | QListViewItem* ci = currentItem(); | 1184 | QListViewItem* ci = currentItem(); |
1185 | clearSelection () ; | 1185 | clearSelection () ; |
1186 | if ( ci ) | 1186 | if ( ci ) |
1187 | ci->setSelected( true ); | 1187 | ci->setSelected( true ); |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1190 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1191 | { | 1191 | { |
1192 | KListView::contentsMouseReleaseEvent(e); | 1192 | KListView::contentsMouseReleaseEvent(e); |
1193 | } | 1193 | } |
1194 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1194 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1195 | { | 1195 | { |
1196 | KListView::contentsMouseMoveEvent(e); | 1196 | KListView::contentsMouseMoveEvent(e); |
1197 | } | 1197 | } |
1198 | #endif | 1198 | #endif |
1199 | void KOListViewListView::popupMenu() | 1199 | void KOListViewListView::popupMenu() |
1200 | { | 1200 | { |
1201 | mPopupTimer->stop(); | 1201 | mPopupTimer->stop(); |
1202 | //qDebug("HUUUUUUUUUUUUUUUUUUUU "); | 1202 | //qDebug("HUUUUUUUUUUUUUUUUUUUU "); |
1203 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1203 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1204 | QApplication::postEvent( this->viewport(), e ); | 1204 | QApplication::postEvent( this->viewport(), e ); |
1205 | } | 1205 | } |
1206 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1206 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1207 | { | 1207 | { |
1208 | //qDebug("contentsMousePressEvent++++ "); | 1208 | //qDebug("contentsMousePressEvent++++ "); |
1209 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1209 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1210 | if ( e->button() == LeftButton ) { | 1210 | if ( e->button() == LeftButton ) { |
1211 | mPopupTimer->start( 600 ); | 1211 | mPopupTimer->start( 600 ); |
1212 | mEventPos = e->pos(); | 1212 | mEventPos = e->pos(); |
1213 | mEventGlobalPos = e->globalPos(); | 1213 | mEventGlobalPos = e->globalPos(); |
1214 | } | 1214 | } |
1215 | KListView::contentsMousePressEvent( e ); | 1215 | KListView::contentsMousePressEvent( e ); |
1216 | if ( e->button() == RightButton ) { | 1216 | if ( e->button() == RightButton ) { |
1217 | QListViewItem* ci = currentItem(); | 1217 | QListViewItem* ci = currentItem(); |
1218 | clearSelection(); | 1218 | //clearSelection(); |
1219 | if ( ci ) | 1219 | if ( ci ) |
1220 | ci->setSelected( true ); | 1220 | ci->setSelected( true ); |
1221 | } | 1221 | } |
1222 | } | 1222 | } |
1223 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1223 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1224 | { | 1224 | { |
1225 | mPopupTimer->stop(); | 1225 | mPopupTimer->stop(); |
1226 | KListView::contentsMouseReleaseEvent(e); | 1226 | KListView::contentsMouseReleaseEvent(e); |
1227 | } | 1227 | } |
1228 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1228 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1229 | { | 1229 | { |
1230 | // qDebug("contentsMouseMoveEv....... "); | 1230 | // qDebug("contentsMouseMoveEv....... "); |
1231 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1231 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1232 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1232 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1233 | if ( diff < 0 ) diff = -diff; | 1233 | if ( diff < 0 ) diff = -diff; |
1234 | if ( diff > 15 ) | 1234 | if ( diff > 15 ) |
1235 | mPopupTimer->stop(); | 1235 | mPopupTimer->stop(); |
1236 | else { | 1236 | else { |
1237 | mEventPos = e->pos(); | 1237 | mEventPos = e->pos(); |
1238 | mEventGlobalPos = e->globalPos(); | 1238 | mEventGlobalPos = e->globalPos(); |
1239 | } | 1239 | } |
1240 | KListView::contentsMouseMoveEvent(e); | 1240 | KListView::contentsMouseMoveEvent(e); |
1241 | } | 1241 | } |
1242 | 1242 | ||
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 029f14b..ea3a329 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -1,1657 +1,1687 @@ | |||
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 >= 0x030000 | 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 | mMouseDown = false; | 83 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 84 | //setMaximumHeight( 5 ); // test only |
85 | } | 85 | } |
86 | 86 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 88 | { |
89 | return mSizeHint; | 89 | return mSizeHint; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 93 | { |
94 | orient = o; | 94 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 95 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 97 | setCursor( splitHCursor ); |
98 | else | 98 | else |
99 | setCursor( splitVCursor ); | 99 | setCursor( splitVCursor ); |
100 | #endif | 100 | #endif |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 105 | { |
106 | updateCursor( e->pos() ); | 106 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 107 | if ( !(e->state()&LeftButton) ) |
108 | return; | 108 | return; |
109 | 109 | ||
110 | if ( _activeButton != 0) | 110 | if ( _activeButton != 0) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 114 | - mouseOffset; |
115 | if ( opaque() ) { | 115 | if ( opaque() ) { |
116 | s->moveSplitter( pos, id() ); | 116 | s->moveSplitter( pos, id() ); |
117 | } else { | 117 | } else { |
118 | int min = pos; int max = pos; | 118 | int min = pos; int max = pos; |
119 | s->getRange( id(), &min, &max ); | 119 | s->getRange( id(), &min, &max ); |
120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
121 | } | 121 | } |
122 | _collapsed = false; | 122 | _collapsed = false; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
126 | { | 126 | { |
127 | if ( e->button() == LeftButton ) { | 127 | if ( e->button() == LeftButton ) { |
128 | _activeButton = onButton( e->pos() ); | 128 | _activeButton = onButton( e->pos() ); |
129 | mouseOffset = s->pick(e->pos()); | 129 | mouseOffset = s->pick(e->pos()); |
130 | mMouseDown = true; | 130 | mMouseDown = true; |
131 | repaint(); | 131 | repaint(); |
132 | updateCursor( e->pos() ); | 132 | updateCursor( e->pos() ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
137 | { | 137 | { |
138 | if ( onButton( p ) != 0 ) { | 138 | if ( onButton( p ) != 0 ) { |
139 | setCursor( arrowCursor ); | 139 | setCursor( arrowCursor ); |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
143 | setCursor( splitHCursor ); | 143 | setCursor( splitHCursor ); |
144 | else | 144 | else |
145 | setCursor( splitVCursor ); | 145 | setCursor( splitVCursor ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | void KDGanttSplitterHandle::toggle() | 148 | void KDGanttSplitterHandle::toggle() |
149 | { | 149 | { |
150 | int pos; | 150 | int pos; |
151 | int min, max; | 151 | int min, max; |
152 | if ( !_collapsed ) { | 152 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 153 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 156 | pos = min; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | pos = max; | 159 | pos = max; |
160 | } | 160 | } |
161 | 161 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 163 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 164 | _collapsed = true; |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | s->moveSplitter( _origPos, id() ); | 167 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 168 | _collapsed = false; |
169 | } | 169 | } |
170 | repaint(); | 170 | repaint(); |
171 | } | 171 | } |
172 | 172 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 174 | { |
175 | mMouseDown = false; | 175 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 176 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 177 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 178 | { |
179 | toggle(); | 179 | toggle(); |
180 | } | 180 | } |
181 | _activeButton = 0; | 181 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 182 | updateCursor( e->pos() ); |
183 | } | 183 | } |
184 | else { | 184 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 185 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 187 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 188 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 189 | s->moveSplitter( pos, id() ); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | if ( s->rubberBand() ) | ||
193 | s->rubberBand()->hide(); | ||
192 | repaint(); | 194 | repaint(); |
193 | } | 195 | } |
194 | 196 | ||
195 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
196 | { | 198 | { |
197 | QValueList<QPointArray> list = buttonRegions(); | 199 | QValueList<QPointArray> list = buttonRegions(); |
198 | int index = 1; | 200 | int index = 1; |
199 | int add = 12; | 201 | int add = 12; |
200 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
201 | QRect rect = (*it).boundingRect(); | 203 | QRect rect = (*it).boundingRect(); |
202 | rect.setLeft( rect.left()- add ); | 204 | rect.setLeft( rect.left()- add ); |
203 | rect.setRight( rect.right() + add); | 205 | rect.setRight( rect.right() + add); |
204 | rect.setTop( rect.top()- add ); | 206 | rect.setTop( rect.top()- add ); |
205 | rect.setBottom( rect.bottom() + add); | 207 | rect.setBottom( rect.bottom() + add); |
206 | if ( rect.contains( p ) ) { | 208 | if ( rect.contains( p ) ) { |
207 | return index; | 209 | return index; |
208 | } | 210 | } |
209 | index++; | 211 | index++; |
210 | } | 212 | } |
211 | return 0; | 213 | return 0; |
212 | } | 214 | } |
213 | 215 | ||
214 | 216 | ||
215 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
216 | { | 218 | { |
217 | QValueList<QPointArray> list; | 219 | QValueList<QPointArray> list; |
218 | 220 | ||
219 | int sw = 8; | 221 | int sw = 8; |
220 | int yyy = 1; | 222 | int yyy = 1; |
221 | int xxx = 1; | 223 | int xxx = 1; |
222 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
223 | for ( int i = 0; i < 2; i++ ) { | 225 | for ( int i = 0; i < 2; i++ ) { |
224 | QPointArray arr; | 226 | QPointArray arr; |
225 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
226 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
227 | int mid = height()/2 + voffset[i]; | 229 | int mid = height()/2 + voffset[i]; |
228 | arr.setPoints( 3, | 230 | arr.setPoints( 3, |
229 | 1-xxx, mid - sw + 4, | 231 | 1-xxx, mid - sw + 4, |
230 | sw-3-xxx, mid, | 232 | sw-3-xxx, mid, |
231 | 1-xxx, mid + sw -4); | 233 | 1-xxx, mid + sw -4); |
232 | } | 234 | } |
233 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
234 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
235 | int mid = height()/2 + voffset[i]; | 237 | int mid = height()/2 + voffset[i]; |
236 | arr.setPoints( 3, | 238 | arr.setPoints( 3, |
237 | sw-4, mid - sw + 4, | 239 | sw-4, mid - sw + 4, |
238 | 0, mid, | 240 | 0, mid, |
239 | sw-4, mid + sw - 4); | 241 | sw-4, mid + sw - 4); |
240 | } | 242 | } |
241 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
242 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { | 244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { |
243 | int mid = width()/2 + voffset[i]; | 245 | int mid = width()/2 + voffset[i]; |
244 | arr.setPoints( 3, | 246 | arr.setPoints( 3, |
245 | mid - sw + 4, sw-4, | 247 | mid - sw + 4, sw-4, |
246 | mid, 0, | 248 | mid, 0, |
247 | mid + sw - 4, sw-4 ); | 249 | mid + sw - 4, sw-4 ); |
248 | } | 250 | } |
249 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || | 251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || |
250 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
251 | int mid = width()/2 + voffset[i]; | 253 | int mid = width()/2 + voffset[i]; |
252 | arr.setPoints( 3, | 254 | arr.setPoints( 3, |
253 | mid - sw + 4, 1-yyy, | 255 | mid - sw + 4, 1-yyy, |
254 | mid, sw-3-yyy, | 256 | mid, sw-3-yyy, |
255 | mid + sw -4, 1-yyy); | 257 | mid + sw -4, 1-yyy); |
256 | } | 258 | } |
257 | list.append( arr ); | 259 | list.append( arr ); |
258 | } | 260 | } |
259 | return list; | 261 | return list; |
260 | } | 262 | } |
261 | 263 | ||
262 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | 264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) |
263 | { | 265 | { |
264 | QPixmap buffer( size() ); | 266 | QPixmap buffer( size() ); |
265 | QPainter p( &buffer ); | 267 | QPainter p( &buffer ); |
266 | 268 | ||
267 | //LR | 269 | //LR |
268 | // Draw the splitter rectangle | 270 | // Draw the splitter rectangle |
269 | p.setBrush( colorGroup().background() ); | 271 | p.setBrush( colorGroup().background() ); |
270 | p.setPen( colorGroup().foreground() ); | 272 | p.setPen( colorGroup().foreground() ); |
271 | //p.drawRect( rect() ); | 273 | //p.drawRect( rect() ); |
272 | buffer.fill( colorGroup().background() ); | 274 | buffer.fill( colorGroup().background() ); |
273 | //buffer.fill( backgroundColor() ); | 275 | //buffer.fill( backgroundColor() ); |
274 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 276 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
275 | 277 | ||
276 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 278 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
277 | 279 | ||
278 | // arrow color | 280 | // arrow color |
279 | QColor col; | 281 | QColor col; |
280 | if ( _activeButton ) | 282 | if ( _activeButton ) |
281 | col = colorGroup().background().dark( 250 ); | 283 | col = colorGroup().background().dark( 250 ); |
282 | else { | 284 | else { |
283 | if ( mMouseDown ) | 285 | if ( mMouseDown ) |
284 | col = Qt::white; | 286 | col = Qt::white; |
285 | else | 287 | else |
286 | col = colorGroup().background().dark( 150 ); | 288 | col = colorGroup().background().dark( 150 ); |
287 | } | 289 | } |
288 | //QColor col = backgroundColor().dark( 130 ); | 290 | //QColor col = backgroundColor().dark( 130 ); |
289 | p.setBrush( col ); | 291 | p.setBrush( col ); |
290 | p.setPen( col ); | 292 | p.setPen( col ); |
291 | 293 | ||
292 | QValueList<QPointArray> list = buttonRegions(); | 294 | QValueList<QPointArray> list = buttonRegions(); |
293 | int index = 1; | 295 | int index = 1; |
294 | if ( mUseOffset ) | 296 | if ( mUseOffset ) |
295 | p.translate( 0, 1 ); | 297 | p.translate( 0, 1 ); |
296 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 298 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
297 | if ( index == _activeButton ) { | 299 | if ( index == _activeButton ) { |
298 | 300 | ||
299 | /* | 301 | /* |
300 | if ( ! _collapsed ) { | 302 | if ( ! _collapsed ) { |
301 | p.save(); | 303 | p.save(); |
302 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 304 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
303 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 305 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
304 | p.translate( -1, 0 ); | 306 | p.translate( -1, 0 ); |
305 | p.drawPolygon( *it, true ); | 307 | p.drawPolygon( *it, true ); |
306 | p.restore(); } else | 308 | p.restore(); } else |
307 | */ | 309 | */ |
308 | p.drawPolygon( *it, true ); | 310 | p.drawPolygon( *it, true ); |
309 | 311 | ||
310 | } | 312 | } |
311 | else { | 313 | else { |
312 | /* | 314 | /* |
313 | if ( ! _collapsed ) { | 315 | if ( ! _collapsed ) { |
314 | p.save(); | 316 | p.save(); |
315 | p.translate( -1, 0 ); | 317 | p.translate( -1, 0 ); |
316 | p.drawPolygon( *it, true ); | 318 | p.drawPolygon( *it, true ); |
317 | p.restore(); | 319 | p.restore(); |
318 | } else | 320 | } else |
319 | */ | 321 | */ |
320 | p.drawPolygon( *it, true ); | 322 | p.drawPolygon( *it, true ); |
321 | 323 | ||
322 | } | 324 | } |
323 | index++; | 325 | index++; |
324 | } | 326 | } |
325 | 327 | ||
326 | // Draw the lines between the arrows | 328 | // Draw the lines between the arrows |
327 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 329 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
328 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 330 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
329 | int mid = height()/2; | 331 | int mid = height()/2; |
330 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 332 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
331 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 333 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
332 | } | 334 | } |
333 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 335 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
334 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 336 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
335 | int mid = width()/2; | 337 | int mid = width()/2; |
336 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 338 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
337 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 339 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
338 | } | 340 | } |
339 | bitBlt( this, 0, 0, &buffer ); | 341 | bitBlt( this, 0, 0, &buffer ); |
340 | 342 | ||
341 | } | 343 | } |
342 | #endif | 344 | #endif |
343 | 345 | ||
344 | class QSplitterLayoutStruct | 346 | class QSplitterLayoutStruct |
345 | { | 347 | { |
346 | public: | 348 | public: |
347 | KDGanttMinimizeSplitter::ResizeMode mode; | 349 | KDGanttMinimizeSplitter::ResizeMode mode; |
348 | QCOORD sizer; | 350 | QCOORD sizer; |
349 | bool isSplitter; | 351 | bool isSplitter; |
350 | QWidget *wid; | 352 | QWidget *wid; |
351 | }; | 353 | }; |
352 | 354 | ||
353 | class QSplitterData | 355 | class QSplitterData |
354 | { | 356 | { |
355 | public: | 357 | public: |
356 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 358 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
357 | 359 | ||
358 | QPtrList<QSplitterLayoutStruct> list; | 360 | QPtrList<QSplitterLayoutStruct> list; |
359 | bool opaque; | 361 | bool opaque; |
360 | bool firstShow; | 362 | bool firstShow; |
361 | }; | 363 | }; |
362 | 364 | ||
363 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 365 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
364 | int space, int spacer ); | 366 | int space, int spacer ); |
365 | #endif // DOXYGEN_SKIP_INTERNAL | 367 | #endif // DOXYGEN_SKIP_INTERNAL |
366 | 368 | ||
367 | 369 | ||
368 | /*! | 370 | /*! |
369 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 371 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
370 | \brief The KDGanttMinimizeSplitter class implements a splitter | 372 | \brief The KDGanttMinimizeSplitter class implements a splitter |
371 | widget with minimize buttons. | 373 | widget with minimize buttons. |
372 | 374 | ||
373 | This class (and its documentation) is largely a copy of Qt's | 375 | This class (and its documentation) is largely a copy of Qt's |
374 | QSplitter; the copying was necessary because QSplitter is not | 376 | QSplitter; the copying was necessary because QSplitter is not |
375 | extensible at all. QSplitter and its documentation are licensed | 377 | extensible at all. QSplitter and its documentation are licensed |
376 | according to the GPL and the Qt Professional License (if you hold | 378 | according to the GPL and the Qt Professional License (if you hold |
377 | such a license) and are (C) Trolltech AS. | 379 | such a license) and are (C) Trolltech AS. |
378 | 380 | ||
379 | A splitter lets the user control the size of child widgets by | 381 | A splitter lets the user control the size of child widgets by |
380 | dragging the boundary between the children. Any number of widgets | 382 | dragging the boundary between the children. Any number of widgets |
381 | may be controlled. | 383 | may be controlled. |
382 | 384 | ||
383 | To show a QListBox, a QListView and a QTextEdit side by side: | 385 | To show a QListBox, a QListView and a QTextEdit side by side: |
384 | 386 | ||
385 | \code | 387 | \code |
386 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 388 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
387 | QListBox *lb = new QListBox( split ); | 389 | QListBox *lb = new QListBox( split ); |
388 | QListView *lv = new QListView( split ); | 390 | QListView *lv = new QListView( split ); |
389 | QTextEdit *ed = new QTextEdit( split ); | 391 | QTextEdit *ed = new QTextEdit( split ); |
390 | \endcode | 392 | \endcode |
391 | 393 | ||
392 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 394 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
393 | vertical. The default is horizontal (the children are side by side) | 395 | vertical. The default is horizontal (the children are side by side) |
394 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 396 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
395 | vertical. | 397 | vertical. |
396 | 398 | ||
397 | Use setResizeMode() to specify | 399 | Use setResizeMode() to specify |
398 | that a widget should keep its size when the splitter is resized. | 400 | that a widget should keep its size when the splitter is resized. |
399 | 401 | ||
400 | Although KDGanttMinimizeSplitter normally resizes the children only | 402 | Although KDGanttMinimizeSplitter normally resizes the children only |
401 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 403 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
402 | ) the widgets are resized as often as possible. | 404 | ) the widgets are resized as often as possible. |
403 | 405 | ||
404 | The initial distribution of size between the widgets is determined | 406 | The initial distribution of size between the widgets is determined |
405 | by the initial size of each widget. You can also use setSizes() to | 407 | by the initial size of each widget. You can also use setSizes() to |
406 | set the sizes of all the widgets. The function sizes() returns the | 408 | set the sizes of all the widgets. The function sizes() returns the |
407 | sizes set by the user. | 409 | sizes set by the user. |
408 | 410 | ||
409 | If you hide() a child, its space will be distributed among the other | 411 | If you hide() a child, its space will be distributed among the other |
410 | children. It will be reinstated when you show() it again. It is also | 412 | children. It will be reinstated when you show() it again. It is also |
411 | possible to reorder the widgets within the splitter using | 413 | possible to reorder the widgets within the splitter using |
412 | moveToFirst() and moveToLast(). | 414 | moveToFirst() and moveToLast(). |
413 | */ | 415 | */ |
414 | 416 | ||
415 | 417 | ||
416 | 418 | ||
417 | static QSize minSize( const QWidget* /*w*/ ) | 419 | static QSize minSize( const QWidget* /*w*/ ) |
418 | { | 420 | { |
419 | return QSize(0,0); | 421 | return QSize(0,0); |
420 | } | 422 | } |
421 | 423 | ||
422 | // This is the original version of minSize | 424 | // This is the original version of minSize |
423 | static QSize minSizeHint( const QWidget* w ) | 425 | static QSize minSizeHint( const QWidget* w ) |
424 | { | 426 | { |
425 | QSize min = w->minimumSize(); | 427 | QSize min = w->minimumSize(); |
426 | QSize s; | 428 | QSize s; |
427 | if ( min.height() <= 0 || min.width() <= 0 ) | 429 | if ( min.height() <= 0 || min.width() <= 0 ) |
428 | s = w->minimumSizeHint(); | 430 | s = w->minimumSizeHint(); |
429 | if ( min.height() > 0 ) | 431 | if ( min.height() > 0 ) |
430 | s.setHeight( min.height() ); | 432 | s.setHeight( min.height() ); |
431 | if ( min.width() > 0 ) | 433 | if ( min.width() > 0 ) |
432 | s.setWidth( min.width() ); | 434 | s.setWidth( min.width() ); |
433 | return s.expandedTo(QSize(0,0)); | 435 | return s.expandedTo(QSize(0,0)); |
434 | } | 436 | } |
435 | 437 | ||
436 | 438 | ||
437 | |||
438 | /*! | 439 | /*! |
439 | Constructs a horizontal splitter with the \a parent and \a | 440 | Constructs a horizontal splitter with the \a parent and \a |
440 | name arguments being passed on to the QFrame constructor. | 441 | name arguments being passed on to the QFrame constructor. |
441 | */ | 442 | */ |
442 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 443 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
443 | :QFrame(parent,name,WPaintUnclipped) | 444 | :QFrame(parent,name,WPaintUnclipped) |
444 | { | 445 | { |
446 | mRubberBand = 0; | ||
445 | mFirstHandle = 0; | 447 | mFirstHandle = 0; |
446 | #if QT_VERSION >= 232 | 448 | #if QT_VERSION >= 232 |
447 | orient = Horizontal; | 449 | orient = Horizontal; |
448 | init(); | 450 | init(); |
449 | #endif | 451 | #endif |
450 | } | 452 | } |
451 | 453 | ||
452 | /*! | 454 | /*! |
453 | Constructs a splitter with orientation \a o with the \a parent | 455 | Constructs a splitter with orientation \a o with the \a parent |
454 | and \a name arguments being passed on to the QFrame constructor. | 456 | and \a name arguments being passed on to the QFrame constructor. |
455 | */ | 457 | */ |
456 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 458 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) |
457 | :QFrame(parent,name,WPaintUnclipped) | 459 | :QFrame(parent,name,WPaintUnclipped) |
458 | { | 460 | { |
461 | |||
462 | mRubberBand = 0; | ||
459 | mFirstHandle = 0; | 463 | mFirstHandle = 0; |
460 | #if QT_VERSION >= 232 | 464 | #if QT_VERSION >= 232 |
461 | orient = o; | 465 | orient = o; |
462 | init(); | 466 | init(); |
463 | #endif | 467 | #endif |
464 | } | 468 | } |
465 | 469 | ||
466 | /*! | 470 | /*! |
467 | Destroys the splitter and any children. | 471 | Destroys the splitter and any children. |
468 | */ | 472 | */ |
469 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 473 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() |
470 | { | 474 | { |
471 | #if QT_VERSION >= 232 | 475 | #if QT_VERSION >= 232 |
472 | data->list.setAutoDelete( TRUE ); | 476 | data->list.setAutoDelete( TRUE ); |
473 | delete data; | 477 | delete data; |
474 | #endif | 478 | #endif |
479 | if ( mRubberBand ) | ||
480 | delete mRubberBand; | ||
475 | } | 481 | } |
476 | 482 | ||
477 | 483 | ||
478 | #if QT_VERSION >= 232 | 484 | #if QT_VERSION >= 232 |
479 | void KDGanttMinimizeSplitter::init() | 485 | void KDGanttMinimizeSplitter::init() |
480 | { | 486 | { |
481 | data = new QSplitterData; | 487 | data = new QSplitterData; |
482 | if ( orient == Horizontal ) | 488 | if ( orient == Horizontal ) |
483 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); | 489 | setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); |
484 | else | 490 | else |
485 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); | 491 | setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); |
486 | #ifndef DESKTOP_VERSION | 492 | #ifndef DESKTOP_VERSION |
487 | setOpaqueResize( false ); | 493 | setOpaqueResize( false ); |
488 | #else | 494 | #else |
489 | setOpaqueResize( true ); | 495 | setOpaqueResize( true ); |
490 | #endif | 496 | #endif |
491 | } | 497 | } |
492 | #endif | 498 | #endif |
493 | 499 | ||
494 | 500 | ||
495 | void KDGanttMinimizeSplitter::toggle() | 501 | void KDGanttMinimizeSplitter::toggle() |
496 | { | 502 | { |
497 | if ( mFirstHandle ) | 503 | if ( mFirstHandle ) |
498 | mFirstHandle->toggle(); | 504 | mFirstHandle->toggle(); |
499 | else | 505 | else |
500 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); | 506 | qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); |
501 | 507 | ||
502 | } | 508 | } |
503 | 509 | ||
504 | 510 | ||
505 | /*! | 511 | /*! |
506 | \brief the orientation of the splitter | 512 | \brief the orientation of the splitter |
507 | 513 | ||
508 | By default the orientation is horizontal (the widgets are side by side). | 514 | By default the orientation is horizontal (the widgets are side by side). |
509 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). | 515 | The possible orientations are Qt:Vertical and Qt::Horizontal (the default). |
510 | */ | 516 | */ |
511 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 517 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) |
512 | { | 518 | { |
513 | #if QT_VERSION >= 232 | 519 | #if QT_VERSION >= 232 |
514 | if ( orient == o ) | 520 | if ( orient == o ) |
515 | return; | 521 | return; |
516 | orient = o; | 522 | orient = o; |
517 | 523 | ||
518 | if ( orient == Horizontal ) | 524 | if ( orient == Horizontal ) |
519 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 525 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
520 | else | 526 | else |
521 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 527 | setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
522 | 528 | ||
523 | QSplitterLayoutStruct *s = data->list.first(); | 529 | QSplitterLayoutStruct *s = data->list.first(); |
524 | while ( s ) { | 530 | while ( s ) { |
525 | if ( s->isSplitter ) | 531 | if ( s->isSplitter ) |
526 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); | 532 | ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); |
527 | s = data->list.next(); // ### next at end of loop, no iterator | 533 | s = data->list.next(); // ### next at end of loop, no iterator |
528 | } | 534 | } |
529 | recalc( isVisible() ); | 535 | recalc( isVisible() ); |
530 | #endif | 536 | #endif |
531 | } | 537 | } |
532 | 538 | ||
533 | 539 | ||
534 | #if QT_VERSION >= 232 | 540 | #if QT_VERSION >= 232 |
535 | /*! | 541 | /*! |
536 | \reimp | 542 | \reimp |
537 | */ | 543 | */ |
538 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 544 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) |
539 | { | 545 | { |
540 | doResize(); | 546 | doResize(); |
541 | } | 547 | } |
542 | 548 | ||
543 | 549 | ||
544 | /* | 550 | /* |
545 | Inserts the widget \a w at the end (or at the beginning if \a first | 551 | Inserts the widget \a w at the end (or at the beginning if \a first |
546 | is TRUE) of the splitter's list of widgets. | 552 | is TRUE) of the splitter's list of widgets. |
547 | 553 | ||
548 | It is the responsibility of the caller of this function to make sure | 554 | It is the responsibility of the caller of this function to make sure |
549 | that \a w is not already in the splitter and to call recalcId if | 555 | that \a w is not already in the splitter and to call recalcId if |
550 | needed. (If \a first is TRUE, then recalcId is very probably | 556 | needed. (If \a first is TRUE, then recalcId is very probably |
551 | needed.) | 557 | needed.) |
552 | */ | 558 | */ |
553 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 559 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) |
554 | { | 560 | { |
555 | QSplitterLayoutStruct *s; | 561 | QSplitterLayoutStruct *s; |
556 | KDGanttSplitterHandle *newHandle = 0; | 562 | KDGanttSplitterHandle *newHandle = 0; |
557 | if ( data->list.count() > 0 ) { | 563 | if ( data->list.count() > 0 ) { |
558 | s = new QSplitterLayoutStruct; | 564 | s = new QSplitterLayoutStruct; |
559 | s->mode = KeepSize; | 565 | s->mode = KeepSize; |
560 | QString tmp = "qt_splithandle_"; | 566 | QString tmp = "qt_splithandle_"; |
561 | tmp += w->name(); | 567 | tmp += w->name(); |
562 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); | 568 | newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); |
563 | if ( ! mFirstHandle ) | 569 | if ( ! mFirstHandle ) |
564 | mFirstHandle = newHandle; | 570 | mFirstHandle = newHandle; |
565 | s->wid = newHandle; | 571 | s->wid = newHandle; |
566 | newHandle->setId(data->list.count()); | 572 | newHandle->setId(data->list.count()); |
567 | s->isSplitter = TRUE; | 573 | s->isSplitter = TRUE; |
568 | s->sizer = pick( newHandle->sizeHint() ); | 574 | s->sizer = pick( newHandle->sizeHint() ); |
569 | if ( first ) | 575 | if ( first ) |
570 | data->list.insert( 0, s ); | 576 | data->list.insert( 0, s ); |
571 | else | 577 | else |
572 | data->list.append( s ); | 578 | data->list.append( s ); |
573 | } | 579 | } |
574 | s = new QSplitterLayoutStruct; | 580 | s = new QSplitterLayoutStruct; |
575 | s->mode = Stretch; | 581 | s->mode = Stretch; |
576 | s->wid = w; | 582 | s->wid = w; |
577 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) | 583 | if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) |
578 | s->sizer = pick( w->sizeHint() ); | 584 | s->sizer = pick( w->sizeHint() ); |
579 | else | 585 | else |
580 | s->sizer = pick( w->size() ); | 586 | s->sizer = pick( w->size() ); |
581 | s->isSplitter = FALSE; | 587 | s->isSplitter = FALSE; |
582 | if ( first ) | 588 | if ( first ) |
583 | data->list.insert( 0, s ); | 589 | data->list.insert( 0, s ); |
584 | else | 590 | else |
585 | data->list.append( s ); | 591 | data->list.append( s ); |
586 | if ( newHandle && isVisible() ) | 592 | if ( newHandle && isVisible() ) |
587 | newHandle->show(); //will trigger sending of post events | 593 | newHandle->show(); //will trigger sending of post events |
588 | return s; | 594 | return s; |
589 | } | 595 | } |
590 | 596 | ||
591 | 597 | ||
592 | /*! | 598 | /*! |
593 | Tells the splitter that a child widget has been inserted or removed. | 599 | Tells the splitter that a child widget has been inserted or removed. |
594 | The event is passed in \a c. | 600 | The event is passed in \a c. |
595 | */ | 601 | */ |
596 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 602 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
597 | { | 603 | { |
598 | if ( c->type() == QEvent::ChildInserted ) { | 604 | if ( c->type() == QEvent::ChildInserted ) { |
599 | if ( !c->child()->isWidgetType() ) | 605 | if ( !c->child()->isWidgetType() ) |
600 | return; | 606 | return; |
601 | 607 | ||
602 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 608 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
603 | return; | 609 | return; |
604 | 610 | ||
605 | QSplitterLayoutStruct *s = data->list.first(); | 611 | QSplitterLayoutStruct *s = data->list.first(); |
606 | while ( s ) { | 612 | while ( s ) { |
607 | if ( s->wid == c->child() ) | 613 | if ( s->wid == c->child() ) |
608 | return; | 614 | return; |
609 | s = data->list.next(); | 615 | s = data->list.next(); |
610 | } | 616 | } |
611 | addWidget( (QWidget*)c->child() ); | 617 | addWidget( (QWidget*)c->child() ); |
612 | recalc( isVisible() ); | 618 | recalc( isVisible() ); |
613 | 619 | ||
614 | } else if ( c->type() == QEvent::ChildRemoved ) { | 620 | } else if ( c->type() == QEvent::ChildRemoved ) { |
615 | QSplitterLayoutStruct *p = 0; | 621 | QSplitterLayoutStruct *p = 0; |
616 | if ( data->list.count() > 1 ) | 622 | if ( data->list.count() > 1 ) |
617 | p = data->list.at(1); //remove handle _after_ first widget. | 623 | p = data->list.at(1); //remove handle _after_ first widget. |
618 | QSplitterLayoutStruct *s = data->list.first(); | 624 | QSplitterLayoutStruct *s = data->list.first(); |
619 | while ( s ) { | 625 | while ( s ) { |
620 | if ( s->wid == c->child() ) { | 626 | if ( s->wid == c->child() ) { |
621 | data->list.removeRef( s ); | 627 | data->list.removeRef( s ); |
622 | delete s; | 628 | delete s; |
623 | if ( p && p->isSplitter ) { | 629 | if ( p && p->isSplitter ) { |
624 | data->list.removeRef( p ); | 630 | data->list.removeRef( p ); |
625 | delete p->wid; //will call childEvent | 631 | delete p->wid; //will call childEvent |
626 | delete p; | 632 | delete p; |
627 | } | 633 | } |
628 | recalcId(); | 634 | recalcId(); |
629 | doResize(); | 635 | doResize(); |
630 | return; | 636 | return; |
631 | } | 637 | } |
632 | p = s; | 638 | p = s; |
633 | s = data->list.next(); | 639 | s = data->list.next(); |
634 | } | 640 | } |
635 | } | 641 | } |
636 | } | 642 | } |
637 | 643 | ||
638 | 644 | ||
639 | /*! | 645 | /*! |
640 | Shows a rubber band at position \a p. If \a p is negative, the | 646 | Shows a rubber band at position \a p. If \a p is negative, the |
641 | rubber band is removed. | 647 | rubber band is removed. |
642 | */ | 648 | */ |
643 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 649 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
644 | { | 650 | { |
651 | #ifdef DESKTOP_VERSION | ||
645 | QPainter paint( this ); | 652 | QPainter paint( this ); |
646 | paint.setPen( gray ); | 653 | paint.setPen( gray ); |
647 | paint.setBrush( gray ); | 654 | paint.setBrush( gray ); |
648 | paint.setRasterOp( XorROP ); | 655 | paint.setRasterOp( XorROP ); |
649 | QRect r = contentsRect(); | 656 | QRect r = contentsRect(); |
650 | const int rBord = 3; //Themable???? | 657 | const int rBord = 3; //Themable???? |
651 | #if QT_VERSION >= 0x030000 | 658 | #if QT_VERSION >= 0x030000 |
652 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 659 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
653 | #else | 660 | #else |
654 | int sw = style().splitterWidth(); | 661 | int sw = style().splitterWidth(); |
655 | #endif | 662 | #endif |
656 | if ( orient == Horizontal ) { | 663 | if ( orient == Horizontal ) { |
657 | if ( opaqueOldPos >= 0 ) | 664 | if ( opaqueOldPos >= 0 ) |
658 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 665 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
659 | 2*rBord, r.height() ); | 666 | 2*rBord, r.height() ); |
660 | if ( p >= 0 ) | 667 | if ( p >= 0 ) |
661 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 668 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
662 | } else { | 669 | } else { |
663 | if ( opaqueOldPos >= 0 ) | 670 | if ( opaqueOldPos >= 0 ) |
664 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 671 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
665 | r.width(), 2*rBord ); | 672 | r.width(), 2*rBord ); |
666 | if ( p >= 0 ) | 673 | if ( p >= 0 ) |
667 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 674 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
668 | } | 675 | } |
669 | opaqueOldPos = p; | 676 | opaqueOldPos = p; |
677 | #else | ||
678 | if ( !mRubberBand ) { | ||
679 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | ||
680 | mRubberBand->setFrameStyle( Box | Raised ); | ||
681 | mRubberBand->setPalette( QPalette ( Qt::green.light(),Qt::green.dark() ) ); | ||
682 | } | ||
683 | QRect r = contentsRect(); | ||
684 | const int rBord = 5; //Themable???? | ||
685 | int sw = style().splitterWidth(); | ||
686 | if ( orient == Horizontal ) { | ||
687 | if ( p >= 0 ) { | ||
688 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | ||
689 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | ||
690 | } | ||
691 | } else { | ||
692 | if ( p >= 0 ) { | ||
693 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | ||
694 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | ||
695 | } | ||
696 | } | ||
697 | opaqueOldPos = p; | ||
698 | mRubberBand->show(); | ||
699 | #endif | ||
670 | } | 700 | } |
671 | 701 | ||
672 | 702 | ||
673 | /*! \reimp */ | 703 | /*! \reimp */ |
674 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 704 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
675 | { | 705 | { |
676 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 706 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
677 | recalc( isVisible() ); | 707 | recalc( isVisible() ); |
678 | if ( e->type() == QEvent::Show ) | 708 | if ( e->type() == QEvent::Show ) |
679 | data->firstShow = FALSE; | 709 | data->firstShow = FALSE; |
680 | } | 710 | } |
681 | return QWidget::event( e ); | 711 | return QWidget::event( e ); |
682 | } | 712 | } |
683 | 713 | ||
684 | 714 | ||
685 | /*! | 715 | /*! |
686 | \obsolete | 716 | \obsolete |
687 | 717 | ||
688 | Draws the splitter handle in the rectangle described by \a x, \a y, | 718 | Draws the splitter handle in the rectangle described by \a x, \a y, |
689 | \a w, \a h using painter \a p. | 719 | \a w, \a h using painter \a p. |
690 | \sa QStyle::drawPrimitive() | 720 | \sa QStyle::drawPrimitive() |
691 | */ | 721 | */ |
692 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, | 722 | void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, |
693 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) | 723 | QCOORD x, QCOORD y, QCOORD w, QCOORD h ) |
694 | { | 724 | { |
695 | #if 0 | 725 | #if 0 |
696 | // LR | 726 | // LR |
697 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), | 727 | style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), |
698 | (orientation() == Qt::Horizontal ? | 728 | (orientation() == Qt::Horizontal ? |
699 | QStyle::Style_Horizontal : 0)); | 729 | QStyle::Style_Horizontal : 0)); |
700 | #endif | 730 | #endif |
701 | } | 731 | } |
702 | 732 | ||
703 | 733 | ||
704 | /*! | 734 | /*! |
705 | Returns the id of the splitter to the right of or below the widget \a w, | 735 | Returns the id of the splitter to the right of or below the widget \a w, |
706 | or 0 if there is no such splitter | 736 | or 0 if there is no such splitter |
707 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). | 737 | (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). |
708 | */ | 738 | */ |
709 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const | 739 | int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const |
710 | { | 740 | { |
711 | QSplitterLayoutStruct *s = data->list.first(); | 741 | QSplitterLayoutStruct *s = data->list.first(); |
712 | bool seen_w = FALSE; | 742 | bool seen_w = FALSE; |
713 | while ( s ) { | 743 | while ( s ) { |
714 | if ( s->isSplitter && seen_w ) | 744 | if ( s->isSplitter && seen_w ) |
715 | return data->list.at(); | 745 | return data->list.at(); |
716 | if ( !s->isSplitter && s->wid == w ) | 746 | if ( !s->isSplitter && s->wid == w ) |
717 | seen_w = TRUE; | 747 | seen_w = TRUE; |
718 | s = data->list.next(); | 748 | s = data->list.next(); |
719 | } | 749 | } |
720 | return 0; | 750 | return 0; |
721 | } | 751 | } |
722 | 752 | ||
723 | 753 | ||
724 | /*! | 754 | /*! |
725 | Moves the left/top edge of the splitter handle with id \a id as | 755 | Moves the left/top edge of the splitter handle with id \a id as |
726 | close as possible to position \a p, which is the distance from the | 756 | close as possible to position \a p, which is the distance from the |
727 | left (or top) edge of the widget. | 757 | left (or top) edge of the widget. |
728 | 758 | ||
729 | For Arabic and Hebrew the layout is reversed, and using this | 759 | For Arabic and Hebrew the layout is reversed, and using this |
730 | function to set the position of the splitter might lead to | 760 | function to set the position of the splitter might lead to |
731 | unexpected results, since in Arabic and Hebrew the position of | 761 | unexpected results, since in Arabic and Hebrew the position of |
732 | splitter one is to the left of the position of splitter zero. | 762 | splitter one is to the left of the position of splitter zero. |
733 | 763 | ||
734 | \sa idAfter() | 764 | \sa idAfter() |
735 | */ | 765 | */ |
736 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) | 766 | void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) |
737 | { | 767 | { |
738 | p = adjustPos( p, id ); | 768 | p = adjustPos( p, id ); |
739 | QSplitterLayoutStruct *s = data->list.at(id); | 769 | QSplitterLayoutStruct *s = data->list.at(id); |
740 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); | 770 | int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); |
741 | bool upLeft; | 771 | bool upLeft; |
742 | if ( false && orient == Horizontal ) { | 772 | if ( false && orient == Horizontal ) { |
743 | p += s->wid->width(); | 773 | p += s->wid->width(); |
744 | upLeft = p > oldP; | 774 | upLeft = p > oldP; |
745 | } else | 775 | } else |
746 | upLeft = p < oldP; | 776 | upLeft = p < oldP; |
747 | 777 | ||
748 | moveAfter( p, id, upLeft ); | 778 | moveAfter( p, id, upLeft ); |
749 | moveBefore( p-1, id-1, upLeft ); | 779 | moveBefore( p-1, id-1, upLeft ); |
750 | 780 | ||
751 | storeSizes(); | 781 | storeSizes(); |
752 | } | 782 | } |
753 | 783 | ||
754 | 784 | ||
755 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) | 785 | void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) |
756 | { | 786 | { |
757 | if ( orient == Horizontal ) { | 787 | if ( orient == Horizontal ) { |
758 | if ( false && orient == Horizontal && !isSplitter ) | 788 | if ( false && orient == Horizontal && !isSplitter ) |
759 | p = contentsRect().width() - p - s; | 789 | p = contentsRect().width() - p - s; |
760 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); | 790 | w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); |
761 | } else | 791 | } else |
762 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); | 792 | w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); |
763 | } | 793 | } |
764 | 794 | ||
765 | 795 | ||
766 | /* | 796 | /* |
767 | Places the right/bottom edge of the widget at \a id at position \a pos. | 797 | Places the right/bottom edge of the widget at \a id at position \a pos. |
768 | 798 | ||
769 | \sa idAfter() | 799 | \sa idAfter() |
770 | */ | 800 | */ |
771 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) | 801 | void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) |
772 | { | 802 | { |
773 | if( id < 0 ) | 803 | if( id < 0 ) |
774 | return; | 804 | return; |
775 | QSplitterLayoutStruct *s = data->list.at(id); | 805 | QSplitterLayoutStruct *s = data->list.at(id); |
776 | if ( !s ) | 806 | if ( !s ) |
777 | return; | 807 | return; |
778 | QWidget *w = s->wid; | 808 | QWidget *w = s->wid; |
779 | if ( w->isHidden() ) { | 809 | if ( w->isHidden() ) { |
780 | moveBefore( pos, id-1, upLeft ); | 810 | moveBefore( pos, id-1, upLeft ); |
781 | } else if ( s->isSplitter ) { | 811 | } else if ( s->isSplitter ) { |
782 | int pos1, pos2; | 812 | int pos1, pos2; |
783 | int dd = s->sizer; | 813 | int dd = s->sizer; |
784 | if( false && orient == Horizontal ) { | 814 | if( false && orient == Horizontal ) { |
785 | pos1 = pos; | 815 | pos1 = pos; |
786 | pos2 = pos + dd; | 816 | pos2 = pos + dd; |
787 | } else { | 817 | } else { |
788 | pos2 = pos - dd; | 818 | pos2 = pos - dd; |
789 | pos1 = pos2 + 1; | 819 | pos1 = pos2 + 1; |
790 | } | 820 | } |
791 | if ( upLeft ) { | 821 | if ( upLeft ) { |
792 | setG( w, pos1, dd, TRUE ); | 822 | setG( w, pos1, dd, TRUE ); |
793 | moveBefore( pos2, id-1, upLeft ); | 823 | moveBefore( pos2, id-1, upLeft ); |
794 | } else { | 824 | } else { |
795 | moveBefore( pos2, id-1, upLeft ); | 825 | moveBefore( pos2, id-1, upLeft ); |
796 | setG( w, pos1, dd, TRUE ); | 826 | setG( w, pos1, dd, TRUE ); |
797 | } | 827 | } |
798 | } else { | 828 | } else { |
799 | int dd, newLeft, nextPos; | 829 | int dd, newLeft, nextPos; |
800 | if( false && orient == Horizontal ) { | 830 | if( false && orient == Horizontal ) { |
801 | dd = w->geometry().right() - pos; | 831 | dd = w->geometry().right() - pos; |
802 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 832 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
803 | newLeft = pos+1; | 833 | newLeft = pos+1; |
804 | nextPos = newLeft + dd; | 834 | nextPos = newLeft + dd; |
805 | } else { | 835 | } else { |
806 | dd = pos - pick( w->pos() ) + 1; | 836 | dd = pos - pick( w->pos() ) + 1; |
807 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 837 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
808 | newLeft = pos-dd+1; | 838 | newLeft = pos-dd+1; |
809 | nextPos = newLeft - 1; | 839 | nextPos = newLeft - 1; |
810 | } | 840 | } |
811 | setG( w, newLeft, dd, TRUE ); | 841 | setG( w, newLeft, dd, TRUE ); |
812 | moveBefore( nextPos, id-1, upLeft ); | 842 | moveBefore( nextPos, id-1, upLeft ); |
813 | } | 843 | } |
814 | } | 844 | } |
815 | 845 | ||
816 | 846 | ||
817 | /* | 847 | /* |
818 | Places the left/top edge of the widget at \a id at position \a pos. | 848 | Places the left/top edge of the widget at \a id at position \a pos. |
819 | 849 | ||
820 | \sa idAfter() | 850 | \sa idAfter() |
821 | */ | 851 | */ |
822 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) | 852 | void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) |
823 | { | 853 | { |
824 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? | 854 | QSplitterLayoutStruct *s = id < int(data->list.count()) ? |
825 | data->list.at(id) : 0; | 855 | data->list.at(id) : 0; |
826 | if ( !s ) | 856 | if ( !s ) |
827 | return; | 857 | return; |
828 | QWidget *w = s->wid; | 858 | QWidget *w = s->wid; |
829 | if ( w->isHidden() ) { | 859 | if ( w->isHidden() ) { |
830 | moveAfter( pos, id+1, upLeft ); | 860 | moveAfter( pos, id+1, upLeft ); |
831 | } else if ( pick( w->pos() ) == pos ) { | 861 | } else if ( pick( w->pos() ) == pos ) { |
832 | //No need to do anything if it's already there. | 862 | //No need to do anything if it's already there. |
833 | return; | 863 | return; |
834 | } else if ( s->isSplitter ) { | 864 | } else if ( s->isSplitter ) { |
835 | int dd = s->sizer; | 865 | int dd = s->sizer; |
836 | int pos1, pos2; | 866 | int pos1, pos2; |
837 | if( false && orient == Horizontal ) { | 867 | if( false && orient == Horizontal ) { |
838 | pos2 = pos - dd; | 868 | pos2 = pos - dd; |
839 | pos1 = pos2 + 1; | 869 | pos1 = pos2 + 1; |
840 | } else { | 870 | } else { |
841 | pos1 = pos; | 871 | pos1 = pos; |
842 | pos2 = pos + dd; | 872 | pos2 = pos + dd; |
843 | } | 873 | } |
844 | if ( upLeft ) { | 874 | if ( upLeft ) { |
845 | setG( w, pos1, dd, TRUE ); | 875 | setG( w, pos1, dd, TRUE ); |
846 | moveAfter( pos2, id+1, upLeft ); | 876 | moveAfter( pos2, id+1, upLeft ); |
847 | } else { | 877 | } else { |
848 | moveAfter( pos2, id+1, upLeft ); | 878 | moveAfter( pos2, id+1, upLeft ); |
849 | setG( w, pos1, dd, TRUE ); | 879 | setG( w, pos1, dd, TRUE ); |
850 | } | 880 | } |
851 | } else { | 881 | } else { |
852 | int left = pick( w->pos() ); | 882 | int left = pick( w->pos() ); |
853 | int right, dd,/* newRight,*/ newLeft, nextPos; | 883 | int right, dd,/* newRight,*/ newLeft, nextPos; |
854 | if ( false && orient == Horizontal ) { | 884 | if ( false && orient == Horizontal ) { |
855 | dd = pos - left + 1; | 885 | dd = pos - left + 1; |
856 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 886 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
857 | newLeft = pos-dd+1; | 887 | newLeft = pos-dd+1; |
858 | nextPos = newLeft - 1; | 888 | nextPos = newLeft - 1; |
859 | } else { | 889 | } else { |
860 | right = pick( w->geometry().bottomRight() ); | 890 | right = pick( w->geometry().bottomRight() ); |
861 | dd = right - pos + 1; | 891 | dd = right - pos + 1; |
862 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); | 892 | dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); |
863 | /*newRight = pos+dd-1;*/ | 893 | /*newRight = pos+dd-1;*/ |
864 | newLeft = pos; | 894 | newLeft = pos; |
865 | nextPos = newLeft + dd; | 895 | nextPos = newLeft + dd; |
866 | } | 896 | } |
867 | setG( w, newLeft, dd, TRUE ); | 897 | setG( w, newLeft, dd, TRUE ); |
868 | /*if( right != newRight )*/ | 898 | /*if( right != newRight )*/ |
869 | moveAfter( nextPos, id+1, upLeft ); | 899 | moveAfter( nextPos, id+1, upLeft ); |
870 | } | 900 | } |
871 | } | 901 | } |
872 | 902 | ||
873 | 903 | ||
874 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) | 904 | void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) |
875 | { | 905 | { |
876 | QSplitterLayoutStruct *s = data->list.at(id-1); | 906 | QSplitterLayoutStruct *s = data->list.at(id-1); |
877 | QWidget* w = s->wid; | 907 | QWidget* w = s->wid; |
878 | *min = pick( w->mapToParent( QPoint(0,0) ) ); | 908 | *min = pick( w->mapToParent( QPoint(0,0) ) ); |
879 | 909 | ||
880 | if ( (uint) id == data->list.count() ) { | 910 | if ( (uint) id == data->list.count() ) { |
881 | pick( size() ); | 911 | pick( size() ); |
882 | } | 912 | } |
883 | else { | 913 | else { |
884 | QSplitterLayoutStruct *s = data->list.at(id+1); | 914 | QSplitterLayoutStruct *s = data->list.at(id+1); |
885 | QWidget* w = s->wid; | 915 | QWidget* w = s->wid; |
886 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; | 916 | *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; |
887 | } | 917 | } |
888 | } | 918 | } |
889 | 919 | ||
890 | 920 | ||
891 | /*! | 921 | /*! |
892 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. | 922 | Returns the valid range of the splitter with id \a id in \a *min and \a *max. |
893 | 923 | ||
894 | \sa idAfter() | 924 | \sa idAfter() |
895 | */ | 925 | */ |
896 | 926 | ||
897 | void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) | 927 | void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) |
898 | { | 928 | { |
899 | int minB = 0;//before | 929 | int minB = 0;//before |
900 | int maxB = 0; | 930 | int maxB = 0; |
901 | int minA = 0; | 931 | int minA = 0; |
902 | int maxA = 0;//after | 932 | int maxA = 0;//after |
903 | int n = data->list.count(); | 933 | int n = data->list.count(); |
904 | if ( id < 0 || id >= n ) | 934 | if ( id < 0 || id >= n ) |
905 | return; | 935 | return; |
906 | int i; | 936 | int i; |
907 | for ( i = 0; i < id; i++ ) { | 937 | for ( i = 0; i < id; i++ ) { |
908 | QSplitterLayoutStruct *s = data->list.at(i); | 938 | QSplitterLayoutStruct *s = data->list.at(i); |
909 | if ( s->wid->isHidden() ) { | 939 | if ( s->wid->isHidden() ) { |
910 | //ignore | 940 | //ignore |
911 | } else if ( s->isSplitter ) { | 941 | } else if ( s->isSplitter ) { |
912 | minB += s->sizer; | 942 | minB += s->sizer; |
913 | maxB += s->sizer; | 943 | maxB += s->sizer; |
914 | } else { | 944 | } else { |
915 | minB += pick( minSize(s->wid) ); | 945 | minB += pick( minSize(s->wid) ); |
916 | maxB += pick( s->wid->maximumSize() ); | 946 | maxB += pick( s->wid->maximumSize() ); |
917 | } | 947 | } |
918 | } | 948 | } |
919 | for ( i = id; i < n; i++ ) { | 949 | for ( i = id; i < n; i++ ) { |
920 | QSplitterLayoutStruct *s = data->list.at(i); | 950 | QSplitterLayoutStruct *s = data->list.at(i); |
921 | if ( s->wid->isHidden() ) { | 951 | if ( s->wid->isHidden() ) { |
922 | //ignore | 952 | //ignore |
923 | } else if ( s->isSplitter ) { | 953 | } else if ( s->isSplitter ) { |
924 | minA += s->sizer; | 954 | minA += s->sizer; |
925 | maxA += s->sizer; | 955 | maxA += s->sizer; |
926 | } else { | 956 | } else { |
927 | minA += pick( minSize(s->wid) ); | 957 | minA += pick( minSize(s->wid) ); |
928 | maxA += pick( s->wid->maximumSize() ); | 958 | maxA += pick( s->wid->maximumSize() ); |
929 | } | 959 | } |
930 | } | 960 | } |
931 | QRect r = contentsRect(); | 961 | QRect r = contentsRect(); |
932 | if ( orient == Horizontal && false ) { | 962 | if ( orient == Horizontal && false ) { |
933 | #if QT_VERSION >= 0x030000 | 963 | #if QT_VERSION >= 0x030000 |
934 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 964 | int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
935 | #else | 965 | #else |
936 | int splitterWidth = style().splitterWidth(); | 966 | int splitterWidth = style().splitterWidth(); |
937 | #endif | 967 | #endif |
938 | 968 | ||
939 | if ( min ) | 969 | if ( min ) |
940 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; | 970 | *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; |
941 | if ( max ) | 971 | if ( max ) |
942 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; | 972 | *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; |
943 | } else { | 973 | } else { |
944 | if ( min ) | 974 | if ( min ) |
945 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); | 975 | *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); |
946 | if ( max ) | 976 | if ( max ) |
947 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); | 977 | *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); |
948 | } | 978 | } |
949 | } | 979 | } |
950 | 980 | ||
951 | 981 | ||
952 | /*! | 982 | /*! |
953 | Returns the closest legal position to \a p of the splitter with id \a id. | 983 | Returns the closest legal position to \a p of the splitter with id \a id. |
954 | 984 | ||
955 | \sa idAfter() | 985 | \sa idAfter() |
956 | */ | 986 | */ |
957 | 987 | ||
958 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) | 988 | int KDGanttMinimizeSplitter::adjustPos( int p, int id ) |
959 | { | 989 | { |
960 | int min = 0; | 990 | int min = 0; |
961 | int max = 0; | 991 | int max = 0; |
962 | getRange( id, &min, &max ); | 992 | getRange( id, &min, &max ); |
963 | p = QMAX( min, QMIN( p, max ) ); | 993 | p = QMAX( min, QMIN( p, max ) ); |
964 | 994 | ||
965 | return p; | 995 | return p; |
966 | } | 996 | } |
967 | 997 | ||
968 | 998 | ||
969 | void KDGanttMinimizeSplitter::doResize() | 999 | void KDGanttMinimizeSplitter::doResize() |
970 | { | 1000 | { |
971 | QRect r = contentsRect(); | 1001 | QRect r = contentsRect(); |
972 | int i; | 1002 | int i; |
973 | int n = data->list.count(); | 1003 | int n = data->list.count(); |
974 | QMemArray<QLayoutStruct> a( n ); | 1004 | QMemArray<QLayoutStruct> a( n ); |
975 | for ( i = 0; i< n; i++ ) { | 1005 | for ( i = 0; i< n; i++ ) { |
976 | a[i].init(); | 1006 | a[i].init(); |
977 | QSplitterLayoutStruct *s = data->list.at(i); | 1007 | QSplitterLayoutStruct *s = data->list.at(i); |
978 | if ( s->wid->isHidden() ) { | 1008 | if ( s->wid->isHidden() ) { |
979 | a[i].stretch = 0; | 1009 | a[i].stretch = 0; |
980 | a[i].sizeHint = a[i].minimumSize = 0; | 1010 | a[i].sizeHint = a[i].minimumSize = 0; |
981 | a[i].maximumSize = 0; | 1011 | a[i].maximumSize = 0; |
982 | } else if ( s->isSplitter ) { | 1012 | } else if ( s->isSplitter ) { |
983 | a[i].stretch = 0; | 1013 | a[i].stretch = 0; |
984 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; | 1014 | a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; |
985 | a[i].empty = FALSE; | 1015 | a[i].empty = FALSE; |
986 | } else if ( s->mode == KeepSize ) { | 1016 | } else if ( s->mode == KeepSize ) { |
987 | a[i].stretch = 0; | 1017 | a[i].stretch = 0; |
988 | a[i].minimumSize = pick( minSize(s->wid) ); | 1018 | a[i].minimumSize = pick( minSize(s->wid) ); |
989 | a[i].sizeHint = s->sizer; | 1019 | a[i].sizeHint = s->sizer; |
990 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1020 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
991 | a[i].empty = FALSE; | 1021 | a[i].empty = FALSE; |
992 | } else if ( s->mode == FollowSizeHint ) { | 1022 | } else if ( s->mode == FollowSizeHint ) { |
993 | a[i].stretch = 0; | 1023 | a[i].stretch = 0; |
994 | a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); | 1024 | a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); |
995 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1025 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
996 | a[i].empty = FALSE; | 1026 | a[i].empty = FALSE; |
997 | } else { //proportional | 1027 | } else { //proportional |
998 | a[i].stretch = s->sizer; | 1028 | a[i].stretch = s->sizer; |
999 | a[i].maximumSize = pick( s->wid->maximumSize() ); | 1029 | a[i].maximumSize = pick( s->wid->maximumSize() ); |
1000 | a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); | 1030 | a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); |
1001 | a[i].empty = FALSE; | 1031 | a[i].empty = FALSE; |
1002 | } | 1032 | } |
1003 | } | 1033 | } |
1004 | 1034 | ||
1005 | kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); | 1035 | kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); |
1006 | 1036 | ||
1007 | for ( i = 0; i< n; i++ ) { | 1037 | for ( i = 0; i< n; i++ ) { |
1008 | QSplitterLayoutStruct *s = data->list.at(i); | 1038 | QSplitterLayoutStruct *s = data->list.at(i); |
1009 | setG( s->wid, a[i].pos, a[i].size ); | 1039 | setG( s->wid, a[i].pos, a[i].size ); |
1010 | } | 1040 | } |
1011 | 1041 | ||
1012 | } | 1042 | } |
1013 | 1043 | ||
1014 | 1044 | ||
1015 | void KDGanttMinimizeSplitter::recalc( bool update ) | 1045 | void KDGanttMinimizeSplitter::recalc( bool update ) |
1016 | { | 1046 | { |
1017 | int fi = 2*frameWidth(); | 1047 | int fi = 2*frameWidth(); |
1018 | int maxl = fi; | 1048 | int maxl = fi; |
1019 | int minl = fi; | 1049 | int minl = fi; |
1020 | int maxt = QWIDGETSIZE_MAX; | 1050 | int maxt = QWIDGETSIZE_MAX; |
1021 | int mint = fi; | 1051 | int mint = fi; |
1022 | int n = data->list.count(); | 1052 | int n = data->list.count(); |
1023 | bool first = TRUE; | 1053 | bool first = TRUE; |
1024 | /* | 1054 | /* |
1025 | The splitter before a hidden widget is always hidden. | 1055 | The splitter before a hidden widget is always hidden. |
1026 | The splitter before the first visible widget is hidden. | 1056 | The splitter before the first visible widget is hidden. |
1027 | The splitter before any other visible widget is visible. | 1057 | The splitter before any other visible widget is visible. |
1028 | */ | 1058 | */ |
1029 | for ( int i = 0; i< n; i++ ) { | 1059 | for ( int i = 0; i< n; i++ ) { |
1030 | QSplitterLayoutStruct *s = data->list.at(i); | 1060 | QSplitterLayoutStruct *s = data->list.at(i); |
1031 | if ( !s->isSplitter ) { | 1061 | if ( !s->isSplitter ) { |
1032 | QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; | 1062 | QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; |
1033 | if ( p && p->isSplitter ) | 1063 | if ( p && p->isSplitter ) |
1034 | if ( first || s->wid->isHidden() ) | 1064 | if ( first || s->wid->isHidden() ) |
1035 | p->wid->hide(); //may trigger new recalc | 1065 | p->wid->hide(); //may trigger new recalc |
1036 | else | 1066 | else |
1037 | p->wid->show(); //may trigger new recalc | 1067 | p->wid->show(); //may trigger new recalc |
1038 | if ( !s->wid->isHidden() ) | 1068 | if ( !s->wid->isHidden() ) |
1039 | first = FALSE; | 1069 | first = FALSE; |
1040 | } | 1070 | } |
1041 | } | 1071 | } |
1042 | 1072 | ||
1043 | bool empty=TRUE; | 1073 | bool empty=TRUE; |
1044 | for ( int j = 0; j< n; j++ ) { | 1074 | for ( int j = 0; j< n; j++ ) { |
1045 | QSplitterLayoutStruct *s = data->list.at(j); | 1075 | QSplitterLayoutStruct *s = data->list.at(j); |
1046 | if ( !s->wid->isHidden() ) { | 1076 | if ( !s->wid->isHidden() ) { |
1047 | empty = FALSE; | 1077 | empty = FALSE; |
1048 | if ( s->isSplitter ) { | 1078 | if ( s->isSplitter ) { |
1049 | minl += s->sizer; | 1079 | minl += s->sizer; |
1050 | maxl += s->sizer; | 1080 | maxl += s->sizer; |
1051 | } else { | 1081 | } else { |
1052 | QSize minS = minSize(s->wid); | 1082 | QSize minS = minSize(s->wid); |
1053 | minl += pick( minS ); | 1083 | minl += pick( minS ); |
1054 | maxl += pick( s->wid->maximumSize() ); | 1084 | maxl += pick( s->wid->maximumSize() ); |
1055 | mint = QMAX( mint, trans( minS )); | 1085 | mint = QMAX( mint, trans( minS )); |
1056 | int tm = trans( s->wid->maximumSize() ); | 1086 | int tm = trans( s->wid->maximumSize() ); |
1057 | if ( tm > 0 ) | 1087 | if ( tm > 0 ) |
1058 | maxt = QMIN( maxt, tm ); | 1088 | maxt = QMIN( maxt, tm ); |
1059 | } | 1089 | } |
1060 | } | 1090 | } |
1061 | } | 1091 | } |
1062 | if ( empty ) { | 1092 | if ( empty ) { |
1063 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { | 1093 | if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { |
1064 | // nested splitters; be nice | 1094 | // nested splitters; be nice |
1065 | maxl = maxt = 0; | 1095 | maxl = maxt = 0; |
1066 | } else { | 1096 | } else { |
1067 | // KDGanttMinimizeSplitter with no children yet | 1097 | // KDGanttMinimizeSplitter with no children yet |
1068 | maxl = QWIDGETSIZE_MAX; | 1098 | maxl = QWIDGETSIZE_MAX; |
1069 | } | 1099 | } |
1070 | } else { | 1100 | } else { |
1071 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); | 1101 | maxl = QMIN( maxl, QWIDGETSIZE_MAX ); |
1072 | } | 1102 | } |
1073 | if ( maxt < mint ) | 1103 | if ( maxt < mint ) |
1074 | maxt = mint; | 1104 | maxt = mint; |
1075 | 1105 | ||
1076 | if ( orient == Horizontal ) { | 1106 | if ( orient == Horizontal ) { |
1077 | setMaximumSize( maxl, maxt ); | 1107 | setMaximumSize( maxl, maxt ); |
1078 | setMinimumSize( minl, mint ); | 1108 | setMinimumSize( minl, mint ); |
1079 | } else { | 1109 | } else { |
1080 | setMaximumSize( maxt, maxl ); | 1110 | setMaximumSize( maxt, maxl ); |
1081 | setMinimumSize( mint, minl ); | 1111 | setMinimumSize( mint, minl ); |
1082 | } | 1112 | } |
1083 | if ( update ) | 1113 | if ( update ) |
1084 | doResize(); | 1114 | doResize(); |
1085 | } | 1115 | } |
1086 | 1116 | ||
1087 | /*! | 1117 | /*! |
1088 | Sets resize mode of \a w to \a mode. | 1118 | Sets resize mode of \a w to \a mode. |
1089 | 1119 | ||
1090 | \sa ResizeMode | 1120 | \sa ResizeMode |
1091 | */ | 1121 | */ |
1092 | 1122 | ||
1093 | void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) | 1123 | void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) |
1094 | { | 1124 | { |
1095 | processChildEvents(); | 1125 | processChildEvents(); |
1096 | QSplitterLayoutStruct *s = data->list.first(); | 1126 | QSplitterLayoutStruct *s = data->list.first(); |
1097 | while ( s ) { | 1127 | while ( s ) { |
1098 | if ( s->wid == w ) { | 1128 | if ( s->wid == w ) { |
1099 | s->mode = mode; | 1129 | s->mode = mode; |
1100 | return; | 1130 | return; |
1101 | } | 1131 | } |
1102 | s = data->list.next(); | 1132 | s = data->list.next(); |
1103 | } | 1133 | } |
1104 | s = addWidget( w, TRUE ); | 1134 | s = addWidget( w, TRUE ); |
1105 | s->mode = mode; | 1135 | s->mode = mode; |
1106 | } | 1136 | } |
1107 | 1137 | ||
1108 | 1138 | ||
1109 | /*! | 1139 | /*! |
1110 | Returns TRUE if opaque resize is on; otherwise returns FALSE. | 1140 | Returns TRUE if opaque resize is on; otherwise returns FALSE. |
1111 | 1141 | ||
1112 | \sa setOpaqueResize() | 1142 | \sa setOpaqueResize() |
1113 | */ | 1143 | */ |
1114 | 1144 | ||
1115 | bool KDGanttMinimizeSplitter::opaqueResize() const | 1145 | bool KDGanttMinimizeSplitter::opaqueResize() const |
1116 | { | 1146 | { |
1117 | return data->opaque; | 1147 | return data->opaque; |
1118 | } | 1148 | } |
1119 | 1149 | ||
1120 | 1150 | ||
1121 | /*! | 1151 | /*! |
1122 | If \a on is TRUE then opaque resizing is turned on; otherwise | 1152 | If \a on is TRUE then opaque resizing is turned on; otherwise |
1123 | opaque resizing is turned off. | 1153 | opaque resizing is turned off. |
1124 | Opaque resizing is initially turned off. | 1154 | Opaque resizing is initially turned off. |
1125 | 1155 | ||
1126 | \sa opaqueResize() | 1156 | \sa opaqueResize() |
1127 | */ | 1157 | */ |
1128 | 1158 | ||
1129 | void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) | 1159 | void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) |
1130 | { | 1160 | { |
1131 | data->opaque = on; | 1161 | data->opaque = on; |
1132 | } | 1162 | } |
1133 | 1163 | ||
1134 | 1164 | ||
1135 | /*! | 1165 | /*! |
1136 | Moves widget \a w to the leftmost/top position. | 1166 | Moves widget \a w to the leftmost/top position. |
1137 | */ | 1167 | */ |
1138 | 1168 | ||
1139 | void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) | 1169 | void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) |
1140 | { | 1170 | { |
1141 | processChildEvents(); | 1171 | processChildEvents(); |
1142 | bool found = FALSE; | 1172 | bool found = FALSE; |
1143 | QSplitterLayoutStruct *s = data->list.first(); | 1173 | QSplitterLayoutStruct *s = data->list.first(); |
1144 | while ( s ) { | 1174 | while ( s ) { |
1145 | if ( s->wid == w ) { | 1175 | if ( s->wid == w ) { |
1146 | found = TRUE; | 1176 | found = TRUE; |
1147 | QSplitterLayoutStruct *p = data->list.prev(); | 1177 | QSplitterLayoutStruct *p = data->list.prev(); |
1148 | if ( p ) { // not already at first place | 1178 | if ( p ) { // not already at first place |
1149 | data->list.take(); //take p | 1179 | data->list.take(); //take p |
1150 | data->list.take(); // take s | 1180 | data->list.take(); // take s |
1151 | data->list.insert( 0, p ); | 1181 | data->list.insert( 0, p ); |
1152 | data->list.insert( 0, s ); | 1182 | data->list.insert( 0, s ); |
1153 | } | 1183 | } |
1154 | break; | 1184 | break; |
1155 | } | 1185 | } |
1156 | s = data->list.next(); | 1186 | s = data->list.next(); |
1157 | } | 1187 | } |
1158 | if ( !found ) | 1188 | if ( !found ) |
1159 | addWidget( w, TRUE ); | 1189 | addWidget( w, TRUE ); |
1160 | recalcId(); | 1190 | recalcId(); |
1161 | } | 1191 | } |
1162 | 1192 | ||
1163 | 1193 | ||
1164 | /*! | 1194 | /*! |
1165 | Moves widget \a w to the rightmost/bottom position. | 1195 | Moves widget \a w to the rightmost/bottom position. |
1166 | */ | 1196 | */ |
1167 | 1197 | ||
1168 | void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) | 1198 | void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) |
1169 | { | 1199 | { |
1170 | processChildEvents(); | 1200 | processChildEvents(); |
1171 | bool found = FALSE; | 1201 | bool found = FALSE; |
1172 | QSplitterLayoutStruct *s = data->list.first(); | 1202 | QSplitterLayoutStruct *s = data->list.first(); |
1173 | while ( s ) { | 1203 | while ( s ) { |
1174 | if ( s->wid == w ) { | 1204 | if ( s->wid == w ) { |
1175 | found = TRUE; | 1205 | found = TRUE; |
1176 | data->list.take(); // take s | 1206 | data->list.take(); // take s |
1177 | QSplitterLayoutStruct *p = data->list.current(); | 1207 | QSplitterLayoutStruct *p = data->list.current(); |
1178 | if ( p ) { // the splitter handle after s | 1208 | if ( p ) { // the splitter handle after s |
1179 | data->list.take(); //take p | 1209 | data->list.take(); //take p |
1180 | data->list.append( p ); | 1210 | data->list.append( p ); |
1181 | } | 1211 | } |
1182 | data->list.append( s ); | 1212 | data->list.append( s ); |
1183 | break; | 1213 | break; |
1184 | } | 1214 | } |
1185 | s = data->list.next(); | 1215 | s = data->list.next(); |
1186 | } | 1216 | } |
1187 | if ( !found ) | 1217 | if ( !found ) |
1188 | addWidget( w); | 1218 | addWidget( w); |
1189 | recalcId(); | 1219 | recalcId(); |
1190 | } | 1220 | } |
1191 | 1221 | ||
1192 | 1222 | ||
1193 | void KDGanttMinimizeSplitter::recalcId() | 1223 | void KDGanttMinimizeSplitter::recalcId() |
1194 | { | 1224 | { |
1195 | int n = data->list.count(); | 1225 | int n = data->list.count(); |
1196 | for ( int i = 0; i < n; i++ ) { | 1226 | for ( int i = 0; i < n; i++ ) { |
1197 | QSplitterLayoutStruct *s = data->list.at(i); | 1227 | QSplitterLayoutStruct *s = data->list.at(i); |
1198 | if ( s->isSplitter ) | 1228 | if ( s->isSplitter ) |
1199 | ((KDGanttSplitterHandle*)s->wid)->setId(i); | 1229 | ((KDGanttSplitterHandle*)s->wid)->setId(i); |
1200 | } | 1230 | } |
1201 | } | 1231 | } |
1202 | 1232 | ||
1203 | 1233 | ||
1204 | /*!\reimp | 1234 | /*!\reimp |
1205 | */ | 1235 | */ |
1206 | QSize KDGanttMinimizeSplitter::sizeHint() const | 1236 | QSize KDGanttMinimizeSplitter::sizeHint() const |
1207 | { | 1237 | { |
1208 | constPolish(); | 1238 | constPolish(); |
1209 | int l = 0; | 1239 | int l = 0; |
1210 | int t = 0; | 1240 | int t = 0; |
1211 | if ( children() ) { | 1241 | if ( children() ) { |
1212 | const QObjectList * c = children(); | 1242 | const QObjectList * c = children(); |
1213 | QObjectListIt it( *c ); | 1243 | QObjectListIt it( *c ); |
1214 | QObject * o; | 1244 | QObject * o; |
1215 | 1245 | ||
1216 | while( (o=it.current()) != 0 ) { | 1246 | while( (o=it.current()) != 0 ) { |
1217 | ++it; | 1247 | ++it; |
1218 | if ( o->isWidgetType() && | 1248 | if ( o->isWidgetType() && |
1219 | !((QWidget*)o)->isHidden() ) { | 1249 | !((QWidget*)o)->isHidden() ) { |
1220 | QSize s = ((QWidget*)o)->sizeHint(); | 1250 | QSize s = ((QWidget*)o)->sizeHint(); |
1221 | if ( s.isValid() ) { | 1251 | if ( s.isValid() ) { |
1222 | l += pick( s ); | 1252 | l += pick( s ); |
1223 | t = QMAX( t, trans( s ) ); | 1253 | t = QMAX( t, trans( s ) ); |
1224 | } | 1254 | } |
1225 | } | 1255 | } |
1226 | } | 1256 | } |
1227 | } | 1257 | } |
1228 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1258 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); |
1229 | } | 1259 | } |
1230 | 1260 | ||
1231 | 1261 | ||
1232 | /*! | 1262 | /*! |
1233 | \reimp | 1263 | \reimp |
1234 | */ | 1264 | */ |
1235 | 1265 | ||
1236 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const | 1266 | QSize KDGanttMinimizeSplitter::minimumSizeHint() const |
1237 | { | 1267 | { |
1238 | constPolish(); | 1268 | constPolish(); |
1239 | int l = 0; | 1269 | int l = 0; |
1240 | int t = 0; | 1270 | int t = 0; |
1241 | if ( children() ) { | 1271 | if ( children() ) { |
1242 | const QObjectList * c = children(); | 1272 | const QObjectList * c = children(); |
1243 | QObjectListIt it( *c ); | 1273 | QObjectListIt it( *c ); |
1244 | QObject * o; | 1274 | QObject * o; |
1245 | 1275 | ||
1246 | while( (o=it.current()) != 0 ) { | 1276 | while( (o=it.current()) != 0 ) { |
1247 | ++it; | 1277 | ++it; |
1248 | if ( o->isWidgetType() && | 1278 | if ( o->isWidgetType() && |
1249 | !((QWidget*)o)->isHidden() ) { | 1279 | !((QWidget*)o)->isHidden() ) { |
1250 | QSize s = minSizeHint((QWidget*)o); | 1280 | QSize s = minSizeHint((QWidget*)o); |
1251 | if ( s.isValid() ) { | 1281 | if ( s.isValid() ) { |
1252 | l += pick( s ); | 1282 | l += pick( s ); |
1253 | t = QMAX( t, trans( s ) ); | 1283 | t = QMAX( t, trans( s ) ); |
1254 | } | 1284 | } |
1255 | } | 1285 | } |
1256 | } | 1286 | } |
1257 | } | 1287 | } |
1258 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); | 1288 | return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); |
1259 | } | 1289 | } |
1260 | 1290 | ||
1261 | 1291 | ||
1262 | /* | 1292 | /* |
1263 | Calculates stretch parameters from current sizes | 1293 | Calculates stretch parameters from current sizes |
1264 | */ | 1294 | */ |
1265 | 1295 | ||
1266 | void KDGanttMinimizeSplitter::storeSizes() | 1296 | void KDGanttMinimizeSplitter::storeSizes() |
1267 | { | 1297 | { |
1268 | QSplitterLayoutStruct *s = data->list.first(); | 1298 | QSplitterLayoutStruct *s = data->list.first(); |
1269 | while ( s ) { | 1299 | while ( s ) { |
1270 | if ( !s->isSplitter ) | 1300 | if ( !s->isSplitter ) |
1271 | s->sizer = pick( s->wid->size() ); | 1301 | s->sizer = pick( s->wid->size() ); |
1272 | s = data->list.next(); | 1302 | s = data->list.next(); |
1273 | } | 1303 | } |
1274 | } | 1304 | } |
1275 | 1305 | ||
1276 | 1306 | ||
1277 | #if 0 // ### remove this code ASAP | 1307 | #if 0 // ### remove this code ASAP |
1278 | 1308 | ||
1279 | /*! | 1309 | /*! |
1280 | Hides \a w if \a hide is TRUE and updates the splitter. | 1310 | Hides \a w if \a hide is TRUE and updates the splitter. |
1281 | 1311 | ||
1282 | \warning Due to a limitation in the current implementation, | 1312 | \warning Due to a limitation in the current implementation, |
1283 | calling QWidget::hide() will not work. | 1313 | calling QWidget::hide() will not work. |
1284 | */ | 1314 | */ |
1285 | 1315 | ||
1286 | void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) | 1316 | void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) |
1287 | { | 1317 | { |
1288 | if ( w == w1 ) { | 1318 | if ( w == w1 ) { |
1289 | w1show = !hide; | 1319 | w1show = !hide; |
1290 | } else if ( w == w2 ) { | 1320 | } else if ( w == w2 ) { |
1291 | w2show = !hide; | 1321 | w2show = !hide; |
1292 | } else { | 1322 | } else { |
1293 | #ifdef QT_CHECK_RANGE | 1323 | #ifdef QT_CHECK_RANGE |
1294 | qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); | 1324 | qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); |
1295 | #endif | 1325 | #endif |
1296 | return; | 1326 | return; |
1297 | } | 1327 | } |
1298 | if ( hide ) | 1328 | if ( hide ) |
1299 | w->hide(); | 1329 | w->hide(); |
1300 | else | 1330 | else |
1301 | w->show(); | 1331 | w->show(); |
1302 | recalc( TRUE ); | 1332 | recalc( TRUE ); |
1303 | } | 1333 | } |
1304 | 1334 | ||
1305 | 1335 | ||
1306 | /*! | 1336 | /*! |
1307 | Returns the hidden status of \a w | 1337 | Returns the hidden status of \a w |
1308 | */ | 1338 | */ |
1309 | 1339 | ||
1310 | bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const | 1340 | bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const |
1311 | { | 1341 | { |
1312 | if ( w == w1 ) | 1342 | if ( w == w1 ) |
1313 | return !w1show; | 1343 | return !w1show; |
1314 | else if ( w == w2 ) | 1344 | else if ( w == w2 ) |
1315 | return !w2show; | 1345 | return !w2show; |
1316 | #ifdef QT_CHECK_RANGE | 1346 | #ifdef QT_CHECK_RANGE |
1317 | else | 1347 | else |
1318 | qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); | 1348 | qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); |
1319 | #endif | 1349 | #endif |
1320 | return FALSE; | 1350 | return FALSE; |
1321 | } | 1351 | } |
1322 | #endif | 1352 | #endif |
1323 | 1353 | ||
1324 | 1354 | ||
1325 | /*! | 1355 | /*! |
1326 | Returns a list of the size parameters of all the widgets in this | 1356 | Returns a list of the size parameters of all the widgets in this |
1327 | splitter. | 1357 | splitter. |
1328 | 1358 | ||
1329 | Giving the values to another splitter's setSizes() function will | 1359 | Giving the values to another splitter's setSizes() function will |
1330 | produce a splitter with the same layout as this one. | 1360 | produce a splitter with the same layout as this one. |
1331 | 1361 | ||
1332 | Note that if you want to iterate over the list, you should | 1362 | Note that if you want to iterate over the list, you should |
1333 | iterate over a copy, e.g. | 1363 | iterate over a copy, e.g. |
1334 | \code | 1364 | \code |
1335 | QValueList<int> list = mySplitter.sizes(); | 1365 | QValueList<int> list = mySplitter.sizes(); |
1336 | QValueList<int>::Iterator it = list.begin(); | 1366 | QValueList<int>::Iterator it = list.begin(); |
1337 | while( it != list.end() ) { | 1367 | while( it != list.end() ) { |
1338 | myProcessing( *it ); | 1368 | myProcessing( *it ); |
1339 | ++it; | 1369 | ++it; |
1340 | } | 1370 | } |
1341 | \endcode | 1371 | \endcode |
1342 | 1372 | ||
1343 | \sa setSizes() | 1373 | \sa setSizes() |
1344 | */ | 1374 | */ |
1345 | 1375 | ||
1346 | QValueList<int> KDGanttMinimizeSplitter::sizes() const | 1376 | QValueList<int> KDGanttMinimizeSplitter::sizes() const |
1347 | { | 1377 | { |
1348 | if ( !testWState(WState_Polished) ) { | 1378 | if ( !testWState(WState_Polished) ) { |
1349 | QWidget* that = (QWidget*) this; | 1379 | QWidget* that = (QWidget*) this; |
1350 | that->polish(); | 1380 | that->polish(); |
1351 | } | 1381 | } |
1352 | QValueList<int> list; | 1382 | QValueList<int> list; |
1353 | QSplitterLayoutStruct *s = data->list.first(); | 1383 | QSplitterLayoutStruct *s = data->list.first(); |
1354 | while ( s ) { | 1384 | while ( s ) { |
1355 | if ( !s->isSplitter ) | 1385 | if ( !s->isSplitter ) |
1356 | list.append( s->sizer ); | 1386 | list.append( s->sizer ); |
1357 | s = data->list.next(); | 1387 | s = data->list.next(); |
1358 | } | 1388 | } |
1359 | return list; | 1389 | return list; |
1360 | } | 1390 | } |
1361 | 1391 | ||
1362 | 1392 | ||
1363 | 1393 | ||
1364 | /*! | 1394 | /*! |
1365 | Sets the size parameters to the values given in \a list. | 1395 | Sets the size parameters to the values given in \a list. |
1366 | If the splitter is horizontal, the values set the sizes from | 1396 | If the splitter is horizontal, the values set the sizes from |
1367 | left to right. If it is vertical, the sizes are applied from | 1397 | left to right. If it is vertical, the sizes are applied from |
1368 | top to bottom. | 1398 | top to bottom. |
1369 | Extra values in \a list are ignored. | 1399 | Extra values in \a list are ignored. |
1370 | 1400 | ||
1371 | If \a list contains too few values, the result is undefined | 1401 | If \a list contains too few values, the result is undefined |
1372 | but the program will still be well-behaved. | 1402 | but the program will still be well-behaved. |
1373 | 1403 | ||
1374 | \sa sizes() | 1404 | \sa sizes() |
1375 | */ | 1405 | */ |
1376 | 1406 | ||
1377 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) | 1407 | void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) |
1378 | { | 1408 | { |
1379 | processChildEvents(); | 1409 | processChildEvents(); |
1380 | QValueList<int>::Iterator it = list.begin(); | 1410 | QValueList<int>::Iterator it = list.begin(); |
1381 | QSplitterLayoutStruct *s = data->list.first(); | 1411 | QSplitterLayoutStruct *s = data->list.first(); |
1382 | while ( s && it != list.end() ) { | 1412 | while ( s && it != list.end() ) { |
1383 | if ( !s->isSplitter ) { | 1413 | if ( !s->isSplitter ) { |
1384 | s->sizer = *it; | 1414 | s->sizer = *it; |
1385 | ++it; | 1415 | ++it; |
1386 | } | 1416 | } |
1387 | s = data->list.next(); | 1417 | s = data->list.next(); |
1388 | } | 1418 | } |
1389 | doResize(); | 1419 | doResize(); |
1390 | } | 1420 | } |
1391 | 1421 | ||
1392 | 1422 | ||
1393 | /*! | 1423 | /*! |
1394 | Gets all posted child events, ensuring that the internal state of | 1424 | Gets all posted child events, ensuring that the internal state of |
1395 | the splitter is consistent. | 1425 | the splitter is consistent. |
1396 | */ | 1426 | */ |
1397 | 1427 | ||
1398 | void KDGanttMinimizeSplitter::processChildEvents() | 1428 | void KDGanttMinimizeSplitter::processChildEvents() |
1399 | { | 1429 | { |
1400 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1430 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1401 | } | 1431 | } |
1402 | 1432 | ||
1403 | 1433 | ||
1404 | /*! | 1434 | /*! |
1405 | \reimp | 1435 | \reimp |
1406 | */ | 1436 | */ |
1407 | 1437 | ||
1408 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) | 1438 | void KDGanttMinimizeSplitter::styleChange( QStyle& old ) |
1409 | { | 1439 | { |
1410 | 1440 | ||
1411 | #if QT_VERSION >= 0x030000 | 1441 | #if QT_VERSION >= 0x030000 |
1412 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 1442 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
1413 | #else | 1443 | #else |
1414 | int sw = style().splitterWidth(); | 1444 | int sw = style().splitterWidth(); |
1415 | #endif | 1445 | #endif |
1416 | QSplitterLayoutStruct *s = data->list.first(); | 1446 | QSplitterLayoutStruct *s = data->list.first(); |
1417 | while ( s ) { | 1447 | while ( s ) { |
1418 | if ( s->isSplitter ) | 1448 | if ( s->isSplitter ) |
1419 | s->sizer = sw; | 1449 | s->sizer = sw; |
1420 | s = data->list.next(); | 1450 | s = data->list.next(); |
1421 | } | 1451 | } |
1422 | doResize(); | 1452 | doResize(); |
1423 | QFrame::styleChange( old ); | 1453 | QFrame::styleChange( old ); |
1424 | } | 1454 | } |
1425 | 1455 | ||
1426 | #endif | 1456 | #endif |
1427 | 1457 | ||
1428 | /*! | 1458 | /*! |
1429 | Specifies the direction of the minimize buttons. | 1459 | Specifies the direction of the minimize buttons. |
1430 | If the orientation of the splitter is horizontal then with | 1460 | If the orientation of the splitter is horizontal then with |
1431 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, | 1461 | KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, |
1432 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down | 1462 | otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down |
1433 | should be used. | 1463 | should be used. |
1434 | */ | 1464 | */ |
1435 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) | 1465 | void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) |
1436 | { | 1466 | { |
1437 | _direction = direction; | 1467 | _direction = direction; |
1438 | } | 1468 | } |
1439 | 1469 | ||
1440 | /*! | 1470 | /*! |
1441 | Returns the direction of the minimize buttons. | 1471 | Returns the direction of the minimize buttons. |
1442 | */ | 1472 | */ |
1443 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const | 1473 | KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const |
1444 | { | 1474 | { |
1445 | return _direction; | 1475 | return _direction; |
1446 | } | 1476 | } |
1447 | 1477 | ||
1448 | /* | 1478 | /* |
1449 | This is a copy of qGeomCalc() in qlayoutengine.cpp which | 1479 | This is a copy of qGeomCalc() in qlayoutengine.cpp which |
1450 | unfortunately isn't exported. | 1480 | unfortunately isn't exported. |
1451 | */ | 1481 | */ |
1452 | static inline int toFixed( int i ) { return i * 256; } | 1482 | static inline int toFixed( int i ) { return i * 256; } |
1453 | static inline int fRound( int i ) { | 1483 | static inline int fRound( int i ) { |
1454 | return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; | 1484 | return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; |
1455 | } | 1485 | } |
1456 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 1486 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
1457 | int space, int spacer ) | 1487 | int space, int spacer ) |
1458 | { | 1488 | { |
1459 | typedef int fixed; | 1489 | typedef int fixed; |
1460 | int cHint = 0; | 1490 | int cHint = 0; |
1461 | int cMin = 0; | 1491 | int cMin = 0; |
1462 | int cMax = 0; | 1492 | int cMax = 0; |
1463 | int sumStretch = 0; | 1493 | int sumStretch = 0; |
1464 | int spacerCount = 0; | 1494 | int spacerCount = 0; |
1465 | 1495 | ||
1466 | bool wannaGrow = FALSE; // anyone who really wants to grow? | 1496 | bool wannaGrow = FALSE; // anyone who really wants to grow? |
1467 | // bool canShrink = FALSE; // anyone who could be persuaded to shrink? | 1497 | // bool canShrink = FALSE; // anyone who could be persuaded to shrink? |
1468 | 1498 | ||
1469 | int i; | 1499 | int i; |
1470 | for ( i = start; i < start + count; i++ ) { | 1500 | for ( i = start; i < start + count; i++ ) { |
1471 | chain[i].done = FALSE; | 1501 | chain[i].done = FALSE; |
1472 | cHint += chain[i].sizeHint; | 1502 | cHint += chain[i].sizeHint; |
1473 | cMin += chain[i].minimumSize; | 1503 | cMin += chain[i].minimumSize; |
1474 | cMax += chain[i].maximumSize; | 1504 | cMax += chain[i].maximumSize; |
1475 | sumStretch += chain[i].stretch; | 1505 | sumStretch += chain[i].stretch; |
1476 | if ( !chain[i].empty ) | 1506 | if ( !chain[i].empty ) |
1477 | spacerCount++; | 1507 | spacerCount++; |
1478 | wannaGrow = wannaGrow || chain[i].expansive; | 1508 | wannaGrow = wannaGrow || chain[i].expansive; |
1479 | } | 1509 | } |
1480 | 1510 | ||
1481 | int extraspace = 0; | 1511 | int extraspace = 0; |
1482 | if ( spacerCount ) | 1512 | if ( spacerCount ) |
1483 | spacerCount--; // only spacers between things | 1513 | spacerCount--; // only spacers between things |
1484 | if ( space < cMin + spacerCount * spacer ) { | 1514 | if ( space < cMin + spacerCount * spacer ) { |
1485 | //qDebug("not enough space"); | 1515 | //qDebug("not enough space"); |
1486 | for ( i = start; i < start+count; i++ ) { | 1516 | for ( i = start; i < start+count; i++ ) { |
1487 | chain[i].size = chain[i].minimumSize; | 1517 | chain[i].size = chain[i].minimumSize; |
1488 | chain[i].done = TRUE; | 1518 | chain[i].done = TRUE; |
1489 | } | 1519 | } |
1490 | } else if ( space < cHint + spacerCount*spacer ) { | 1520 | } else if ( space < cHint + spacerCount*spacer ) { |
1491 | // Less space than sizeHint, but more than minimum. | 1521 | // Less space than sizeHint, but more than minimum. |
1492 | // Currently take space equally from each, like in Qt 2.x. | 1522 | // Currently take space equally from each, like in Qt 2.x. |
1493 | // Commented-out lines will give more space to stretchier items. | 1523 | // Commented-out lines will give more space to stretchier items. |
1494 | int n = count; | 1524 | int n = count; |
1495 | int space_left = space - spacerCount*spacer; | 1525 | int space_left = space - spacerCount*spacer; |
1496 | int overdraft = cHint - space_left; | 1526 | int overdraft = cHint - space_left; |
1497 | //first give to the fixed ones: | 1527 | //first give to the fixed ones: |
1498 | for ( i = start; i < start+count; i++ ) { | 1528 | for ( i = start; i < start+count; i++ ) { |
1499 | if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { | 1529 | if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { |
1500 | chain[i].size = chain[i].sizeHint; | 1530 | chain[i].size = chain[i].sizeHint; |
1501 | chain[i].done = TRUE; | 1531 | chain[i].done = TRUE; |
1502 | space_left -= chain[i].sizeHint; | 1532 | space_left -= chain[i].sizeHint; |
1503 | // sumStretch -= chain[i].stretch; | 1533 | // sumStretch -= chain[i].stretch; |
1504 | n--; | 1534 | n--; |
1505 | } | 1535 | } |
1506 | } | 1536 | } |
1507 | bool finished = n == 0; | 1537 | bool finished = n == 0; |
1508 | while ( !finished ) { | 1538 | while ( !finished ) { |
1509 | finished = TRUE; | 1539 | finished = TRUE; |
1510 | fixed fp_over = toFixed( overdraft ); | 1540 | fixed fp_over = toFixed( overdraft ); |
1511 | fixed fp_w = 0; | 1541 | fixed fp_w = 0; |
1512 | 1542 | ||
1513 | for ( i = start; i < start+count; i++ ) { | 1543 | for ( i = start; i < start+count; i++ ) { |
1514 | if ( chain[i].done ) | 1544 | if ( chain[i].done ) |
1515 | continue; | 1545 | continue; |
1516 | // if ( sumStretch <= 0 ) | 1546 | // if ( sumStretch <= 0 ) |
1517 | fp_w += fp_over / n; | 1547 | fp_w += fp_over / n; |
1518 | // else | 1548 | // else |
1519 | // fp_w += (fp_over * chain[i].stretch) / sumStretch; | 1549 | // fp_w += (fp_over * chain[i].stretch) / sumStretch; |
1520 | int w = fRound( fp_w ); | 1550 | int w = fRound( fp_w ); |
1521 | chain[i].size = chain[i].sizeHint - w; | 1551 | chain[i].size = chain[i].sizeHint - w; |
1522 | fp_w -= toFixed( w ); //give the difference to the next | 1552 | fp_w -= toFixed( w ); //give the difference to the next |
1523 | if ( chain[i].size < chain[i].minimumSize ) { | 1553 | if ( chain[i].size < chain[i].minimumSize ) { |
1524 | chain[i].done = TRUE; | 1554 | chain[i].done = TRUE; |
1525 | chain[i].size = chain[i].minimumSize; | 1555 | chain[i].size = chain[i].minimumSize; |
1526 | finished = FALSE; | 1556 | finished = FALSE; |
1527 | overdraft -= chain[i].sizeHint - chain[i].minimumSize; | 1557 | overdraft -= chain[i].sizeHint - chain[i].minimumSize; |
1528 | // sumStretch -= chain[i].stretch; | 1558 | // sumStretch -= chain[i].stretch; |
1529 | n--; | 1559 | n--; |
1530 | break; | 1560 | break; |
1531 | } | 1561 | } |
1532 | } | 1562 | } |
1533 | } | 1563 | } |
1534 | } else { //extra space | 1564 | } else { //extra space |
1535 | int n = count; | 1565 | int n = count; |
1536 | int space_left = space - spacerCount*spacer; | 1566 | int space_left = space - spacerCount*spacer; |
1537 | // first give to the fixed ones, and handle non-expansiveness | 1567 | // first give to the fixed ones, and handle non-expansiveness |
1538 | for ( i = start; i < start + count; i++ ) { | 1568 | for ( i = start; i < start + count; i++ ) { |
1539 | if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint | 1569 | if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint |
1540 | || wannaGrow && !chain[i].expansive) ) { | 1570 | || wannaGrow && !chain[i].expansive) ) { |
1541 | chain[i].size = chain[i].sizeHint; | 1571 | chain[i].size = chain[i].sizeHint; |
1542 | chain[i].done = TRUE; | 1572 | chain[i].done = TRUE; |
1543 | space_left -= chain[i].sizeHint; | 1573 | space_left -= chain[i].sizeHint; |
1544 | sumStretch -= chain[i].stretch; | 1574 | sumStretch -= chain[i].stretch; |
1545 | n--; | 1575 | n--; |
1546 | } | 1576 | } |
1547 | } | 1577 | } |
1548 | extraspace = space_left; | 1578 | extraspace = space_left; |
1549 | /* | 1579 | /* |
1550 | Do a trial distribution and calculate how much it is off. | 1580 | Do a trial distribution and calculate how much it is off. |
1551 | If there are more deficit pixels than surplus pixels, give | 1581 | If there are more deficit pixels than surplus pixels, give |
1552 | the minimum size items what they need, and repeat. | 1582 | the minimum size items what they need, and repeat. |
1553 | Otherwise give to the maximum size items, and repeat. | 1583 | Otherwise give to the maximum size items, and repeat. |
1554 | 1584 | ||
1555 | I have a wonderful mathematical proof for the correctness | 1585 | I have a wonderful mathematical proof for the correctness |
1556 | of this principle, but unfortunately this comment is too | 1586 | of this principle, but unfortunately this comment is too |
1557 | small to contain it. | 1587 | small to contain it. |
1558 | */ | 1588 | */ |
1559 | int surplus, deficit; | 1589 | int surplus, deficit; |
1560 | do { | 1590 | do { |
1561 | surplus = deficit = 0; | 1591 | surplus = deficit = 0; |
1562 | fixed fp_space = toFixed( space_left ); | 1592 | fixed fp_space = toFixed( space_left ); |
1563 | fixed fp_w = 0; | 1593 | fixed fp_w = 0; |
1564 | for ( i = start; i < start+count; i++ ) { | 1594 | for ( i = start; i < start+count; i++ ) { |
1565 | if ( chain[i].done ) | 1595 | if ( chain[i].done ) |
1566 | continue; | 1596 | continue; |
1567 | extraspace = 0; | 1597 | extraspace = 0; |
1568 | if ( sumStretch <= 0 ) | 1598 | if ( sumStretch <= 0 ) |
1569 | fp_w += fp_space / n; | 1599 | fp_w += fp_space / n; |
1570 | else | 1600 | else |
1571 | fp_w += (fp_space * chain[i].stretch) / sumStretch; | 1601 | fp_w += (fp_space * chain[i].stretch) / sumStretch; |
1572 | int w = fRound( fp_w ); | 1602 | int w = fRound( fp_w ); |
1573 | chain[i].size = w; | 1603 | chain[i].size = w; |
1574 | fp_w -= toFixed( w ); // give the difference to the next | 1604 | fp_w -= toFixed( w ); // give the difference to the next |
1575 | if ( w < chain[i].sizeHint ) { | 1605 | if ( w < chain[i].sizeHint ) { |
1576 | deficit += chain[i].sizeHint - w; | 1606 | deficit += chain[i].sizeHint - w; |
1577 | } else if ( w > chain[i].maximumSize ) { | 1607 | } else if ( w > chain[i].maximumSize ) { |
1578 | surplus += w - chain[i].maximumSize; | 1608 | surplus += w - chain[i].maximumSize; |
1579 | } | 1609 | } |
1580 | } | 1610 | } |
1581 | if ( deficit > 0 && surplus <= deficit ) { | 1611 | if ( deficit > 0 && surplus <= deficit ) { |
1582 | // give to the ones that have too little | 1612 | // give to the ones that have too little |
1583 | for ( i = start; i < start+count; i++ ) { | 1613 | for ( i = start; i < start+count; i++ ) { |
1584 | if ( !chain[i].done && | 1614 | if ( !chain[i].done && |
1585 | chain[i].size < chain[i].sizeHint ) { | 1615 | chain[i].size < chain[i].sizeHint ) { |
1586 | chain[i].size = chain[i].sizeHint; | 1616 | chain[i].size = chain[i].sizeHint; |
1587 | chain[i].done = TRUE; | 1617 | chain[i].done = TRUE; |
1588 | space_left -= chain[i].sizeHint; | 1618 | space_left -= chain[i].sizeHint; |
1589 | sumStretch -= chain[i].stretch; | 1619 | sumStretch -= chain[i].stretch; |
1590 | n--; | 1620 | n--; |
1591 | } | 1621 | } |
1592 | } | 1622 | } |
1593 | } | 1623 | } |
1594 | if ( surplus > 0 && surplus >= deficit ) { | 1624 | if ( surplus > 0 && surplus >= deficit ) { |
1595 | // take from the ones that have too much | 1625 | // take from the ones that have too much |
1596 | for ( i = start; i < start+count; i++ ) { | 1626 | for ( i = start; i < start+count; i++ ) { |
1597 | if ( !chain[i].done && | 1627 | if ( !chain[i].done && |
1598 | chain[i].size > chain[i].maximumSize ) { | 1628 | chain[i].size > chain[i].maximumSize ) { |
1599 | chain[i].size = chain[i].maximumSize; | 1629 | chain[i].size = chain[i].maximumSize; |
1600 | chain[i].done = TRUE; | 1630 | chain[i].done = TRUE; |
1601 | space_left -= chain[i].maximumSize; | 1631 | space_left -= chain[i].maximumSize; |
1602 | sumStretch -= chain[i].stretch; | 1632 | sumStretch -= chain[i].stretch; |
1603 | n--; | 1633 | n--; |
1604 | } | 1634 | } |
1605 | } | 1635 | } |
1606 | } | 1636 | } |
1607 | } while ( n > 0 && surplus != deficit ); | 1637 | } while ( n > 0 && surplus != deficit ); |
1608 | if ( n == 0 ) | 1638 | if ( n == 0 ) |
1609 | extraspace = space_left; | 1639 | extraspace = space_left; |
1610 | } | 1640 | } |
1611 | 1641 | ||
1612 | // as a last resort, we distribute the unwanted space equally | 1642 | // as a last resort, we distribute the unwanted space equally |
1613 | // among the spacers (counting the start and end of the chain). | 1643 | // among the spacers (counting the start and end of the chain). |
1614 | 1644 | ||
1615 | //### should do a sub-pixel allocation of extra space | 1645 | //### should do a sub-pixel allocation of extra space |
1616 | int extra = extraspace / ( spacerCount + 2 ); | 1646 | int extra = extraspace / ( spacerCount + 2 ); |
1617 | int p = pos + extra; | 1647 | int p = pos + extra; |
1618 | for ( i = start; i < start+count; i++ ) { | 1648 | for ( i = start; i < start+count; i++ ) { |
1619 | chain[i].pos = p; | 1649 | chain[i].pos = p; |
1620 | p = p + chain[i].size; | 1650 | p = p + chain[i].size; |
1621 | if ( !chain[i].empty ) | 1651 | if ( !chain[i].empty ) |
1622 | p += spacer+extra; | 1652 | p += spacer+extra; |
1623 | } | 1653 | } |
1624 | } | 1654 | } |
1625 | 1655 | ||
1626 | #endif | 1656 | #endif |
1627 | 1657 | ||
1628 | /*! | 1658 | /*! |
1629 | \enum KDGanttMinimizeSplitter::Direction | 1659 | \enum KDGanttMinimizeSplitter::Direction |
1630 | 1660 | ||
1631 | The values of this enumeration describe into which direction the | 1661 | The values of this enumeration describe into which direction the |
1632 | splitter will collapse its child widgets. By extension, it also | 1662 | splitter will collapse its child widgets. By extension, it also |
1633 | specifies the orientation of the splitter; collapsing to the left or | 1663 | specifies the orientation of the splitter; collapsing to the left or |
1634 | to the right results in a horizontal splitter, collapsing to the top | 1664 | to the right results in a horizontal splitter, collapsing to the top |
1635 | or bottom in a vertical splitter. | 1665 | or bottom in a vertical splitter. |
1636 | */ | 1666 | */ |
1637 | 1667 | ||
1638 | /*! | 1668 | /*! |
1639 | \fn Orientation KDGanttMinimizeSplitter::orientation() const | 1669 | \fn Orientation KDGanttMinimizeSplitter::orientation() const |
1640 | 1670 | ||
1641 | Returns the orientation of the splitter. | 1671 | Returns the orientation of the splitter. |
1642 | */ | 1672 | */ |
1643 | 1673 | ||
1644 | /*! \enum KDGanttMinimizeSplitter::ResizeMode | 1674 | /*! \enum KDGanttMinimizeSplitter::ResizeMode |
1645 | 1675 | ||
1646 | This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: | 1676 | This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: |
1647 | 1677 | ||
1648 | Stretch: the widget will be resized when the splitter | 1678 | Stretch: the widget will be resized when the splitter |
1649 | itself is resized. | 1679 | itself is resized. |
1650 | 1680 | ||
1651 | KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size | 1681 | KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size |
1652 | unchanged. | 1682 | unchanged. |
1653 | 1683 | ||
1654 | FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the | 1684 | FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the |
1655 | widget's size hint changes. | 1685 | widget's size hint changes. |
1656 | */ | 1686 | */ |
1657 | 1687 | ||
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h index 84d3d8e..585298d 100644 --- a/microkde/KDGanttMinimizeSplitter.h +++ b/microkde/KDGanttMinimizeSplitter.h | |||
@@ -1,189 +1,191 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2001-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 | #ifndef KDGANTTMINIMIZESPLITTER_H | 34 | #ifndef KDGANTTMINIMIZESPLITTER_H |
35 | #define KDGANTTMINIMIZESPLITTER_H | 35 | #define KDGANTTMINIMIZESPLITTER_H |
36 | 36 | ||
37 | #ifndef QT_H | 37 | #ifndef QT_H |
38 | #include "qframe.h" | 38 | #include "qframe.h" |
39 | #include "qvaluelist.h" | 39 | #include "qvaluelist.h" |
40 | #endif // QT_H | 40 | #endif // QT_H |
41 | 41 | ||
42 | #ifndef QT_NO_SPLITTER___ | 42 | #ifndef QT_NO_SPLITTER___ |
43 | class QSplitterData; | 43 | class QSplitterData; |
44 | class QSplitterLayoutStruct; | 44 | class QSplitterLayoutStruct; |
45 | class KDGanttSplitterHandle; | 45 | class KDGanttSplitterHandle; |
46 | class KDGanttMinimizeSplitter : public QFrame | 46 | class KDGanttMinimizeSplitter : public QFrame |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | // Q_ENUMS( Direction ) | 49 | // Q_ENUMS( Direction ) |
50 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) | 50 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) |
51 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) | 51 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) |
52 | 52 | ||
53 | public: | 53 | public: |
54 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; | 54 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; |
55 | enum Direction { Left, Right, Up, Down }; | 55 | enum Direction { Left, Right, Up, Down }; |
56 | 56 | ||
57 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); | 57 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); |
58 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); | 58 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); |
59 | ~KDGanttMinimizeSplitter(); | 59 | ~KDGanttMinimizeSplitter(); |
60 | 60 | ||
61 | virtual void setOrientation( Orientation ); | 61 | virtual void setOrientation( Orientation ); |
62 | Orientation orientation() const { return orient; } | 62 | Orientation orientation() const { return orient; } |
63 | 63 | ||
64 | void setMinimizeDirection( Direction ); | 64 | void setMinimizeDirection( Direction ); |
65 | Direction minimizeDirection() const; | 65 | Direction minimizeDirection() const; |
66 | 66 | ||
67 | #if QT_VERSION >= 232 | 67 | #if QT_VERSION >= 232 |
68 | virtual void setResizeMode( QWidget *w, ResizeMode ); | 68 | virtual void setResizeMode( QWidget *w, ResizeMode ); |
69 | virtual void setOpaqueResize( bool = TRUE ); | 69 | virtual void setOpaqueResize( bool = TRUE ); |
70 | bool opaqueResize() const; | 70 | bool opaqueResize() const; |
71 | 71 | ||
72 | void moveToFirst( QWidget * ); | 72 | void moveToFirst( QWidget * ); |
73 | void moveToLast( QWidget * ); | 73 | void moveToLast( QWidget * ); |
74 | 74 | ||
75 | void refresh() { recalc( TRUE ); } | 75 | void refresh() { recalc( TRUE ); } |
76 | QSize sizeHint() const; | 76 | QSize sizeHint() const; |
77 | QSize minimumSizeHint() const; | 77 | QSize minimumSizeHint() const; |
78 | 78 | ||
79 | QValueList<int> sizes() const; | 79 | QValueList<int> sizes() const; |
80 | void setSizes( QValueList<int> ); | 80 | void setSizes( QValueList<int> ); |
81 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} | 81 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} |
82 | void expandPos( int id, int* min, int* max ); | 82 | void expandPos( int id, int* min, int* max ); |
83 | QFrame* rubberBand() { return mRubberBand ;} | ||
83 | public slots: | 84 | public slots: |
84 | void toggle(); | 85 | void toggle(); |
85 | protected: | 86 | protected: |
86 | void childEvent( QChildEvent * ); | 87 | void childEvent( QChildEvent * ); |
87 | 88 | ||
88 | bool event( QEvent * ); | 89 | bool event( QEvent * ); |
89 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
90 | 91 | ||
91 | int idAfter( QWidget* ) const; | 92 | int idAfter( QWidget* ) const; |
92 | 93 | ||
93 | void moveSplitter( QCOORD pos, int id ); | 94 | void moveSplitter( QCOORD pos, int id ); |
94 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, | 95 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, |
95 | QCOORD w, QCOORD h ); | 96 | QCOORD w, QCOORD h ); |
96 | void styleChange( QStyle& ); | 97 | void styleChange( QStyle& ); |
97 | int adjustPos( int , int ); | 98 | int adjustPos( int , int ); |
98 | virtual void setRubberband( int ); | 99 | virtual void setRubberband( int ); |
99 | void getRange( int id, int*, int* ); | 100 | void getRange( int id, int*, int* ); |
100 | 101 | ||
101 | private: | 102 | private: |
103 | QFrame* mRubberBand; | ||
102 | void init(); | 104 | void init(); |
103 | void recalc( bool update = FALSE ); | 105 | void recalc( bool update = FALSE ); |
104 | void doResize(); | 106 | void doResize(); |
105 | void storeSizes(); | 107 | void storeSizes(); |
106 | void processChildEvents(); | 108 | void processChildEvents(); |
107 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); | 109 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); |
108 | void recalcId(); | 110 | void recalcId(); |
109 | void moveBefore( int pos, int id, bool upLeft ); | 111 | void moveBefore( int pos, int id, bool upLeft ); |
110 | void moveAfter( int pos, int id, bool upLeft ); | 112 | void moveAfter( int pos, int id, bool upLeft ); |
111 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); | 113 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); |
112 | 114 | ||
113 | QCOORD pick( const QPoint &p ) const | 115 | QCOORD pick( const QPoint &p ) const |
114 | { return orient == Horizontal ? p.x() : p.y(); } | 116 | { return orient == Horizontal ? p.x() : p.y(); } |
115 | QCOORD pick( const QSize &s ) const | 117 | QCOORD pick( const QSize &s ) const |
116 | { return orient == Horizontal ? s.width() : s.height(); } | 118 | { return orient == Horizontal ? s.width() : s.height(); } |
117 | 119 | ||
118 | QCOORD trans( const QPoint &p ) const | 120 | QCOORD trans( const QPoint &p ) const |
119 | { return orient == Vertical ? p.x() : p.y(); } | 121 | { return orient == Vertical ? p.x() : p.y(); } |
120 | QCOORD trans( const QSize &s ) const | 122 | QCOORD trans( const QSize &s ) const |
121 | { return orient == Vertical ? s.width() : s.height(); } | 123 | { return orient == Vertical ? s.width() : s.height(); } |
122 | KDGanttSplitterHandle* mFirstHandle; | 124 | KDGanttSplitterHandle* mFirstHandle; |
123 | QSplitterData *data; | 125 | QSplitterData *data; |
124 | #endif | 126 | #endif |
125 | 127 | ||
126 | private: | 128 | private: |
127 | Orientation orient; | 129 | Orientation orient; |
128 | Direction _direction; | 130 | Direction _direction; |
129 | #ifndef DOXYGEN_SKIP_INTERNAL | 131 | #ifndef DOXYGEN_SKIP_INTERNAL |
130 | friend class KDGanttSplitterHandle; | 132 | friend class KDGanttSplitterHandle; |
131 | #endif | 133 | #endif |
132 | private:// Disabled copy constructor and operator= | 134 | private:// Disabled copy constructor and operator= |
133 | #if defined(Q_DISABLE_COPY) | 135 | #if defined(Q_DISABLE_COPY) |
134 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); | 136 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); |
135 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); | 137 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); |
136 | #endif | 138 | #endif |
137 | }; | 139 | }; |
138 | 140 | ||
139 | #ifndef DOXYGEN_SKIP_INTERNAL | 141 | #ifndef DOXYGEN_SKIP_INTERNAL |
140 | // This class was continued from a verbatim copy of the | 142 | // This class was continued from a verbatim copy of the |
141 | // QSplitterHandle pertaining to the Qt Enterprise License and the | 143 | // QSplitterHandle pertaining to the Qt Enterprise License and the |
142 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to | 144 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to |
143 | // avoid a symbol clash on some platforms. | 145 | // avoid a symbol clash on some platforms. |
144 | class KDGanttSplitterHandle : public QWidget | 146 | class KDGanttSplitterHandle : public QWidget |
145 | { | 147 | { |
146 | Q_OBJECT | 148 | Q_OBJECT |
147 | #if QT_VERSION >= 232 | 149 | #if QT_VERSION >= 232 |
148 | public: | 150 | public: |
149 | KDGanttSplitterHandle( Qt::Orientation o, | 151 | KDGanttSplitterHandle( Qt::Orientation o, |
150 | KDGanttMinimizeSplitter *parent, const char* name=0 ); | 152 | KDGanttMinimizeSplitter *parent, const char* name=0 ); |
151 | void setOrientation( Qt::Orientation o ); | 153 | void setOrientation( Qt::Orientation o ); |
152 | Qt::Orientation orientation() const { return orient; } | 154 | Qt::Orientation orientation() const { return orient; } |
153 | 155 | ||
154 | bool opaque() const { return s->opaqueResize(); } | 156 | bool opaque() const { return s->opaqueResize(); } |
155 | 157 | ||
156 | QSize sizeHint() const; | 158 | QSize sizeHint() const; |
157 | void toggle(); | 159 | void toggle(); |
158 | 160 | ||
159 | int id() const { return myId; } // data->list.at(id())->wid == this | 161 | int id() const { return myId; } // data->list.at(id())->wid == this |
160 | void setId( int i ) { myId = i; } | 162 | void setId( int i ) { myId = i; } |
161 | 163 | ||
162 | protected: | 164 | protected: |
163 | QValueList<QPointArray> buttonRegions(); | 165 | QValueList<QPointArray> buttonRegions(); |
164 | void paintEvent( QPaintEvent * ); | 166 | void paintEvent( QPaintEvent * ); |
165 | void mouseMoveEvent( QMouseEvent * ); | 167 | void mouseMoveEvent( QMouseEvent * ); |
166 | void mousePressEvent( QMouseEvent * ); | 168 | void mousePressEvent( QMouseEvent * ); |
167 | void mouseReleaseEvent( QMouseEvent * ); | 169 | void mouseReleaseEvent( QMouseEvent * ); |
168 | int onButton( const QPoint& p ); | 170 | int onButton( const QPoint& p ); |
169 | void updateCursor( const QPoint& p ); | 171 | void updateCursor( const QPoint& p ); |
170 | 172 | ||
171 | private: | 173 | private: |
172 | bool mMouseDown; | 174 | bool mMouseDown; |
173 | QSize mSizeHint; | 175 | QSize mSizeHint; |
174 | bool mUseOffset; | 176 | bool mUseOffset; |
175 | Qt::Orientation orient; | 177 | Qt::Orientation orient; |
176 | bool opaq; | 178 | bool opaq; |
177 | int myId; | 179 | int myId; |
178 | 180 | ||
179 | KDGanttMinimizeSplitter *s; | 181 | KDGanttMinimizeSplitter *s; |
180 | int _activeButton; | 182 | int _activeButton; |
181 | bool _collapsed; | 183 | bool _collapsed; |
182 | int _origPos; | 184 | int _origPos; |
183 | #endif | 185 | #endif |
184 | }; | 186 | }; |
185 | #endif | 187 | #endif |
186 | 188 | ||
187 | #endif // QT_NO_SPLITTER | 189 | #endif // QT_NO_SPLITTER |
188 | 190 | ||
189 | #endif // KDGANTTMINIMIZESPLITTER_H | 191 | #endif // KDGANTTMINIMIZESPLITTER_H |