CuteLogger
Fast and simple logging solution for Qt based applications
playlisticonview.h
1/*
2 * Copyright (c) 2016-2024 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef SRC_WIDGETS_PLAYLISTICONVIEW_H
19#define SRC_WIDGETS_PLAYLISTICONVIEW_H
20
21#include <QAbstractItemView>
22
23class PlaylistIconView : public QAbstractItemView
24{
25 Q_OBJECT
26public:
27 PlaylistIconView(QWidget *parent);
28 void resetMultiSelect();
29 void setIconRole(int role);
30
31 QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
32 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
33 QModelIndex indexAt(const QPoint &point) const Q_DECL_OVERRIDE;
34 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
35 int horizontalOffset() const Q_DECL_OVERRIDE;
36 int verticalOffset() const Q_DECL_OVERRIDE;
37 bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
38 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
39 QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
40 void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE;
41
42 void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
43 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
44 void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
45 void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
46 void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
47 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
48 void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
49 void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
50 void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
51
52 void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
53 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
54 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
55 const QVector<int> &roles = QVector<int>()) Q_DECL_OVERRIDE;
56
57protected slots:
58 void selectionChanged(const QItemSelection &selected,
59 const QItemSelection &deselected) Q_DECL_OVERRIDE;
60
61private slots:
62 void updateSizes();
63
64private:
65 int rowWidth() const;
66 QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect,
67 const QModelIndex &index) const;
68
69 QSize m_gridSize;
70 QPoint m_draggingOverPos;
71 int m_itemsPerRow;
72 bool m_isToggleSelect {false};
73 bool m_isRangeSelect {false};
74 QModelIndex m_pendingSelect;
75 int m_iconRole;
76};
77
78#endif