comparison view/PaneStack.cpp @ 1266:a34a2a25907c

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 36cddc3de023
children d79e21855aef
comparison
equal deleted inserted replaced
1265:6e724c81f18f 1266:a34a2a25907c
129 av->setViewManager(m_viewManager); 129 av->setViewManager(m_viewManager);
130 layout->addWidget(av, 2, 1); 130 layout->addWidget(av, 2, 1);
131 131
132 QWidget *properties = 0; 132 QWidget *properties = 0;
133 if (suppressPropertyBox) { 133 if (suppressPropertyBox) {
134 properties = new QFrame(); 134 properties = new QFrame();
135 } else { 135 } else {
136 properties = new PropertyStack(frame, pane); 136 properties = new PropertyStack(frame, pane);
137 connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), 137 connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)),
138 this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); 138 this, SLOT(propertyContainerSelected(View *, PropertyContainer *)));
139 connect(properties, SIGNAL(viewSelected(View *)), 139 connect(properties, SIGNAL(viewSelected(View *)),
140 this, SLOT(viewSelected(View *))); 140 this, SLOT(viewSelected(View *)));
141 connect(properties, SIGNAL(contextHelpChanged(const QString &)), 141 connect(properties, SIGNAL(contextHelpChanged(const QString &)),
142 this, SIGNAL(contextHelpChanged(const QString &))); 142 this, SIGNAL(contextHelpChanged(const QString &)));
143 } 143 }
161 161
162 frame->setLayout(layout); 162 frame->setLayout(layout);
163 m_splitter->insertWidget(index, frame); 163 m_splitter->insertWidget(index, frame);
164 164
165 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), 165 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)),
166 this, SLOT(propertyContainerAdded(PropertyContainer *))); 166 this, SLOT(propertyContainerAdded(PropertyContainer *)));
167 connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)), 167 connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)),
168 this, SLOT(propertyContainerRemoved(PropertyContainer *))); 168 this, SLOT(propertyContainerRemoved(PropertyContainer *)));
169 connect(pane, SIGNAL(paneInteractedWith()), 169 connect(pane, SIGNAL(paneInteractedWith()),
170 this, SLOT(paneInteractedWith())); 170 this, SLOT(paneInteractedWith()));
171 connect(pane, SIGNAL(rightButtonMenuRequested(QPoint)), 171 connect(pane, SIGNAL(rightButtonMenuRequested(QPoint)),
172 this, SLOT(rightButtonMenuRequested(QPoint))); 172 this, SLOT(rightButtonMenuRequested(QPoint)));
173 connect(pane, SIGNAL(dropAccepted(QStringList)), 173 connect(pane, SIGNAL(dropAccepted(QStringList)),
174 this, SLOT(paneDropAccepted(QStringList))); 174 this, SLOT(paneDropAccepted(QStringList)));
175 connect(pane, SIGNAL(dropAccepted(QString)), 175 connect(pane, SIGNAL(dropAccepted(QString)),
179 179
180 emit paneAdded(pane); 180 emit paneAdded(pane);
181 emit paneAdded(); 181 emit paneAdded();
182 182
183 if (!m_currentPane) { 183 if (!m_currentPane) {
184 setCurrentPane(pane); 184 setCurrentPane(pane);
185 } 185 }
186 186
187 showOrHidePaneAccessories(); 187 showOrHidePaneAccessories();
188 relinkAlignmentViews(); 188 relinkAlignmentViews();
189 189
292 bool found = false; 292 bool found = false;
293 293
294 QWidget *stack = 0; 294 QWidget *stack = 0;
295 295
296 for (i = m_panes.begin(); i != m_panes.end(); ++i) { 296 for (i = m_panes.begin(); i != m_panes.end(); ++i) {
297 if (i->pane == pane) { 297 if (i->pane == pane) {
298 stack = i->propertyStack; 298 stack = i->propertyStack;
299 m_panes.erase(i); 299 m_panes.erase(i);
300 found = true; 300 found = true;
301 break; 301 break;
302 } 302 }
303 } 303 }
304 304
305 if (!found) { 305 if (!found) {
306 306
307 for (i = m_hiddenPanes.begin(); i != m_hiddenPanes.end(); ++i) { 307 for (i = m_hiddenPanes.begin(); i != m_hiddenPanes.end(); ++i) {
308 if (i->pane == pane) { 308 if (i->pane == pane) {
309 stack = i->propertyStack; 309 stack = i->propertyStack;
310 m_hiddenPanes.erase(i); 310 m_hiddenPanes.erase(i);
311 found = true; 311 found = true;
312 break; 312 break;
313 } 313 }
314 } 314 }
315 315
316 if (!found) { 316 if (!found) {
317 cerr << "WARNING: PaneStack::deletePane(" << pane << "): Pane not found in visible or hidden panes, not deleting" << endl; 317 cerr << "WARNING: PaneStack::deletePane(" << pane << "): Pane not found in visible or hidden panes, not deleting" << endl;
318 return; 318 return;
319 } 319 }
320 } 320 }
321 321
322 emit paneAboutToBeDeleted(pane); 322 emit paneAboutToBeDeleted(pane);
323 unlinkAlignmentViews(); 323 unlinkAlignmentViews();
324 324
335 delete stack; 335 delete stack;
336 336
337 delete pane->parent(); 337 delete pane->parent();
338 338
339 if (m_currentPane == pane) { 339 if (m_currentPane == pane) {
340 if (m_panes.size() > 0) { 340 if (m_panes.size() > 0) {
341 setCurrentPane(m_panes[0].pane); 341 setCurrentPane(m_panes[0].pane);
342 } else { 342 } else {
343 setCurrentPane(0); 343 setCurrentPane(0);
344 } 344 }
345 } 345 }
346 346
347 showOrHidePaneAccessories(); 347 showOrHidePaneAccessories();
348 relinkAlignmentViews(); 348 relinkAlignmentViews();
349 349
379 PaneStack::hidePane(Pane *pane) 379 PaneStack::hidePane(Pane *pane)
380 { 380 {
381 std::vector<PaneRec>::iterator i = m_panes.begin(); 381 std::vector<PaneRec>::iterator i = m_panes.begin();
382 382
383 while (i != m_panes.end()) { 383 while (i != m_panes.end()) {
384 if (i->pane == pane) { 384 if (i->pane == pane) {
385 385
386 m_hiddenPanes.push_back(*i); 386 m_hiddenPanes.push_back(*i);
387 m_panes.erase(i); 387 m_panes.erase(i);
388 388
389 QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); 389 QWidget *pw = dynamic_cast<QWidget *>(pane->parent());
390 if (pw) pw->hide(); 390 if (pw) pw->hide();
391 391
392 if (m_currentPane == pane) { 392 if (m_currentPane == pane) {
393 if (m_panes.size() > 0) { 393 if (m_panes.size() > 0) {
394 setCurrentPane(m_panes[0].pane); 394 setCurrentPane(m_panes[0].pane);
395 } else { 395 } else {
396 setCurrentPane(0); 396 setCurrentPane(0);
397 } 397 }
398 } 398 }
399 399
400 showOrHidePaneAccessories(); 400 showOrHidePaneAccessories();
401 emit paneHidden(pane); 401 emit paneHidden(pane);
402 emit paneHidden(); 402 emit paneHidden();
403 return; 403 return;
404 } 404 }
405 ++i; 405 ++i;
406 } 406 }
407 407
408 relinkAlignmentViews(); 408 relinkAlignmentViews();
409 409
410 cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << endl; 410 cerr << "WARNING: PaneStack::hidePane(" << pane << "): Pane not found in visible panes" << endl;
414 PaneStack::showPane(Pane *pane) 414 PaneStack::showPane(Pane *pane)
415 { 415 {
416 std::vector<PaneRec>::iterator i = m_hiddenPanes.begin(); 416 std::vector<PaneRec>::iterator i = m_hiddenPanes.begin();
417 417
418 while (i != m_hiddenPanes.end()) { 418 while (i != m_hiddenPanes.end()) {
419 if (i->pane == pane) { 419 if (i->pane == pane) {
420 m_panes.push_back(*i); 420 m_panes.push_back(*i);
421 m_hiddenPanes.erase(i); 421 m_hiddenPanes.erase(i);
422 QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); 422 QWidget *pw = dynamic_cast<QWidget *>(pane->parent());
423 if (pw) pw->show(); 423 if (pw) pw->show();
424 424
425 //!!! update current pane 425 //!!! update current pane
426 426
427 showOrHidePaneAccessories(); 427 showOrHidePaneAccessories();
428 428
429 return; 429 return;
430 } 430 }
431 ++i; 431 ++i;
432 } 432 }
433 433
434 relinkAlignmentViews(); 434 relinkAlignmentViews();
435 435
436 cerr << "WARNING: PaneStack::showPane(" << pane << "): Pane not found in hidden panes" << endl; 436 cerr << "WARNING: PaneStack::showPane(" << pane << "): Pane not found in hidden panes" << endl;
454 unselectedMap.fill(QApplication::palette().color(QPalette::Background)); 454 unselectedMap.fill(QApplication::palette().color(QPalette::Background));
455 455
456 bool found = false; 456 bool found = false;
457 457
458 while (i != m_panes.end()) { 458 while (i != m_panes.end()) {
459 if (i->pane == pane) { 459 if (i->pane == pane) {
460 i->currentIndicator->setPixmap(selectedMap); 460 i->currentIndicator->setPixmap(selectedMap);
461 if (m_layoutStyle != PropertyStackPerPaneLayout) { 461 if (m_layoutStyle != PropertyStackPerPaneLayout) {
462 m_propertyStackStack->setCurrentWidget(i->propertyStack); 462 m_propertyStackStack->setCurrentWidget(i->propertyStack);
463 } 463 }
464 found = true; 464 found = true;
465 } else { 465 } else {
466 i->currentIndicator->setPixmap(unselectedMap); 466 i->currentIndicator->setPixmap(unselectedMap);
467 } 467 }
468 ++i; 468 ++i;
469 } 469 }
470 470
471 if (found || pane == 0) { 471 if (found || pane == 0) {
472 m_currentPane = pane; 472 m_currentPane = pane;
473 emit currentPaneChanged(m_currentPane); 473 emit currentPaneChanged(m_currentPane);
474 } else { 474 } else {
475 cerr << "WARNING: PaneStack::setCurrentPane(" << pane << "): pane is not a visible pane in this stack" << endl; 475 cerr << "WARNING: PaneStack::setCurrentPane(" << pane << "): pane is not a visible pane in this stack" << endl;
476 } 476 }
477 } 477 }
478 478
479 void 479 void
480 PaneStack::setCurrentLayer(Pane *pane, Layer *layer) // may be null 480 PaneStack::setCurrentLayer(Pane *pane, Layer *layer) // may be null
481 { 481 {
482 setCurrentPane(pane); 482 setCurrentPane(pane);
483 483
484 if (m_currentPane) { 484 if (m_currentPane) {
485 485
486 std::vector<PaneRec>::iterator i = m_panes.begin(); 486 std::vector<PaneRec>::iterator i = m_panes.begin();
487 487
488 while (i != m_panes.end()) { 488 while (i != m_panes.end()) {
489 489
490 if (i->pane == pane) { 490 if (i->pane == pane) {
491 PropertyStack *stack = dynamic_cast<PropertyStack *> 491 PropertyStack *stack = dynamic_cast<PropertyStack *>
492 (i->propertyStack); 492 (i->propertyStack);
493 if (stack) { 493 if (stack) {
494 if (stack->containsContainer(layer)) { 494 if (stack->containsContainer(layer)) {
495 stack->setCurrentIndex(stack->getContainerIndex(layer)); 495 stack->setCurrentIndex(stack->getContainerIndex(layer));
496 emit currentLayerChanged(pane, layer); 496 emit currentLayerChanged(pane, layer);
497 } else { 497 } else {
498 stack->setCurrentIndex 498 stack->setCurrentIndex
499 (stack->getContainerIndex 499 (stack->getContainerIndex
500 (pane->getPropertyContainer(0))); 500 (pane->getPropertyContainer(0)));
501 emit currentLayerChanged(pane, 0); 501 emit currentLayerChanged(pane, 0);
502 } 502 }
503 } 503 }
504 break; 504 break;
505 } 505 }
506 ++i; 506 ++i;
507 } 507 }
508 } 508 }
509 } 509 }
510 510
511 Pane * 511 Pane *
512 PaneStack::getCurrentPane() 512 PaneStack::getCurrentPane()
530 PaneStack::propertyContainerSelected(View *client, PropertyContainer *pc) 530 PaneStack::propertyContainerSelected(View *client, PropertyContainer *pc)
531 { 531 {
532 std::vector<PaneRec>::iterator i = m_panes.begin(); 532 std::vector<PaneRec>::iterator i = m_panes.begin();
533 533
534 while (i != m_panes.end()) { 534 while (i != m_panes.end()) {
535 PropertyStack *stack = dynamic_cast<PropertyStack *>(i->propertyStack); 535 PropertyStack *stack = dynamic_cast<PropertyStack *>(i->propertyStack);
536 if (stack && 536 if (stack &&
537 stack->getClient() == client && 537 stack->getClient() == client &&
538 stack->containsContainer(pc)) { 538 stack->containsContainer(pc)) {
539 setCurrentPane(i->pane); 539 setCurrentPane(i->pane);
540 break; 540 break;
541 } 541 }
542 ++i; 542 ++i;
543 } 543 }
544 544
545 Layer *layer = dynamic_cast<Layer *>(pc); 545 Layer *layer = dynamic_cast<Layer *>(pc);
546 if (layer) emit currentLayerChanged(m_currentPane, layer); 546 if (layer) emit currentLayerChanged(m_currentPane, layer);
547 else emit currentLayerChanged(m_currentPane, 0); 547 else emit currentLayerChanged(m_currentPane, 0);
576 int maxMinWidth = 0; 576 int maxMinWidth = 0;
577 577
578 if (m_propertyStackMinWidth > 0) maxMinWidth = m_propertyStackMinWidth; 578 if (m_propertyStackMinWidth > 0) maxMinWidth = m_propertyStackMinWidth;
579 579
580 for (int i = 0; i < (int)m_panes.size(); ++i) { 580 for (int i = 0; i < (int)m_panes.size(); ++i) {
581 if (!m_panes[i].propertyStack) continue; 581 if (!m_panes[i].propertyStack) continue;
582 #ifdef DEBUG_PANE_STACK 582 #ifdef DEBUG_PANE_STACK
583 SVDEBUG << "PaneStack::sizePropertyStacks: " << i << ": min " 583 SVDEBUG << "PaneStack::sizePropertyStacks: " << i << ": min "
584 << m_panes[i].propertyStack->minimumSizeHint().width() << ", hint " 584 << m_panes[i].propertyStack->minimumSizeHint().width() << ", hint "
585 << m_panes[i].propertyStack->sizeHint().width() << ", current " 585 << m_panes[i].propertyStack->sizeHint().width() << ", current "
586 << m_panes[i].propertyStack->width() << endl; 586 << m_panes[i].propertyStack->width() << endl;
587 #endif 587 #endif
588 588
589 if (m_panes[i].propertyStack->sizeHint().width() > maxMinWidth) { 589 if (m_panes[i].propertyStack->sizeHint().width() > maxMinWidth) {
590 maxMinWidth = m_panes[i].propertyStack->sizeHint().width(); 590 maxMinWidth = m_panes[i].propertyStack->sizeHint().width();
591 } 591 }
592 } 592 }
593 593
594 #ifdef DEBUG_PANE_STACK 594 #ifdef DEBUG_PANE_STACK
595 SVDEBUG << "PaneStack::sizePropertyStacks: max min width " << maxMinWidth << endl; 595 SVDEBUG << "PaneStack::sizePropertyStacks: max min width " << maxMinWidth << endl;
596 #endif 596 #endif
598 int setWidth = maxMinWidth; 598 int setWidth = maxMinWidth;
599 599
600 m_propertyStackStack->setMaximumWidth(setWidth + 10); 600 m_propertyStackStack->setMaximumWidth(setWidth + 10);
601 601
602 for (int i = 0; i < (int)m_panes.size(); ++i) { 602 for (int i = 0; i < (int)m_panes.size(); ++i) {
603 if (!m_panes[i].propertyStack) continue; 603 if (!m_panes[i].propertyStack) continue;
604 m_panes[i].propertyStack->setMinimumWidth(setWidth); 604 m_panes[i].propertyStack->setMinimumWidth(setWidth);
605 } 605 }
606 606
607 emit propertyStacksResized(setWidth); 607 emit propertyStacksResized(setWidth);
608 emit propertyStacksResized(); 608 emit propertyStacksResized();
609 } 609 }
625 void 625 void
626 PaneStack::paneDeleteButtonClicked() 626 PaneStack::paneDeleteButtonClicked()
627 { 627 {
628 QObject *s = sender(); 628 QObject *s = sender();
629 for (int i = 0; i < (int)m_panes.size(); ++i) { 629 for (int i = 0; i < (int)m_panes.size(); ++i) {
630 if (m_panes[i].xButton == s) { 630 if (m_panes[i].xButton == s) {
631 emit paneDeleteButtonClicked(m_panes[i].pane); 631 emit paneDeleteButtonClicked(m_panes[i].pane);
632 } 632 }
633 } 633 }
634 } 634 }
635 635
637 PaneStack::indicatorClicked() 637 PaneStack::indicatorClicked()
638 { 638 {
639 QObject *s = sender(); 639 QObject *s = sender();
640 640
641 for (int i = 0; i < (int)m_panes.size(); ++i) { 641 for (int i = 0; i < (int)m_panes.size(); ++i) {
642 if (m_panes[i].currentIndicator == s) { 642 if (m_panes[i].currentIndicator == s) {
643 setCurrentPane(m_panes[i].pane); 643 setCurrentPane(m_panes[i].pane);
644 return; 644 return;
645 } 645 }
646 } 646 }
647 } 647 }