focus-list.cpp 511 B

12345678910111213141516171819202122
  1. #include "moc_focus-list.cpp"
  2. #include <QDragMoveEvent>
  3. FocusList::FocusList(QWidget *parent) : QListWidget(parent) {}
  4. void FocusList::focusInEvent(QFocusEvent *event)
  5. {
  6. QListWidget::focusInEvent(event);
  7. emit GotFocus();
  8. }
  9. void FocusList::dragMoveEvent(QDragMoveEvent *event)
  10. {
  11. QPoint pos = event->position().toPoint();
  12. int itemRow = row(itemAt(pos));
  13. if ((itemRow == currentRow() + 1) || (currentRow() == count() - 1 && itemRow == -1))
  14. event->ignore();
  15. else
  16. QListWidget::dragMoveEvent(event);
  17. }