comparison view/PaneStack.cpp @ 320:984c1975f1ff

* Some tidying up to handling of alignment; add alignment status label to pane; ensure alignment when dragging with mouse as well as when playing
author Chris Cannam
date Thu, 25 Oct 2007 14:32:23 +0000
parents 2a50c1ecc990
children 267586900360
comparison
equal deleted inserted replaced
319:2a50c1ecc990 320:984c1975f1ff
501 { 501 {
502 Pane *pane = dynamic_cast<Pane *>(sender()); 502 Pane *pane = dynamic_cast<Pane *>(sender());
503 emit dropAccepted(pane, text); 503 emit dropAccepted(pane, text);
504 } 504 }
505 505
506 void
507 PaneStack::sizePanesEqually()
508 {
509 QList<int> sizes = m_splitter->sizes();
510 if (sizes.empty()) return;
511
512 int count = sizes.size();
513
514 int total = 0;
515 for (int i = 0; i < count; ++i) {
516 total += sizes[i];
517 }
518
519 if (total == 0) return;
520
521 sizes.clear();
522
523 int each = total / count;
524 int remaining = total;
525
526 for (int i = 0; i < count; ++i) {
527 if (i == count - 1) {
528 sizes.push_back(remaining);
529 } else {
530 sizes.push_back(each);
531 remaining -= each;
532 }
533 }
534
535 /*
536 std::cerr << "sizes: ";
537 for (int i = 0; i < sizes.size(); ++i) {
538 std::cerr << sizes[i] << " ";
539 }
540 std::cerr << std::endl;
541 */
542
543 m_splitter->setSizes(sizes);
544 }
545
546