KDEUI
kcategorizedview.cpp
Go to the documentation of this file.
89 // will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the
90 // visual rect position of item j will have to be recomputed (cannot use the cached point). The quarantine
92 // that the whole block will have different offset, but items will keep the same relative position
98 // to the block. Because of insertions or removals a whole block can be moved, so the whole block
137 const QString categoryDisplay = representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
141 option.rect.setWidth(viewportWidth() + categoryDrawer->leftMargin() + categoryDrawer->rightMargin());
148 QPair<QModelIndex, QModelIndex> KCategorizedView::Private::intersectingIndexesWithRect(const QRect &_rect) const
233 const QModelIndex lastIndex = proxyModel->index(firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
253 return q->viewport()->width() - categorySpacing * 2 - categoryDrawer->leftMargin() - categoryDrawer->rightMargin();
354 const QModelIndex lastIndex = proxyModel->index(block.firstIndex.row() + block.items.count() - 1, q->modelColumn(), q->rootIndex());
357 QModelIndex prevIndex = proxyModel->index(lastIndex.row() - 1, q->modelColumn(), q->rootIndex());
384 const QModelIndex categoryIndex = index.model()->index(index.row(), proxyModel->sortColumn(), index.parent());
397 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * q->gridSize().width() + blockPos.x() + categoryDrawer->leftMargin();
399 item.topLeft.rx() = viewportWidth() - ((relativeRow % maxItemsPerRow) + 1) * q->gridSize().width() + categoryDrawer->leftMargin() + categorySpacing;
406 const int maxItemsPerRow = qMax((viewportWidth() - q->spacing()) / (itemSize.width() + q->spacing()), 1);
408 item.topLeft.rx() = (relativeRow % maxItemsPerRow) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin();
410 item.topLeft.rx() = viewportWidth() - (relativeRow % maxItemsPerRow) * itemSize.width() + categoryDrawer->leftMargin() + categorySpacing;
420 if ((prevRect.bottomRight().x() + 1) + currSize.width() - blockPos.x() + q->spacing() > viewportW) {
439 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
446 item.topLeft.rx() = (prevRect.bottomLeft().x() - 1) - q->spacing() - item.size.width() + categoryDrawer->leftMargin() + categorySpacing;
454 item.topLeft.rx() = viewportWidth() - currSize.width() + categoryDrawer->leftMargin() + categorySpacing;
594 const QModelIndex nextIndex = d->proxyModel->index(index.row() + 1, modelColumn(), rootIndex());
667 for (QHash<QString, Private::Block>::Iterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
713 return block(representative.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString());
795 const QPair<QModelIndex, QModelIndex> intersecting = d->intersectingIndexesWithRect(viewport()->rect().intersected(event->rect()));
806 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
808 option.features |= d->alternatingBlockColors && block.alternate ? QStyleOptionViewItemV4::Alternate
816 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
839 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
889 opt.rect = d->mapToViewport(d->rubberBandRect).intersected(viewport()->rect().adjusted(-16, -16, 16, 16));
954 if (state() == DragSelectingState && isSelectionRectVisible() && itemViewSelectionMode != SingleSelection
967 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
973 option.rect.setWidth(d->viewportWidth() + d->categoryDrawer->leftMargin() + d->categoryDrawer->rightMargin());
979 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
999 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1022 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1053 const QModelIndex categoryIndex = d->proxyModel->index(block.firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1081 const QModelIndex categoryIndex = d->proxyModel->index(d->hoveredBlock->firstIndex.row(), d->proxyModel->sortColumn(), rootIndex());
1140 const QModelIndex previous = d->proxyModel->index(current.row() - 1, modelColumn(), rootIndex());
1175 const QModelIndex nextIndex = d->proxyModel->index(block.firstIndex.row() + block.items.count(), modelColumn(), rootIndex());
1188 return d->proxyModel->index(nextBlock.firstIndex.row() + currentRelativePos, modelColumn(), rootIndex());
1208 const QModelIndex prevIndex = d->proxyModel->index(block.firstIndex.row() - 1, modelColumn(), rootIndex());
1222 return d->proxyModel->index(prevBlock.firstIndex.row() + prevBlock.items.count() - remainder + currentRelativePos, modelColumn(), rootIndex());
1280 // located under the top most affected category as in quarantine (the block itself, as a whole),
1342 for (QHash<QString, Private::Block>::Iterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
1360 const Qt::ScrollBarPolicy verticalP = verticalScrollBarPolicy(), horizontalP = horizontalScrollBarPolicy();
1364 * QListView::updateGeometries() has it's own opinion on whether the scrollbars should be visible (valid range) or not
1367 * (the comment above the main block isn't all accurate, layoutChldren is called regardless of the policy)
1369 * As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
1373 * Since the implicit show/hide by the followin range setting will cause further resizes if the policy is Qt::ScrollBarAsNeeded
1374 * we keep it static until we're done, then restore the original value and ultimately change the scrollbar visibility ourself.
1376 if (d->isCategorized()) { // important! - otherwise we'd pollute the setting if the view is initially not categorized
1377 setVerticalScrollBarPolicy((verticalP == Qt::ScrollBarAlwaysOn || verticalScrollBar()->isVisibleTo(this)) ?
1379 setHorizontalScrollBarPolicy((horizontalP == Qt::ScrollBarAlwaysOn || horizontalScrollBar()->isVisibleTo(this)) ?
1417 const int bottomRange = lastItemRect.bottomRight().y() + verticalOffset() - viewport()->height();
1428 //TODO: also consider working with the horizontal scroll bar. since at this level I am not still
1430 // (think how to draw categories), we would have to take care of the horizontal scroll bar too.
1431 // In theory, as KCategorizedView has been designed, there is no need of horizontal scroll bar.
1440 if (verticalP == Qt::ScrollBarAsNeeded && (verticalScrollBar()->isVisibleTo(this) != validRange))
1443 if (horizontalP == Qt::ScrollBarAsNeeded && (horizontalScrollBar()->isVisibleTo(this) != validRange))
1475 category = categoryIndex.data(KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
virtual void leaveEvent(QEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:1073
QSize boundedTo(const QSize &otherSize) const
virtual int rowCount(const QModelIndex &parent) const =0
bool isValid() const
void setHeight(int height)
virtual void reset()
int & rx()
int & ry()
virtual void mouseMoveEvent(QMouseEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:949
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1448
QRect normalized() const
QPoint topRight() const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
bool alternatingRowColors() const
int width() const
virtual QModelIndex indexAt(const QPoint &point) const
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:716
virtual void startDrag(QFlags< Qt::DropAction > supportedActions)
int categorySpacing() const
QAbstractItemView::SelectionMode selectionMode() const
virtual void rowsRemoved(const QModelIndex &parent, int start, int end)
Definition: kcategorizedview.cpp:1512
virtual void resizeEvent(QResizeEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:899
bool alternatingBlockColors() const
void setRange(int min, int max)
QItemSelectionModel * selectionModel() const
virtual void rowsInsertedArtifficial(const QModelIndex &parent, int start, int end)
Definition: kcategorizedview.cpp:1501
virtual void updateGeometries()
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1357
virtual void dragEnterEvent(QDragEnterEvent *event)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1101
QStyle * style() const
virtual void setModel(QAbstractItemModel *model)
virtual int verticalOffset() const
bool collapsibleBlocks() const
void setCollapsibleBlocks(bool enable)
Sets whether blocks can be collapsed or not.
Definition: kcategorizedview.cpp:688
virtual void mouseReleaseEvent(QMouseEvent *e)
QPoint bottomRight() const
const QPoint & pos() const
virtual QModelIndex moveCursor(CursorAction cursorAction, QFlags< Qt::KeyboardModifier > modifiers)
This class lets you categorize a view.
Definition: kcategorizedsortfilterproxymodel.h:45
bool isNull() const
virtual void dragLeaveEvent(QDragLeaveEvent *event)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1106
virtual void setVisible(bool visible)
bool intersects(const QRect &rectangle) const
void save()
QPoint bottomLeft() const
QWidget * viewport() const
int height() const
void setPageStep(int)
ScrollMode verticalScrollMode() const
bool operator!=(const KEntry &k1, const KEntry &k2)
virtual void updateGeometries()
bool wordWrap() const
virtual void slotLayoutChanged()
Definition: kcategorizedview.cpp:1522
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
void setGridSizeOwn(const QSize &size)
Definition: kcategorizedview.cpp:545
void update()
virtual QSize sizeHint() const
int x() const
int y() const
void setCategoryDrawer(KCategoryDrawer *categoryDrawer)
The category drawer that will be used for drawing categories.
Definition: kcategorizedview.cpp:637
bool isVisibleTo(QWidget *ancestor) const
int indexOf(const T &value, int from) const
void initFrom(const QWidget *widget)
QSize size() const
const QRect & rect() const
Definition: kcategorydrawer.h:43
bool isValid() const
bool isAccepted() const
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
Item view for listing items in a categorized fashion optionally.
Definition: kcategorizedview.h:79
Qt::LayoutDirection layoutDirection() const
int modelColumn() const
int top() const
KCategoryDrawer * categoryDrawer() const
Returns the current category drawer.
Definition: kcategorizedview.cpp:632
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Qt::MouseButton button() const
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1454
Qt::ScrollBarPolicy horizontalScrollBarPolicy() const
virtual void select(const QModelIndex &index, QFlags< QItemSelectionModel::SelectionFlag > command)
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1235
int row() const
iterator begin()
QAbstractItemDelegate * itemDelegate() const
virtual QRect visualRect(const QModelIndex &index) const
virtual QRect visualRect(const QModelIndex &index) const
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:551
Definition: kcategorydrawer.h:150
virtual int horizontalOffset() const
virtual void dragEnterEvent(QDragEnterEvent *event)
bool contains(const QPoint &point, bool proper) const
minimum
QModelIndex parent() const
QSize sizeHintForIndex(const QModelIndex &index) const
QScrollBar * verticalScrollBar() const
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:905
virtual void setModel(QAbstractItemModel *model)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:514
QRect rect() const
KAction * next(const QObject *recvr, const char *slot, QObject *parent)
Scroll down one page.
Definition: kstandardaction.cpp:414
KCategorizedView(QWidget *parent=0)
Definition: kcategorizedview.cpp:503
QRect adjusted(int dx1, int dy1, int dx2, int dy2) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const =0
iterator end()
bool uniformItemSizes() const
virtual void paintEvent(QPaintEvent *e)
void setValue(int)
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1486
QModelIndex rootIndex() const
virtual QStyleOptionViewItem viewOptions() const
void restore()
State state() const
int spacing() const
bool isSelectionRectVisible() const
virtual void dragMoveEvent(QDragMoveEvent *e)
virtual void resizeEvent(QResizeEvent *e)
virtual void dropEvent(QDropEvent *e)
virtual QModelIndex indexAt(const QPoint &p) const
const QAbstractItemModel * model() const
virtual void dragLeaveEvent(QDragLeaveEvent *e)
virtual void mouseMoveEvent(QMouseEvent *e)
QPoint pos()
QModelIndexList block(const QString &category)
Definition: kcategorizedview.cpp:693
Definition: kcategorydrawer.h:113
QVariant data(int role) const
virtual void dropEvent(QDropEvent *event)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1111
void setSingleStep(int)
typedef DropActions
virtual void mousePressEvent(QMouseEvent *event)
virtual void setSelection(const QRect &rect, QFlags< QItemSelectionModel::SelectionFlag > command)
void setAlternatingBlockColors(bool enable)
Sets whether blocks should be drawn with alternating colors.
Definition: kcategorizedview.cpp:678
void setHeight(int height)
bool isSelected(const QModelIndex &index) const
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const =0
QPoint mapFromGlobal(const QPoint &pos) const
int height() const
QPoint topLeft() const
QScrollBar * horizontalScrollBar() const
virtual Qt::ItemFlags flags(const QModelIndex &index) const
void setGridSize(const QSize &size)
virtual void mouseReleaseEvent(QMouseEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:1042
const QPoint & pos() const
void setCategorySpacing(int categorySpacing)
Stablishes the category spacing.
Definition: kcategorizedview.cpp:659
QAbstractItemModel * model() const
This role is used for asking the category to a given index.
Definition: kcategorizedsortfilterproxymodel.h:52
QModelIndex currentIndex() const
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1118
virtual void mousePressEvent(QMouseEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:1008
maximum
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Flow flow() const
virtual void leaveEvent(QEvent *event)
virtual void paintEvent(QPaintEvent *event)
Reimplemented from QWidget.
Definition: kcategorizedview.cpp:788
typedef SelectionFlags
QString toString() const
Qt::ScrollBarPolicy verticalScrollBarPolicy() const
void setLeft(int x)
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
iterator begin()
virtual void startDrag(Qt::DropActions supportedActions)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1090
virtual void dragMoveEvent(QDragMoveEvent *event)
Reimplemented from QAbstractItemView.
Definition: kcategorizedview.cpp:1095
int height() const
typedef KeyboardModifiers
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.