- QGraphicsWidget::mouseMoveEvent(event);
-
- switch (m_roleOperation) {
- case NoRoleOperation:
- if ((event->pos() - m_pressedMousePos).manhattanLength() >= QApplication::startDragDistance()) {
- // A role gets dragged by the user. Create a pixmap of the role that will get
- // synchronized on each furter mouse-move-event with the mouse-position.
- m_roleOperation = MoveRoleOperation;
- const int roleIndex = roleIndexAt(m_pressedMousePos);
- m_movingRole.index = roleIndex;
- if (roleIndex == 0) {
- // TODO: It should be configurable whether moving the first role is allowed.
- // In the context of Dolphin this is not required, however this should be
- // changed if KItemViews are used in a more generic way.
- QApplication::setOverrideCursor(QCursor(Qt::ForbiddenCursor));
- } else {
- m_movingRole.pixmap = createRolePixmap(roleIndex);
-
- qreal roleX = 0;
- for (int i = 0; i < roleIndex; ++i) {
- const QByteArray role = m_visibleRoles[i];
- roleX += m_visibleRolesWidths.value(role);
- }
-
- m_movingRole.xDec = event->pos().x() - roleX;
- m_movingRole.x = roleX;
- update();
- }
- }
- break;
-
- case ResizeRoleOperation: {
- const QByteArray pressedRole = m_visibleRoles[m_pressedRoleIndex];
-
- qreal previousWidth = m_visibleRolesWidths.value(pressedRole);
- qreal currentWidth = previousWidth;
- currentWidth += event->pos().x() - event->lastPos().x();
- currentWidth = qMax(minimumRoleWidth(), currentWidth);
-
- m_visibleRolesWidths.insert(pressedRole, currentWidth);
- update();
-
- emit visibleRoleWidthChanged(pressedRole, currentWidth, previousWidth);
- break;
- }
-
- case MoveRoleOperation: {
- // TODO: It should be configurable whether moving the first role is allowed.
- // In the context of Dolphin this is not required, however this should be
- // changed if KItemViews are used in a more generic way.
- if (m_movingRole.index > 0) {
- m_movingRole.x = event->pos().x() - m_movingRole.xDec;
- update();
-
- const int targetIndex = targetOfMovingRole();
- if (targetIndex > 0 && targetIndex != m_movingRole.index) {
- const QByteArray role = m_visibleRoles[m_movingRole.index];
- const int previousIndex = m_movingRole.index;
- m_movingRole.index = targetIndex;
- emit visibleRoleMoved(role, targetIndex, previousIndex);
-
- m_movingRole.xDec = event->pos().x() - roleXPosition(role);
- }