comparison view/Pane.cpp @ 753:09e2677e34e7 tonioni

Fix fancy note-editing mode (was not working in new multi-layer world, and shift-click delete was broken)
author Chris Cannam
date Tue, 01 Apr 2014 21:18:31 +0100
parents f831ca41d4a5
children 9cfcb2924ee3 785c6f175ccc
comparison
equal deleted inserted replaced
752:f428bd852580 753:09e2677e34e7
342 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) { 342 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) {
343 return false; 343 return false;
344 } 344 }
345 345
346 if (layer == getSelectedLayer() && 346 if (layer == getSelectedLayer() &&
347 !shouldIlluminateLocalSelection(discard, b0, b1)) { 347 !shouldIlluminateLocalSelection(discard, b0, b1)) {
348 348
349 pos = m_identifyPoint; 349 pos = m_identifyPoint;
350 return m_identifyFeatures; 350 return m_identifyFeatures;
351 } 351 }
352 352
353 return false; 353 return false;
354 } 354 }
355 355
362 m_manager && 362 m_manager &&
363 m_manager->getToolModeFor(this) == ViewManager::EditMode && 363 m_manager->getToolModeFor(this) == ViewManager::EditMode &&
364 !m_manager->getSelections().empty() && 364 !m_manager->getSelections().empty() &&
365 !selectionIsBeingEdited()) { 365 !selectionIsBeingEdited()) {
366 366
367 Selection s(getSelectionAt(m_identifyPoint.x(), 367 Selection s(getSelectionAt(m_identifyPoint.x(),
368 closeToLeft, closeToRight)); 368 closeToLeft, closeToRight));
369 369
370 if (!s.isEmpty()) { 370 if (!s.isEmpty()) {
371 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) { 371 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
372 372
373 pos = m_identifyPoint; 373 pos = m_identifyPoint;
374 return true; 374 return true;
375 } 375 }
376 } 376 }
377 } 377 }
378 378
379 return false; 379 return false;
380 } 380 }
381 381
1274 tr("Click left button and drag to measure extents of an item or shape")); 1274 tr("Click left button and drag to measure extents of an item or shape"));
1275 kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"), 1275 kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"),
1276 tr("Shift-click left button and drag to zoom to a rectangular area")); 1276 tr("Shift-click left button and drag to zoom to a rectangular area"));
1277 } 1277 }
1278 1278
1279 Layer *
1280 Pane::getTopFlexiNoteLayer()
1281 {
1282 for (int i = int(m_layers.size()) - 1; i >= 0; --i) {
1283 if (LayerFactory::getInstance()->getLayerType(m_layers[i]) ==
1284 LayerFactory::FlexiNotes) {
1285 return m_layers[i];
1286 }
1287 }
1288 return 0;
1289 }
1290
1279 void 1291 void
1280 Pane::mousePressEvent(QMouseEvent *e) 1292 Pane::mousePressEvent(QMouseEvent *e)
1281 { 1293 {
1282 if (e->buttons() & Qt::RightButton) { 1294 if (e->buttons() & Qt::RightButton) {
1283 emit contextHelpChanged(""); 1295 emit contextHelpChanged("");
1385 1397
1386 // GF: handle mouse press for NoteEditMode 1398 // GF: handle mouse press for NoteEditMode
1387 } else if (mode == ViewManager::NoteEditMode) { 1399 } else if (mode == ViewManager::NoteEditMode) {
1388 1400
1389 std::cerr << "mouse pressed in note edit mode" << std::endl; 1401 std::cerr << "mouse pressed in note edit mode" << std::endl;
1390 Layer *layer = getSelectedLayer(); 1402 Layer *layer = getTopFlexiNoteLayer();
1391 if (layer && layer->isLayerEditable()) { 1403 if (layer) {
1392 layer->splitStart(this, e); 1404 layer->splitStart(this, e);
1393 } 1405 }
1394 1406
1395 } else if (mode == ViewManager::EditMode) { 1407 } else if (mode == ViewManager::EditMode) {
1396 1408
1500 } 1512 }
1501 1513
1502 } else if (mode == ViewManager::NoteEditMode) { 1514 } else if (mode == ViewManager::NoteEditMode) {
1503 1515
1504 //GF: handle mouse release for NoteEditMode (note: works but will need to re-think this a bit later) 1516 //GF: handle mouse release for NoteEditMode (note: works but will need to re-think this a bit later)
1505 Layer *layer = getSelectedLayer(); 1517 Layer *layer = getTopFlexiNoteLayer();
1506 if (layer && layer->isLayerEditable()) { 1518
1519 if (layer) {
1507 layer->splitEnd(this, e); 1520 layer->splitEnd(this, e);
1508 update(); } 1521 update();
1509 1522
1523 if (m_editing) {
1524 if (!editSelectionEnd(e)) {
1525 layer->editEnd(this, e);
1526 update();
1527 }
1528 }
1529 }
1530
1531 } else if (mode == ViewManager::EditMode) {
1532
1510 if (m_editing) { 1533 if (m_editing) {
1511 if (!editSelectionEnd(e)) { 1534 if (!editSelectionEnd(e)) {
1512 Layer *layer = getSelectedLayer(); 1535 Layer *layer = getSelectedLayer();
1513 if (layer && layer->isLayerEditable()) { 1536 if (layer && layer->isLayerEditable()) {
1514 layer->editEnd(this, e); 1537 layer->editEnd(this, e);
1515 update(); 1538 update();
1516 } 1539 }
1517 } 1540 }
1518 } 1541 }
1519 1542
1520 } else if (mode == ViewManager::EditMode) {
1521
1522 // GF: edited this previously, but restored to original state
1523 if (m_editing) {
1524 if (!editSelectionEnd(e)) {
1525 Layer *layer = getSelectedLayer();
1526 if (layer && layer->isLayerEditable()) {
1527 layer->editEnd(this, e);
1528 update();
1529 }
1530 }
1531 }
1532
1533 } else if (mode == ViewManager::MeasureMode) { 1543 } else if (mode == ViewManager::MeasureMode) {
1534 1544
1535 Layer *layer = getTopLayer(); 1545 Layer *layer = getTopLayer();
1536 if (layer) layer->measureEnd(this, e); 1546 if (layer) layer->measureEnd(this, e);
1537 if (m_measureCursor1) setCursor(*m_measureCursor1); 1547 if (m_measureCursor1) setCursor(*m_measureCursor1);
1578 1588
1579 if (!m_clickedInRange) { 1589 if (!m_clickedInRange) {
1580 1590
1581 // GF: handle mouse move for context sensitive cursor switching in NoteEditMode. 1591 // GF: handle mouse move for context sensitive cursor switching in NoteEditMode.
1582 // GF: Propagate the event to FlexiNoteLayer. I somehow feel it's best handeled there rather than here, but perhaps not if this will be needed elsewhere too. 1592 // GF: Propagate the event to FlexiNoteLayer. I somehow feel it's best handeled there rather than here, but perhaps not if this will be needed elsewhere too.
1583 if (mode == ViewManager::NoteEditMode && LayerFactory::getInstance()->getLayerType(getTopLayer()) == LayerFactory::FlexiNotes) { 1593 if (mode == ViewManager::NoteEditMode) {
1584 1594 FlexiNoteLayer *layer = qobject_cast<FlexiNoteLayer *>(getTopFlexiNoteLayer());
1585 dynamic_cast<FlexiNoteLayer *>(getTopLayer())->mouseMoveEvent(this, e); 1595 if (layer) {
1586 1596 layer->mouseMoveEvent(this, e); //!!! ew
1597 return;
1598 }
1587 } 1599 }
1588 1600
1589 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { 1601 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) {
1590 bool closeToLeft = false, closeToRight = false; 1602 bool closeToLeft = false, closeToRight = false;
1591 getSelectionAt(e->x(), closeToLeft, closeToRight); 1603 getSelectionAt(e->x(), closeToLeft, closeToRight);
1690 Qt::NoButton, 1702 Qt::NoButton,
1691 e->buttons(), 1703 e->buttons(),
1692 e->modifiers()); 1704 e->modifiers());
1693 1705
1694 if (!editSelectionStart(&clickEvent)) { 1706 if (!editSelectionStart(&clickEvent)) {
1695 Layer *layer = getSelectedLayer(); 1707 Layer *layer = getTopFlexiNoteLayer();
1696 if (layer && layer->isLayerEditable()) { 1708 if (layer) {
1697 std::cerr << "calling edit start" << std::endl; 1709 std::cerr << "calling edit start" << std::endl;
1698 layer->editStart(this, &clickEvent); 1710 layer->editStart(this, &clickEvent);
1699 } 1711 }
1700 } 1712 }
1701 } 1713 }