void PlayListHeaderModel::move(int from, int to) { if(from < 0 || from >= m_columns.size()) { qWarning("ColumnManager: index is out of range"); return; } if(to < 0 || to >= m_columns.size()) { qWarning("ColumnManager: index is out of range"); return; } m_columns.move(from, to); emit columnMoved(from, to); emit headerChanged(); updatePlayLists(); }
int QTreeView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractItemView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: expanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 1: collapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 2: hideColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: showColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: expand((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 5: collapse((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 6: resizeColumnToContents((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: sortByColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 8: expandAll(); break; case 9: collapseAll(); break; case 10: expandToDepth((*reinterpret_cast< int(*)>(_a[1]))); break; case 11: columnResized((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 12: columnCountChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 13: columnMoved(); break; case 14: reexpand(); break; case 15: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 16: d_func()->_q_endAnimatedOperation(); break; case 17: d_func()->_q_modelAboutToBeReset(); break; case 18: d_func()->_q_sortIndicatorChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Qt::SortOrder(*)>(_a[2]))); break; default: ; } _id -= 19; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = autoExpandDelay(); break; case 1: *reinterpret_cast< int*>(_v) = indentation(); break; case 2: *reinterpret_cast< bool*>(_v) = rootIsDecorated(); break; case 3: *reinterpret_cast< bool*>(_v) = uniformRowHeights(); break; case 4: *reinterpret_cast< bool*>(_v) = itemsExpandable(); break; case 5: *reinterpret_cast< bool*>(_v) = isSortingEnabled(); break; case 6: *reinterpret_cast< bool*>(_v) = isAnimated(); break; case 7: *reinterpret_cast< bool*>(_v) = allColumnsShowFocus(); break; case 8: *reinterpret_cast< bool*>(_v) = wordWrap(); break; case 9: *reinterpret_cast< bool*>(_v) = isHeaderHidden(); break; case 10: *reinterpret_cast< bool*>(_v) = expandsOnDoubleClick(); break; } _id -= 11; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAutoExpandDelay(*reinterpret_cast< int*>(_v)); break; case 1: setIndentation(*reinterpret_cast< int*>(_v)); break; case 2: setRootIsDecorated(*reinterpret_cast< bool*>(_v)); break; case 3: setUniformRowHeights(*reinterpret_cast< bool*>(_v)); break; case 4: setItemsExpandable(*reinterpret_cast< bool*>(_v)); break; case 5: setSortingEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setAnimated(*reinterpret_cast< bool*>(_v)); break; case 7: setAllColumnsShowFocus(*reinterpret_cast< bool*>(_v)); break; case 8: setWordWrap(*reinterpret_cast< bool*>(_v)); break; case 9: setHeaderHidden(*reinterpret_cast< bool*>(_v)); break; case 10: setExpandsOnDoubleClick(*reinterpret_cast< bool*>(_v)); break; } _id -= 11; } else if (_c == QMetaObject::ResetProperty) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 11; } #endif // QT_NO_PROPERTIES return _id; }
void KItemListHeaderWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { 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 = -m_offset; for (int i = 0; i < roleIndex; ++i) { const QByteArray role = m_columns[i]; roleX += m_columnWidths.value(role); } m_movingRole.xDec = event->pos().x() - roleX; m_movingRole.x = roleX; update(); } } break; case ResizeRoleOperation: { const QByteArray pressedRole = m_columns[m_pressedRoleIndex]; qreal previousWidth = m_columnWidths.value(pressedRole); qreal currentWidth = previousWidth; currentWidth += event->pos().x() - event->lastPos().x(); currentWidth = qMax(minimumColumnWidth(), currentWidth); m_columnWidths.insert(pressedRole, currentWidth); update(); emit columnWidthChanged(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_columns[m_movingRole.index]; const int previousIndex = m_movingRole.index; m_movingRole.index = targetIndex; emit columnMoved(role, targetIndex, previousIndex); m_movingRole.xDec = event->pos().x() - roleXPosition(role); } } break; } default: break; } }