kDebug() << "mousePressEvent STARTED";
m_menuPosition = QPoint();
m_blockRefresh = true;
+ m_dragItem = NULL;
+ m_dragGuide = NULL;
bool collision = false;
if (m_tool != RAZORTOOL) activateMonitor();
return;
}
- if (event->button() == Qt::LeftButton && collisionList.count() == 1 && collisionList.at(0)->type() == GUIDEITEM) {
- // a guide item was pressed
- collisionList.at(0)->setFlag(QGraphicsItem::ItemIsMovable, true);
- m_dragItem = NULL;
- m_dragGuide = (Guide *) collisionList.at(0);
- collision = true;
- m_operationMode = MOVEGUIDE;
- // deselect all clips so that only the guide will move
- m_scene->clearSelection();
- resetSelectionGroup();
- updateSnapPoints(NULL);
- QGraphicsView::mousePressEvent(event);
- return;
+ // if a guide and a clip were pressed, just select the guide
+ for (int i = 0; i < collisionList.count(); ++i) {
+ if (collisionList.at(i)->type() == GUIDEITEM) {
+ // a guide item was pressed
+ m_dragGuide = (Guide *) collisionList.at(i);
+ if (event->button() == Qt::LeftButton) { // move it
+ m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
+ collision = true;
+ m_operationMode = MOVEGUIDE;
+ // deselect all clips so that only the guide will move
+ m_scene->clearSelection();
+ resetSelectionGroup(false);
+ updateSnapPoints(NULL);
+ QGraphicsView::mousePressEvent(event);
+ return;
+ } else // show context menu
+ break;
+ }
}
- // Find first clip, transition or group under mouse
+ // Find first clip, transition or group under mouse (when no guides selected)
int ct = 0;
- m_dragItem = NULL;
AbstractGroupItem *dragGroup = NULL;
- while (ct < collisionList.count()) {
+ while (!m_dragGuide && ct < collisionList.count()) {
if (collisionList.at(ct)->type() == AVWIDGET || collisionList.at(ct)->type() == TRANSITIONWIDGET) {
m_dragItem = static_cast <AbstractClipItem *>(collisionList.at(ct));
m_dragItemInfo = m_dragItem->info();
// context menu requested
if (event->button() == Qt::RightButton) {
- m_dragGuide = NULL;
if (m_dragItem) {
if (dragGroup) dragGroup->setSelected(true);
else if (!m_dragItem->isSelected()) {
m_scene->clearSelection();
m_dragItem->setSelected(true);
}
- }
-
- // check if there is a guide close to mouse click
- QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 1);
- for (int i = 0; i < guidesCollisionList.count(); i++) {
- if (guidesCollisionList.at(0)->type() != GUIDEITEM)
+ } else if (!m_dragGuide) {
+ // check if there is a guide close to mouse click
+ QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 2); // a rect of height < 2 does not always collide with the guide
+ for (int i = 0; i < guidesCollisionList.count(); i++) {
+ if (guidesCollisionList.at(i)->type() == GUIDEITEM) {
+ m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(i));
+ break;
+ }
+ }
+ // keep this to support multiple guides context menu in the future (?)
+ /*if (guidesCollisionList.at(0)->type() != GUIDEITEM)
guidesCollisionList.removeAt(0);
+ }
+ if (!guidesCollisionList.isEmpty())
+ m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(0));*/
}
- if (!guidesCollisionList.isEmpty())
- m_dragGuide = static_cast <Guide *>(guidesCollisionList.at(0));
+
m_operationMode = NONE;
displayContextMenu(event->globalPos(), m_dragItem, dragGroup);
m_menuPosition = m_clickEvent;
if (m_dragItem->type() == AVWIDGET && !m_dragItem->isItemLocked()) emit clipItemSelected((ClipItem*) m_dragItem);
else emit clipItemSelected(NULL);
- if (event->modifiers() != Qt::ControlModifier && (m_dragItem->isSelected() || (dragGroup && dragGroup->isSelected()))) {
- // If clicked item is selected, allow move
- if (dragGroup) dragGroup->setSelected(true);
- //event->accept();
- if (m_operationMode == NONE) QGraphicsView::mousePressEvent(event);
- } else {
+ if (event->modifiers() == Qt::ControlModifier || !(m_dragItem->isSelected() || (dragGroup && dragGroup->isSelected()))) {
resetSelectionGroup();
if (event->modifiers() != Qt::ControlModifier) m_scene->clearSelection();
dragGroup = NULL;
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
}
+ // If clicked item is selected, allow move
+ //event->accept();
+ if (event->modifiers() != Qt::ControlModifier && (m_dragItem->isSelected() || (dragGroup && dragGroup->isSelected())) && m_operationMode == NONE) QGraphicsView::mousePressEvent(event);
+
m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
{
for (int i = 0; i < m_guides.count(); i++) {
int guidePos = m_guides.at(i)->position().frames(m_document->fps());
- if (qAbs(guidePos - pos) < offset) return guidePos;
+ if (qAbs(guidePos - pos) <= offset) return guidePos;
else if (guidePos > pos) return -1;
}
return -1;