Convert counter viewer to item model, sync filter with event browser

This commit is contained in:
baldurk
2021-10-18 14:14:36 +01:00
parent 531946c128
commit 6dd63c6aec
7 changed files with 323 additions and 209 deletions
+13 -7
View File
@@ -111,6 +111,8 @@ void RDHeaderView::reset()
{
if(m_customSizing)
cacheSections();
QHeaderView::reset();
}
void RDHeaderView::cacheSections()
@@ -247,7 +249,10 @@ int RDHeaderView::visualIndexAt(int position) const
int RDHeaderView::logicalIndexAt(int position) const
{
return visualIndexAt(position);
if(m_customSizing)
return visualIndexAt(position);
return QHeaderView::logicalIndexAt(position);
}
int RDHeaderView::count() const
@@ -570,6 +575,8 @@ void RDHeaderView::mousePressEvent(QMouseEvent *event)
paintSection(&painter, QRect(QPoint(0, 0), m_sectionPreview->size()), idx);
painter.end();
m_cursorPos = QCursor::pos().x();
m_sectionPreview->setPixmap(preview);
m_sectionPreviewOffset = mousePos - secPos;
@@ -577,6 +584,7 @@ void RDHeaderView::mousePressEvent(QMouseEvent *event)
m_sectionPreview->move(mousePos - m_sectionPreviewOffset, 0);
m_sectionPreview->show();
QHeaderView::mousePressEvent(event);
return;
}
}
@@ -741,6 +749,8 @@ void RDHeaderView::mouseReleaseEvent(QMouseEvent *event)
int mousePos = event->x();
int idx = logicalIndexAt(mousePos);
m_sectionPreview->hide();
if(idx >= 0)
{
int secSize = sectionSize(idx);
@@ -769,21 +779,17 @@ void RDHeaderView::mouseReleaseEvent(QMouseEvent *event)
else
moveSection(srcSection, dstSection);
}
return;
}
}
m_sectionPreview->hide();
}
m_movingSection = -1;
if(m_customSizing)
{
m_resizeState = qMakePair(NoResize, -1);
return QAbstractItemView::mouseReleaseEvent(event);
}
QHeaderView::mouseReleaseEvent(event);
}