KItemViews
kcategorizedview.cpp
67 // will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the
68 // visual rect position of item j will have to be recomputed (cannot use the cached point). The quarantine
70 // that the whole block will have different offset, but items will keep the same relative position
76 // to the block. Because of insertions or removals a whole block can be moved, so the whole block
120 const QString categoryDisplay = representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
124 option.rect.setWidth(viewportWidth() + categoryDrawer->leftMargin() + categoryDrawer->rightMargin());
131 std::pair<QModelIndex, QModelIndex> KCategorizedViewPrivate::intersectingIndexesWithRect(const QRect &_rect) const
217 const QModelIndex lastIndex = proxyModel->index(firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
237 return q->viewport()->width() - categorySpacing * 2 - categoryDrawer->leftMargin() - categoryDrawer->rightMargin();
338 const QModelIndex lastIndex = proxyModel->index(block.firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
341 QModelIndex prevIndex = proxyModel->index(lastIndex.row() - 1, q->modelColumn(), q->rootIndex());
368 const QModelIndex categoryIndex = index.model()->index(index.row(), proxyModel->sortColumn(), index.parent());
372 void KCategorizedViewPrivate::leftToRightVisualRect(const QModelIndex &index, Item &item, const Block &block, const QPoint &blockPos) const
380 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * q->gridSize().width() + blockPos.x() + categoryDrawer->leftMargin();
382 item.topLeft.rx() = viewportWidth() - ((relativeRow % maxItemsPerRow) + 1) * q->gridSize().width() + categoryDrawer->leftMargin() + categorySpacing;
389 const int maxItemsPerRow = qMax((viewportWidth() - q->spacing()) / (itemSize.width() + q->spacing()), 1);
391 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin();
393 item.topLeft.rx() = viewportWidth() - (relativeRow % maxItemsPerRow) * itemSize.width() + categoryDrawer->leftMargin() + categorySpacing;
403 if ((prevRect.bottomRight().x() + 1) + currSize.width() - blockPos.x() + q->spacing() > viewportW) {
422 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
429 item.topLeft.rx() = (prevRect.bottomLeft().x() - 1) - q->spacing() - item.size.width() + categoryDrawer->leftMargin() + categorySpacing;
437 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
446 void KCategorizedViewPrivate::topToBottomVisualRect(const QModelIndex &index, Item &item, const Block &block, const QPoint &blockPos) const
573 const QModelIndex nextIndex = d->proxyModel->index(index.row() + 1, modelColumn(), rootIndex());
590 QRect res(item.topLeft.x() + ((sizeGrid.width() - resultingSize.width()) / 2), item.topLeft.y(), resultingSize.width(), resultingSize.height());
618 disconnect(d->categoryDrawer, SIGNAL(collapseOrExpandClicked(QModelIndex)), this, SLOT(_k_slotCollapseOrExpandClicked(QModelIndex)));
623 connect(d->categoryDrawer, SIGNAL(collapseOrExpandClicked(QModelIndex)), this, SLOT(_k_slotCollapseOrExpandClicked(QModelIndex)));
685 return block(representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString());
768 const std::pair<QModelIndex, QModelIndex> intersecting = d->intersectingIndexesWithRect(viewport()->rect().intersected(event->rect()));
779 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
792 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
815 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
835 option.features |= alternatingRowColors() && alternateItem ? QStyleOptionViewItem::Alternate : QStyleOptionViewItem::None;
837 option.state |= selectionModel()->isSelected(index) ? QStyle::State_Selected : QStyle::State_None;
860 opt.rect = d->mapToViewport(d->rubberBandRect).intersected(viewport()->rect().adjusted(-16, -16, 16, 16));
876 void KCategorizedView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
939 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
945 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
951 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
969 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
992 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1019 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1043 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1080 QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
1101 const QModelIndex previous = d->proxyModel->index(current.row() - 1, modelColumn(), rootIndex());
1127 const bool canMove = current.row() + maxItemsPerRow < block.firstIndex.row() + block.items.count();
1134 const QModelIndex nextIndex = d->proxyModel->index(block.firstIndex.row() + block.items.count(), modelColumn(), rootIndex());
1147 return d->proxyModel->index(nextBlock.firstIndex.row() + currentRelativePos, modelColumn(), rootIndex());
1165 const QModelIndex prevIndex = d->proxyModel->index(block.firstIndex.row() - 1, modelColumn(), rootIndex());
1179 return d->proxyModel->index(prevBlock.firstIndex.row() + prevBlock.items.count() - remainder + currentRelativePos, modelColumn(), rootIndex());
1236 // located under the top most affected category as in quarantine (the block itself, as a whole),
1277 if (!block.items.isEmpty() && start <= block.firstIndex.row() && end >= block.firstIndex.row()) {
1321 * QListView::updateGeometries() has it's own opinion on whether the scrollbars should be visible (valid range) or not
1324 * (the comment above the main block isn't all accurate, layoutChldren is called regardless of the policy)
1326 * As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
1330 * Since the implicit show/hide by the following range setting will cause further resizes if the policy is Qt::ScrollBarAsNeeded
1331 * we keep it static until we're done, then restore the original value and ultimately change the scrollbar visibility ourself.
1333 if (d->isCategorized()) { // important! - otherwise we'd pollute the setting if the view is initially not categorized
1334 setVerticalScrollBarPolicy((verticalP == Qt::ScrollBarAlwaysOn || verticalScrollBar()->isVisibleTo(this)) ? Qt::ScrollBarAlwaysOn
1336 setHorizontalScrollBarPolicy((horizontalP == Qt::ScrollBarAlwaysOn || horizontalScrollBar()->isVisibleTo(this)) ? Qt::ScrollBarAlwaysOn
1379 const int bottomRange = lastItemRect.bottomRight().y() + verticalOffset() - viewport()->height();
1390 // TODO: also consider working with the horizontal scroll bar. since at this level I am not still
1392 // (think how to draw categories), we would have to take care of the horizontal scroll bar too.
1393 // In theory, as KCategorizedView has been designed, there is no need of horizontal scroll bar.
1402 if (verticalP == Qt::ScrollBarAsNeeded && (verticalScrollBar()->isVisibleTo(this) != validRange)) {
1406 if (horizontalP == Qt::ScrollBarAsNeeded && (horizontalScrollBar()->isVisibleTo(this) != validRange)) {
1417 void KCategorizedView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
1437 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
virtual bool event(QEvent *e) override
CE_RubberBand
QScrollBar * verticalScrollBar() const const
QTextStream & right(QTextStream &stream)
void setSize(const QSize &size)
DragSelectingState
minimum
void mouseMoveEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:919
virtual void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
QPoint topLeft() const const
bool isValid() const const
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
virtual void mouseReleaseEvent(QMouseEvent *e) override
QRect visualRect(const QModelIndex &index) const override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:530
virtual int rowCount(const QModelIndex &parent) const const=0
pos
void resizeEvent(QResizeEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:870
QSize size() const const
int & ry()
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:876
virtual void setModel(QAbstractItemModel *model)
rect
QAbstractItemModel * model() const const
QSize sizeHintForIndex(const QModelIndex &index) const const
QSizeF size() const const
void update()
QTextStream & left(QTextStream &stream)
QHash::iterator begin()
void dragLeaveEvent(QDragLeaveEvent *event) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1068
QPoint mapFromGlobal(const QPoint &pos) const const
virtual QSize sizeHint() const const override
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
Q_SCRIPTABLE Q_NOREPLY void start()
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1412
QItemSelectionModel * selectionModel() const const
virtual void leaveEvent(QEvent *event)
LeftToRight
selectionMode
alternatingRowColors
Alternate
void initFrom(const QWidget *widget)
QModelIndex indexAt(const QPoint &point) const override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:688
ScrollBarPolicy
virtual QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
int x() const const
int y() const const
int width() const const
QPoint bottomRight() const const
QAbstractItemDelegate * itemDelegate() const const
bool contains(const QRect &rectangle, bool proper) const const
LeftButton
void setAlternatingBlockColors(bool enable)
Sets whether blocks should be drawn with alternating colors.
Definition: kcategorizedview.cpp:650
virtual void mousePressEvent(QMouseEvent *event) override
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
State_Open
maximum
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1448
void setValue(int)
virtual void dragMoveEvent(QDragMoveEvent *e) override
typedef SelectionFlags
QModelIndexList block(const QString &category)
Definition: kcategorizedview.cpp:665
virtual void dragLeaveEvent(QDragLeaveEvent *e) override
virtual void setVisible(bool visible)
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >()) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1417
QVariant data(int role) const const
bool intersects(const QRect &rectangle) const const
virtual QRect visualRect(const QModelIndex &index) const const override
CursorAction
QAbstractItemView::State state() const const
int top() const const
ItemIsEnabled
void setRange(int min, int max)
horizontalScrollBarPolicy
void mouseReleaseEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:1008
QStyle * style() const const
virtual void dropEvent(QDropEvent *e) override
int height() const const
void setHeight(int height)
virtual void startDrag(Qt::DropActions supportedActions) override
bool isVisibleTo(const QWidget *ancestor) const const
void setModel(QAbstractItemModel *model) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:493
int indexOf(const T &value, int from) const const
modelColumn
ScrollPerItem
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Definition: kcategorydrawer.h:32
void setCategorySpacing(int categorySpacing)
Stablishes the category spacing.
Definition: kcategorizedview.cpp:631
QSize boundedTo(const QSize &otherSize) const const
bool isNull() const const
virtual Qt::ItemFlags flags(const QModelIndex &index) const const
bool isSelected(const QModelIndex &index) const const
SelectionMode
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
KCategoryDrawer * categoryDrawer() const
Returns the current category drawer.
Definition: kcategorizedview.cpp:610
Item view for listing items in a categorized fashion optionally.
Definition: kcategorizedview.h:68
virtual void rowsInsertedArtifficial(const QModelIndex &parent, int start, int end)
Definition: kcategorizedview.cpp:1461
height
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles) override
QModelIndex rootIndex() const const
QPoint pos()
virtual void dragEnterEvent(QDragEnterEvent *event) override
QPoint bottomLeft() const const
bool isValid() const const
QScrollBar * horizontalScrollBar() const const
void setCollapsibleBlocks(bool enable)
Sets whether blocks can be collapsed or not.
Definition: kcategorizedview.cpp:660
virtual void slotLayoutChanged()
Definition: kcategorizedview.cpp:1478
int row() const const
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
void paintEvent(QPaintEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:761
flow
bool isSelectionRectVisible() const const
void setGridSizeOwn(const QSize &size)
Definition: kcategorizedview.cpp:524
void setGridSize(const QSize &size)
virtual int horizontalOffset() const const override
virtual void rowsRemoved(const QModelIndex &parent, int start, int end)
Definition: kcategorizedview.cpp:1470
typedef DropActions
QSize expandedTo(const QSize &otherSize) const const
height
spacing
int height() const const
QPoint topRight() const const
void dropEvent(QDropEvent *event) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1073
void leaveEvent(QEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:1035
virtual QModelIndex indexAt(const QPoint &p) const const override
virtual void paintEvent(QPaintEvent *e) override
Rectangle
LeftToRight
virtual void reset()
virtual void mouseMoveEvent(QMouseEvent *e) override
QRect adjusted(int dx1, int dy1, int dx2, int dy2) const const
void setSingleStep(int)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
void dragMoveEvent(QDragMoveEvent *event) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1057
void startDrag(Qt::DropActions supportedActions) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1052
void restore()
QList::iterator begin()
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1080
QModelIndex parent() const const
ListMode
void save()
void dragEnterEvent(QDragEnterEvent *event) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1063
virtual int verticalOffset() const const override
viewMode
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1193
QModelIndex currentIndex() const const
uniformItemSizes
void setWidth(qreal width)
void mousePressEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:978
QList::iterator end()
typedef KeyboardModifiers
Block
layoutDirection
QWidget * viewport() const const
Category category(StandardShortcut id)
void setLeft(int x)
verticalScrollBarPolicy
size
wordWrap
virtual void updateGeometries() override
QObject * parent() const const
verticalScrollMode
void setHeight(int height)
const QAbstractItemModel * model() const const
const QList< QKeySequence > & end()
@ CategoryDisplayRole
This role is used for asking the category to a given index.
Definition: kcategorizedsortfilterproxymodel.h:41
void setPageStep(int)
width
QRect normalized() const const
void updateGeometries() override
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1313
QString toString() const const
virtual void resizeEvent(QResizeEvent *e) override
void setCategoryDrawer(KCategoryDrawer *categoryDrawer)
The category drawer that will be used for drawing categories.
Definition: kcategorizedview.cpp:615
qreal width() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:17:40 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:17:40 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.