CustomListView.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef CUSTOMLISTVIEW_H
  2. #define CUSTOMLISTVIEW_H
  3. #include <QListView>
  4. #include <QScopedPointer>
  5. class CustomListViewPrivate;
  6. class CustomListView : public QListView
  7. {
  8. Q_OBJECT
  9. Q_DISABLE_COPY(CustomListView)
  10. public:
  11. explicit CustomListView(QWidget *parent = NULL, const bool tansparent = true);
  12. ~CustomListView();
  13. void setCurrentIndex(const QModelIndex &index);
  14. void setItemDelegate(QAbstractItemDelegate *delegate);
  15. void enableLongPress(const bool flag);
  16. protected:
  17. void mousePressEvent(QMouseEvent* event);
  18. void mouseMoveEvent(QMouseEvent* event);
  19. void mouseReleaseEvent(QMouseEvent* event) ;
  20. signals:
  21. void onPressIndexChanged(const QModelIndex &index);
  22. void onCurrentIndexChange(const QModelIndex &index);
  23. void listViewItemRelease(const int index);
  24. void listViewItemLongPress(const int index);
  25. void listViewRelease();
  26. private slots:
  27. void onTimeout();
  28. private:
  29. friend class CustomListViewPrivate;
  30. QScopedPointer<CustomListViewPrivate> m_Private;
  31. };
  32. #endif // CUSTOMLISTVIEW_H