focus-list.cpp 512 B

1234567891011121314151617181920212223
  1. #include "focus-list.hpp"
  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) ||
  14. (currentRow() == count() - 1 && itemRow == -1))
  15. event->ignore();
  16. else
  17. QListWidget::dragMoveEvent(event);
  18. }