void StretchHeaderView::SectionResized(int logical, int, int new_size) { if (!stretch_enabled_) return; if (in_mouse_move_event_) { // Update this section's proportional width column_widths_[logical] = ColumnWidthType(new_size) / width(); // Find the visible sections to the right of the section that's being resized int visual = visualIndex(logical); QList<int> logical_sections_to_resize; for (int i=0 ; i<count() ; ++i) { if (!isSectionHidden(i) && visualIndex(i) > visual) logical_sections_to_resize << i; } // Resize just those columns if (!logical_sections_to_resize.isEmpty()) { in_mouse_move_event_ = false; UpdateWidths(logical_sections_to_resize); NormaliseWidths(logical_sections_to_resize); in_mouse_move_event_ = true; } } }
void TupExposureHeader::moveHeaderSection(int position, int newPosition, bool isLocalRequest) { if (isLocalRequest) { m_sectionOnMotion = true; moveSection(visualIndex(position), visualIndex(newPosition)); m_sections.swap(position, newPosition); m_sectionOnMotion = false; } else { m_sections.swap(position, newPosition); } }
void RDHeaderView::mouseReleaseEvent(QMouseEvent *event) { if(m_movingSection >= 0) { int mousePos = event->x(); int idx = logicalIndexAt(mousePos); if(idx >= 0) { int secSize = sectionSize(idx); int secPos = sectionPosition(idx); int srcSection = visualIndex(m_movingSection); int dstSection = visualIndex(idx); if(srcSection >= 0 && dstSection >= 0 && srcSection != dstSection) { // the half-way point of the section decides whether we're dropping to the left // or the right of it. if(mousePos < secPos + secSize / 2) { // if we're moving from the left, place it to the left of dstSection if(srcSection < dstSection) moveSection(srcSection, dstSection - 1); else moveSection(srcSection, dstSection); } else { // if we're moving it from the right, place it to the right of dstSection if(srcSection > dstSection) moveSection(srcSection, dstSection + 1); else moveSection(srcSection, dstSection); } } } m_sectionPreview->hide(); } m_movingSection = -1; if(m_customSizing) { m_resizeState = qMakePair(NoResize, -1); return QAbstractItemView::mouseReleaseEvent(event); } QHeaderView::mouseReleaseEvent(event); }
void handleSectionResized(int i) { for (int j=visualIndex(i);j<count();j++) { int logical = logicalIndex(j); boxes[logical]->setGeometry(sectionViewportPosition(logical), 0, sectionSize(logical) - 5, height()); } }
void CQHeaderView:: handleSectionResized(int i) { for (int j = visualIndex(i); j < count(); ++j) { int logical = logicalIndex(j); QWidget *w = widgets_[logical]; w->setGeometry(sectionViewportPosition(logical), 0, sectionSize(logical) - 5, height()); } }
QStyleOptionHeader HierarchicalHeaderView::styleOptionForCell(int logicalInd) const { QStyleOptionHeader opt; initStyleOption(&opt); if (window()->isActiveWindow()) opt.state |= QStyle::State_Active; opt.textAlignment = Qt::AlignCenter; opt.iconAlignment = Qt::AlignVCenter; opt.section = logicalInd; int visual = visualIndex(logicalInd); if (count() == 1) opt.position = QStyleOptionHeader::OnlyOneSection; else { if (visual == 0) opt.position = QStyleOptionHeader::Beginning; else opt.position=(visual==count()-1 ? QStyleOptionHeader::End : QStyleOptionHeader::Middle); } if(isClickable()) { /* if (logicalIndex == d->hover) state |= QStyle::State_MouseOver; if (logicalIndex == d->pressed) { state |= QStyle::State_Sunken; } else*/ { if(highlightSections() && selectionModel()) { if(orientation()==Qt::Horizontal) { if(selectionModel()->columnIntersectsSelection(logicalInd, rootIndex())) opt.state |= QStyle::State_On; if(selectionModel()->isColumnSelected(logicalInd, rootIndex())) opt.state |= QStyle::State_Sunken; } else { if(selectionModel()->rowIntersectsSelection(logicalInd, rootIndex())) opt.state |= QStyle::State_On; if(selectionModel()->isRowSelected(logicalInd, rootIndex())) opt.state |= QStyle::State_Sunken; } } } } if(selectionModel()) { bool previousSelected=false; if(orientation()==Qt::Horizontal) previousSelected = selectionModel()->isColumnSelected(logicalIndex(visual - 1), rootIndex()); else previousSelected = selectionModel()->isRowSelected(logicalIndex(visual - 1), rootIndex()); bool nextSelected=false; if(orientation()==Qt::Horizontal) nextSelected = selectionModel()->isColumnSelected(logicalIndex(visual + 1), rootIndex()); else nextSelected = selectionModel()->isRowSelected(logicalIndex(visual + 1), rootIndex()); if (previousSelected && nextSelected) opt.selectedPosition = QStyleOptionHeader::NextAndPreviousAreSelected; else { if (previousSelected) opt.selectedPosition = QStyleOptionHeader::PreviousIsSelected; else { if (nextSelected) opt.selectedPosition = QStyleOptionHeader::NextIsSelected; else opt.selectedPosition = QStyleOptionHeader::NotAdjacent; } } } return opt; }
void TupExposureHeader::notifyVisibilityChange(int section) { emit visibilityChanged(visualIndex(section), !m_sections[section].isVisible); }
void KTExposureHeader::emitVisibilityChanged(int section) { emit visibilityChanged(visualIndex(section), !m_layers[section].isVisible); }