ui: Fixed resize status view table columns only resizeable in the title bar (issue #506)
bug id = 506
This commit is contained in:
@@ -37,6 +37,7 @@ QtTable::QtTable(QWidget* parent)
|
||||
{
|
||||
setAlternatingRowColors(true);
|
||||
setShowGrid(false);
|
||||
setMouseTracking(true);
|
||||
|
||||
this->setItemDelegate(new SelectableCellDelegate());
|
||||
|
||||
@@ -132,3 +133,61 @@ void QtTable::resizeEvent(QResizeEvent* event)
|
||||
updateRows();
|
||||
}
|
||||
|
||||
void QtTable::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
for (auto i = 1; i < this->model()->columnCount(); i++)
|
||||
{
|
||||
if (std::abs(event->pos().x() - columnViewportPosition(i)) < 5)
|
||||
{
|
||||
m_colIndex = i - 1;
|
||||
m_lastPos = event->pos().x();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTableView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void QtTable::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (m_colIndex >= 0)
|
||||
{
|
||||
int width = columnWidth(m_colIndex) + event->pos().x() - m_lastPos;
|
||||
setColumnWidth(m_colIndex, width < 20 ? 20 : width);
|
||||
|
||||
if (width >= 20)
|
||||
{
|
||||
m_lastPos = event->pos().x();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool inRange = false;
|
||||
for (auto i = 1; i < this->model()->columnCount(); i++)
|
||||
{
|
||||
if (std::abs(event->pos().x() - columnViewportPosition(i)) < 5)
|
||||
{
|
||||
setCursor(Qt::SplitHCursor);
|
||||
inRange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRange)
|
||||
{
|
||||
unsetCursor();
|
||||
}
|
||||
}
|
||||
|
||||
QTableView::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void QtTable::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
m_colIndex = -1;
|
||||
m_lastPos = -1;
|
||||
|
||||
QTableView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,15 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent* event);
|
||||
virtual void mouseMoveEvent(QMouseEvent* event);
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
float m_rowsToFill;
|
||||
|
||||
int m_colIndex = -1;
|
||||
int m_lastPos = -1;
|
||||
};
|
||||
|
||||
#endif // QT_TABLE_H
|
||||
|
||||
Reference in New Issue
Block a user