KItemViews
kcategorizedview.cpp
69 // will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the
70 // visual rect position of item j will have to be recomputed (cannot use the cached point). The quarantine
72 // that the whole block will have different offset, but items will keep the same relative position
78 // to the block. Because of insertions or removals a whole block can be moved, so the whole block
118 const QString categoryDisplay = representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
122 option.rect.setWidth(viewportWidth() + categoryDrawer->leftMargin() + categoryDrawer->rightMargin());
129std::pair<QModelIndex, QModelIndex> KCategorizedViewPrivate::intersectingIndexesWithRect(const QRect &_rect) const
215 const QModelIndex lastIndex = proxyModel->index(firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
235 return q->viewport()->width() - categorySpacing * 2 - categoryDrawer->leftMargin() - categoryDrawer->rightMargin();
336 const QModelIndex lastIndex = proxyModel->index(block.firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
339 QModelIndex prevIndex = proxyModel->index(lastIndex.row() - 1, q->modelColumn(), q->rootIndex());
372 const QModelIndex categoryIndex = indexModel->index(index.row(), proxyModel->sortColumn(), index.parent());
376void KCategorizedViewPrivate::leftToRightVisualRect(const QModelIndex &index, Item &item, const Block &block, const QPoint &blockPos) const
384 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * q->gridSize().width() + blockPos.x() + categoryDrawer->leftMargin();
386 item.topLeft.rx() = viewportWidth() - ((relativeRow % maxItemsPerRow) + 1) * q->gridSize().width() + categoryDrawer->leftMargin() + categorySpacing;
393 const int maxItemsPerRow = qMax((viewportWidth() - q->spacing()) / (itemSize.width() + q->spacing()), 1);
395 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin();
397 item.topLeft.rx() = viewportWidth() - (relativeRow % maxItemsPerRow) * itemSize.width() + categoryDrawer->leftMargin() + categorySpacing;
407 if ((prevRect.bottomRight().x() + 1) + currSize.width() - blockPos.x() + q->spacing() > viewportW) {
426 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
433 item.topLeft.rx() = (prevRect.bottomLeft().x() - 1) - q->spacing() - item.size.width() + categoryDrawer->leftMargin() + categorySpacing;
441 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
450void KCategorizedViewPrivate::topToBottomVisualRect(const QModelIndex &index, Item &item, const Block &block, const QPoint &blockPos) const
577 const QModelIndex nextIndex = d->proxyModel->index(index.row() + 1, modelColumn(), rootIndex());
622 disconnect(d->categoryDrawer, SIGNAL(collapseOrExpandClicked(QModelIndex)), this, SLOT(_k_slotCollapseOrExpandClicked(QModelIndex)));
627 connect(d->categoryDrawer, SIGNAL(collapseOrExpandClicked(QModelIndex)), this, SLOT(_k_slotCollapseOrExpandClicked(QModelIndex)));
700 return block(representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString());
783 const std::pair<QModelIndex, QModelIndex> intersecting = d->intersectingIndexesWithRect(viewport()->rect().intersected(event->rect()));
794 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
807 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
830 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
850 option.features |= alternatingRowColors() && alternateItem ? QStyleOptionViewItem::Alternate : QStyleOptionViewItem::None;
852 option.state |= selectionModel()->isSelected(index) ? QStyle::State_Selected : QStyle::State_None;
891void KCategorizedView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
954 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
960 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
966 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
984 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1007 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1034 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1058 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1095QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
1116 const QModelIndex previous = d->proxyModel->index(current.row() - 1, modelColumn(), rootIndex());
1142 const bool canMove = current.row() + maxItemsPerRow < block.firstIndex.row() + block.items.count();
1149 const QModelIndex nextIndex = d->proxyModel->index(block.firstIndex.row() + block.items.count(), modelColumn(), rootIndex());
1162 return d->proxyModel->index(nextBlock.firstIndex.row() + currentRelativePos, modelColumn(), rootIndex());
1180 const QModelIndex prevIndex = d->proxyModel->index(block.firstIndex.row() - 1, modelColumn(), rootIndex());
1194 return d->proxyModel->index(prevBlock.firstIndex.row() + prevBlock.items.count() - remainder + currentRelativePos, modelColumn(), rootIndex());
1251 // located under the top most affected category as in quarantine (the block itself, as a whole),
1336 * QListView::updateGeometries() has it's own opinion on whether the scrollbars should be visible (valid range) or not
1339 * (the comment above the main block isn't all accurate, layoutChldren is called regardless of the policy)
1341 * As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
1345 * Since the implicit show/hide by the following range setting will cause further resizes if the policy is Qt::ScrollBarAsNeeded
1346 * we keep it static until we're done, then restore the original value and ultimately change the scrollbar visibility ourself.
1348 if (d->isCategorized()) { // important! - otherwise we'd pollute the setting if the view is initially not categorized
1349 setVerticalScrollBarPolicy((verticalP == Qt::ScrollBarAlwaysOn || verticalScrollBar()->isVisibleTo(this)) ? Qt::ScrollBarAlwaysOn
1351 setHorizontalScrollBarPolicy((horizontalP == Qt::ScrollBarAlwaysOn || horizontalScrollBar()->isVisibleTo(this)) ? Qt::ScrollBarAlwaysOn
1394 const int bottomRange = lastItemRect.bottomRight().y() + verticalOffset() - viewport()->height();
1405 // TODO: also consider working with the horizontal scroll bar. since at this level I am not still
1407 // (think how to draw categories), we would have to take care of the horizontal scroll bar too.
1408 // In theory, as KCategorizedView has been designed, there is no need of horizontal scroll bar.
1417 if (verticalP == Qt::ScrollBarAsNeeded && (verticalScrollBar()->isVisibleTo(this) != validRange)) {
1421 if (horizontalP == Qt::ScrollBarAsNeeded && (horizontalScrollBar()->isVisibleTo(this) != validRange)) {
1432void KCategorizedView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles)
1452 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
This class lets you categorize a view.
Definition kcategorizedsortfilterproxymodel.h:36
@ CategoryDisplayRole
This role is used for asking the category to a given index.
Definition kcategorizedsortfilterproxymodel.h:42
Item view for listing items in a categorized fashion optionally.
Definition kcategorizedview.h:69
void setModel(QAbstractItemModel *model) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:497
void setCategorySpacing(int categorySpacing)
Stablishes the category spacing.
Definition kcategorizedview.cpp:635
QModelIndex indexAt(const QPoint &point) const override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:703
void dragMoveEvent(QDragMoveEvent *event) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1072
QRect visualRect(const QModelIndex &index) const override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:534
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1208
void dropEvent(QDropEvent *event) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1088
void resizeEvent(QResizeEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:885
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1095
void mouseMoveEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:934
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1432
void dragEnterEvent(QDragEnterEvent *event) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1078
KCategoryDrawer * categoryDrawer() const
Returns the current category drawer.
Definition kcategorizedview.cpp:614
void setCollapsibleBlocks(bool enable)
Sets whether blocks can be collapsed or not.
Definition kcategorizedview.cpp:670
void mousePressEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:993
void setAlternatingBlockColors(bool enable)
Sets whether blocks should be drawn with alternating colors.
Definition kcategorizedview.cpp:655
void leaveEvent(QEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:1050
void paintEvent(QPaintEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:776
void setCategoryDrawer(KCategoryDrawer *categoryDrawer)
The category drawer that will be used for drawing categories.
Definition kcategorizedview.cpp:619
QModelIndexList block(const QString &category)
Definition kcategorizedview.cpp:680
void startDrag(Qt::DropActions supportedActions) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1067
void mouseReleaseEvent(QMouseEvent *event) override
Reimplemented from QWidget.
Definition kcategorizedview.cpp:1023
void setGridSizeOwn(const QSize &size)
Definition kcategorizedview.cpp:528
void updateGeometries() override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1328
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1427
void dragLeaveEvent(QDragLeaveEvent *event) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1083
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:891
virtual void slotLayoutChanged()
Definition kcategorizedview.cpp:1475
void rowsInserted(const QModelIndex &parent, int start, int end) override
Reimplemented from QAbstractItemView.
Definition kcategorizedview.cpp:1463
Q_SCRIPTABLE Q_NOREPLY void start()
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
Category category(StandardShortcut id)
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const=0
virtual Qt::ItemFlags flags(const QModelIndex &index) const const
virtual int rowCount(const QModelIndex &parent) const const=0
CursorAction
ScrollPerItem
SelectionMode
DragSelectingState
alternatingRowColors
QModelIndex currentIndex() const const
virtual void dragEnterEvent(QDragEnterEvent *event) override
virtual QAbstractItemDelegate * itemDelegateForIndex(const QModelIndex &index) const const
QAbstractItemModel * model() const const
virtual void mousePressEvent(QMouseEvent *event) override
virtual void reset()
QModelIndex rootIndex() const const
selectionMode
QItemSelectionModel * selectionModel() const const
virtual void setModel(QAbstractItemModel *model)
QSize sizeHintForIndex(const QModelIndex &index) const const
State state() const const
verticalScrollMode
QScrollBar * horizontalScrollBar() const const
horizontalScrollBarPolicy
virtual QSize sizeHint() const const override
QScrollBar * verticalScrollBar() const const
verticalScrollBarPolicy
QWidget * viewport() const const
maximum
minimum
void setPageStep(int)
void setRange(int min, int max)
void setSingleStep(int)
void setValue(int)
QPoint pos()
Block
Iterator
SelectionFlags
bool isSelected(const QModelIndex &index) const const
virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
iterator begin()
qsizetype count() const const
iterator end()
qsizetype indexOf(const AT &value, qsizetype from) const const
LeftToRight
ListMode
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles) override
virtual void dragLeaveEvent(QDragLeaveEvent *e) override
virtual void dragMoveEvent(QDragMoveEvent *e) override
virtual void dropEvent(QDropEvent *event) override
virtual bool event(QEvent *e) override
flow
void setGridSize(const QSize &size)
virtual int horizontalOffset() const const override
virtual QModelIndex indexAt(const QPoint &p) const const override
modelColumn
virtual void mouseMoveEvent(QMouseEvent *e) override
virtual void mouseReleaseEvent(QMouseEvent *e) override
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
virtual void paintEvent(QPaintEvent *e) override
virtual void resizeEvent(QResizeEvent *e) override
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
virtual void rowsInserted(const QModelIndex &parent, int start, int end) override
bool isSelectionRectVisible() const const
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override
spacing
virtual void startDrag(Qt::DropActions supportedActions) override
uniformItemSizes
virtual void updateGeometries() override
virtual int verticalOffset() const const override
viewMode
virtual QRect visualRect(const QModelIndex &index) const const override
wordWrap
QVariant data(int role) const const
bool isValid() const const
const QAbstractItemModel * model() const const
QModelIndex parent() const const
int row() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
void restore()
void save()
int row() const const
bool isNull() const const
int & ry()
int x() const const
int y() const const
height
QSizeF size() const const
width
QRect adjusted(int dx1, int dy1, int dx2, int dy2) const const
QPoint bottomLeft() const const
QPoint bottomRight() const const
bool contains(const QPoint &point, bool proper) const const
int height() const const
bool intersects(const QRect &rectangle) const const
QRect normalized() const const
void setHeight(int height)
void setLeft(int x)
void setSize(const QSize &size)
QSize size() const const
int top() const const
QPoint topLeft() const const
QPoint topRight() const const
Rectangle
QSize boundedTo(const QSize &otherSize) const const
QSize expandedTo(const QSize &otherSize) const const
int height() const const
bool isNull() const const
bool isValid() const const
void setHeight(int height)
int width() const const
void setWidth(qreal width)
qreal width() const const
CE_RubberBand
State_Open
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
Alternate
typedef DropActions
ItemIsEnabled
typedef KeyboardModifiers
LeftToRight
LeftButton
ScrollBarPolicy
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QString toString() const const
height
bool isVisibleTo(const QWidget *ancestor) const const
layoutDirection
virtual void leaveEvent(QEvent *event)
QPoint mapFromGlobal(const QPoint &pos) const const
pos
rect
size
QStyle * style() const const
void update()
virtual void setVisible(bool visible)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.