StretchHeaderView: Formatting

This commit is contained in:
Jonas Kvinge 2024-07-09 11:35:01 +02:00
parent ac959387fe
commit 74b8cd6156
1 changed files with 34 additions and 31 deletions

View File

@ -332,40 +332,43 @@ void StretchHeaderView::SectionResized(const int logical_index, const int old_si
return; return;
} }
if (in_mouse_move_event_) { if (!in_mouse_move_event_) {
bool resized = false; return;
if (new_size >= minimumSectionSize()) { }
// Find the visible section to the right of the section that's being resized
const int visual_index = visualIndex(logical_index); bool resized = false;
int right_section_logical_index = -1; if (new_size >= minimumSectionSize()) {
int right_section_visual_index = -1; // Find the visible section to the right of the section that's being resized
for (int i = 0; i <= count(); ++i) { const int visual_index = visualIndex(logical_index);
if (!isSectionHidden(i) && int right_section_logical_index = -1;
visualIndex(i) > visual_index && int right_section_visual_index = -1;
(right_section_visual_index == -1 || visualIndex(i) < right_section_visual_index)) { for (int i = 0; i <= count(); ++i) {
right_section_logical_index = i; if (!isSectionHidden(i) &&
right_section_visual_index = visualIndex(i); visualIndex(i) > visual_index &&
} (right_section_visual_index == -1 || visualIndex(i) < right_section_visual_index)) {
} right_section_logical_index = i;
if (right_section_logical_index != -1) { right_section_visual_index = visualIndex(i);
const int right_section_size = sectionSize(right_section_logical_index) + (old_size - new_size);
if (right_section_size >= minimumSectionSize()) {
column_widths_[logical_index] = static_cast<ColumnWidthType>(new_size) / width();
column_widths_[right_section_logical_index] = static_cast<ColumnWidthType>(right_section_size) / width();
in_mouse_move_event_ = false;
NormaliseWidths(QList<int>() << right_section_logical_index);
ResizeSections(QList<int>() << right_section_logical_index);
in_mouse_move_event_ = true;
resized = true;
}
} }
} }
if (!resized) { if (right_section_logical_index != -1) {
in_mouse_move_event_ = true; const int right_section_size = sectionSize(right_section_logical_index) + (old_size - new_size);
forced_resize_logical_index_ = logical_index; if (right_section_size >= minimumSectionSize()) {
resizeSection(logical_index, old_size); column_widths_[logical_index] = static_cast<ColumnWidthType>(new_size) / width();
in_mouse_move_event_ = false; column_widths_[right_section_logical_index] = static_cast<ColumnWidthType>(right_section_size) / width();
in_mouse_move_event_ = false;
NormaliseWidths(QList<int>() << right_section_logical_index);
ResizeSections(QList<int>() << right_section_logical_index);
in_mouse_move_event_ = true;
resized = true;
}
} }
} }
if (!resized) {
forced_resize_logical_index_ = logical_index;
in_mouse_move_event_ = false;
resizeSection(logical_index, old_size);
in_mouse_move_event_ = true;
}
} }