|
@@ -258,8 +258,10 @@ void AbstractTableView::mousemove_event(MouseEvent& event)
|
|
if (!model())
|
|
if (!model())
|
|
return AbstractView::mousemove_event(event);
|
|
return AbstractView::mousemove_event(event);
|
|
|
|
|
|
|
|
+ auto adjusted_position = this->adjusted_position(event.position());
|
|
|
|
+
|
|
if (m_in_column_resize) {
|
|
if (m_in_column_resize) {
|
|
- auto delta = event.position() - m_column_resize_origin;
|
|
|
|
|
|
+ auto delta = adjusted_position - m_column_resize_origin;
|
|
int new_width = m_column_resize_original_width + delta.x();
|
|
int new_width = m_column_resize_original_width + delta.x();
|
|
if (new_width <= minimum_column_width)
|
|
if (new_width <= minimum_column_width)
|
|
new_width = minimum_column_width;
|
|
new_width = minimum_column_width;
|
|
@@ -276,7 +278,7 @@ void AbstractTableView::mousemove_event(MouseEvent& event)
|
|
|
|
|
|
if (m_pressed_column_header_index != -1) {
|
|
if (m_pressed_column_header_index != -1) {
|
|
auto header_rect = this->header_rect(m_pressed_column_header_index);
|
|
auto header_rect = this->header_rect(m_pressed_column_header_index);
|
|
- if (header_rect.contains(event.position())) {
|
|
|
|
|
|
+ if (header_rect.contains(adjusted_position)) {
|
|
set_hovered_header_index(m_pressed_column_header_index);
|
|
set_hovered_header_index(m_pressed_column_header_index);
|
|
if (!m_pressed_column_header_is_pressed)
|
|
if (!m_pressed_column_header_is_pressed)
|
|
update_headers();
|
|
update_headers();
|
|
@@ -294,12 +296,12 @@ void AbstractTableView::mousemove_event(MouseEvent& event)
|
|
int column_count = model()->column_count();
|
|
int column_count = model()->column_count();
|
|
bool found_hovered_header = false;
|
|
bool found_hovered_header = false;
|
|
for (int i = 0; i < column_count; ++i) {
|
|
for (int i = 0; i < column_count; ++i) {
|
|
- if (column_resize_grabbable_rect(i).contains(event.position())) {
|
|
|
|
|
|
+ if (column_resize_grabbable_rect(i).contains(adjusted_position)) {
|
|
window()->set_override_cursor(StandardCursor::ResizeHorizontal);
|
|
window()->set_override_cursor(StandardCursor::ResizeHorizontal);
|
|
set_hovered_header_index(-1);
|
|
set_hovered_header_index(-1);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (header_rect(i).contains(event.position())) {
|
|
|
|
|
|
+ if (header_rect(i).contains(adjusted_position)) {
|
|
set_hovered_header_index(i);
|
|
set_hovered_header_index(i);
|
|
found_hovered_header = true;
|
|
found_hovered_header = true;
|
|
}
|
|
}
|
|
@@ -324,7 +326,7 @@ void AbstractTableView::mouseup_event(MouseEvent& event)
|
|
}
|
|
}
|
|
if (m_pressed_column_header_index != -1) {
|
|
if (m_pressed_column_header_index != -1) {
|
|
auto header_rect = this->header_rect(m_pressed_column_header_index);
|
|
auto header_rect = this->header_rect(m_pressed_column_header_index);
|
|
- if (header_rect.contains(event.position())) {
|
|
|
|
|
|
+ if (header_rect.contains(adjusted_position)) {
|
|
auto new_sort_order = SortOrder::Ascending;
|
|
auto new_sort_order = SortOrder::Ascending;
|
|
if (model()->key_column() == m_pressed_column_header_index)
|
|
if (model()->key_column() == m_pressed_column_header_index)
|
|
new_sort_order = model()->sort_order() == SortOrder::Ascending
|
|
new_sort_order = model()->sort_order() == SortOrder::Ascending
|
|
@@ -350,19 +352,21 @@ void AbstractTableView::mousedown_event(MouseEvent& event)
|
|
if (event.button() != MouseButton::Left)
|
|
if (event.button() != MouseButton::Left)
|
|
return AbstractView::mousedown_event(event);
|
|
return AbstractView::mousedown_event(event);
|
|
|
|
|
|
|
|
+ auto adjusted_position = this->adjusted_position(event.position());
|
|
|
|
+
|
|
if (event.y() < header_height()) {
|
|
if (event.y() < header_height()) {
|
|
int column_count = model()->column_count();
|
|
int column_count = model()->column_count();
|
|
for (int i = 0; i < column_count; ++i) {
|
|
for (int i = 0; i < column_count; ++i) {
|
|
- if (column_resize_grabbable_rect(i).contains(event.position())) {
|
|
|
|
|
|
+ if (column_resize_grabbable_rect(i).contains(adjusted_position)) {
|
|
m_resizing_column = i;
|
|
m_resizing_column = i;
|
|
m_in_column_resize = true;
|
|
m_in_column_resize = true;
|
|
m_column_resize_original_width = column_width(i);
|
|
m_column_resize_original_width = column_width(i);
|
|
- m_column_resize_origin = event.position();
|
|
|
|
|
|
+ m_column_resize_origin = adjusted_position;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
auto header_rect = this->header_rect(i);
|
|
auto header_rect = this->header_rect(i);
|
|
auto column_metadata = model()->column_metadata(i);
|
|
auto column_metadata = model()->column_metadata(i);
|
|
- if (header_rect.contains(event.position()) && column_metadata.sortable == Model::ColumnMetadata::Sortable::True) {
|
|
|
|
|
|
+ if (header_rect.contains(adjusted_position) && column_metadata.sortable == Model::ColumnMetadata::Sortable::True) {
|
|
m_pressed_column_header_index = i;
|
|
m_pressed_column_header_index = i;
|
|
m_pressed_column_header_is_pressed = true;
|
|
m_pressed_column_header_is_pressed = true;
|
|
update_headers();
|
|
update_headers();
|