PrismLauncher/GroupView.h

141 lines
3.3 KiB
C
Raw Normal View History

2014-01-31 21:51:45 +00:00
#pragma once
#include <QListView>
#include <QLineEdit>
2013-12-30 22:39:10 +00:00
struct CategorizedViewRoles
{
enum
{
CategoryRole = Qt::UserRole,
ProgressValueRole,
ProgressMaximumRole
};
};
2014-01-31 21:51:45 +00:00
struct Group;
2013-12-31 16:26:36 +00:00
2014-02-02 09:26:38 +00:00
class GroupView : public QAbstractItemView
{
Q_OBJECT
public:
2014-01-31 21:51:45 +00:00
GroupView(QWidget *parent = 0);
~GroupView();
virtual QRect visualRect(const QModelIndex &index) const;
QModelIndex indexAt(const QPoint &point) const;
2014-01-31 21:51:45 +00:00
void setSelection(const QRect &rect,
const QItemSelectionModel::SelectionFlags commands) override;
2014-02-02 09:26:38 +00:00
/*
* BS
*/
virtual int horizontalOffset() const override
{
return 0;
}
virtual int verticalOffset() const override
{
return 0;
}
virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override
{
return;
}
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
override
{
return QModelIndex();
}
virtual QRegion visualRegionForSelection(const QItemSelection &) const override
{
return QRegion();
}
/*
* End of BS
*/
2014-01-31 21:51:45 +00:00
protected
slots:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QVector<int> &roles);
virtual void rowsInserted(const QModelIndex &parent, int start, int end);
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
virtual void updateGeometries();
protected:
virtual bool isIndexHidden(const QModelIndex &index) const;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
void startDrag(Qt::DropActions supportedActions) override;
private:
2014-01-31 21:51:45 +00:00
friend struct Group;
2014-01-31 21:51:45 +00:00
QList<Group *> m_categories;
int m_leftMargin;
int m_rightMargin;
2013-12-30 17:46:12 +00:00
int m_bottomMargin;
int m_categoryMargin;
2014-01-31 21:51:45 +00:00
// bool m_updatesDisabled;
2014-01-31 21:51:45 +00:00
Group *category(const QModelIndex &index) const;
Group *category(const QString &cat) const;
Group *categoryAt(const QPoint &pos) const;
int itemsPerRow() const;
int contentWidth() const;
private:
int itemWidth() const;
2013-12-31 16:26:36 +00:00
int categoryRowHeight(const QModelIndex &index) const;
/*QLineEdit *m_categoryEditor;
Category *m_editedCategory;
void startCategoryEditor(Category *category);
private slots:
void endCategoryEditor();*/
private:
QPoint m_pressedPosition;
QPersistentModelIndex m_pressedIndex;
bool m_pressedAlreadySelected;
2014-01-31 21:51:45 +00:00
Group *m_pressedCategory;
QItemSelectionModel::SelectionFlag m_ctrlDragSelectionFlag;
QPoint m_lastDragPosition;
QPair<int, int> categoryInternalPosition(const QModelIndex &index) const;
2013-12-31 16:26:36 +00:00
int categoryInternalRowTop(const QModelIndex &index) const;
2014-01-31 21:58:57 +00:00
int itemHeightForCategoryRow(const Group *category, const int internalRow) const;
QPixmap renderToPixmap(const QModelIndexList &indices, QRect *r) const;
2014-01-31 21:51:45 +00:00
QList<QPair<QRect, QModelIndex>> draggablePaintPairs(const QModelIndexList &indices,
QRect *r) const;
bool isDragEventAccepted(QDropEvent *event);
2014-01-31 21:51:45 +00:00
QPair<Group *, int> rowDropPos(const QPoint &pos);
2013-12-30 17:46:12 +00:00
QPoint offset() const;
};