1
0
Fork 0

Fixed random behavior when hiding / showing / reordering StdTable columns (#1421)

* fixed column ordering bug in ColumnReorderDialog

* resizing cursor bug is fixed.  adjusting order in edit dialog is broken.

* fixed column resizing bug
This commit is contained in:
changeofpace 2017-01-18 08:42:42 -05:00 committed by Duncan Ogilvie
parent 0b18f65653
commit ae36e772fe
2 changed files with 13 additions and 6 deletions

View File

@ -354,8 +354,9 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
if(getColumnCount() <= 1)
return;
int wColIndex = getColumnIndexFromX(event->x());
int wStartPos = getColumnPosition(wColIndex); // Position X of the start of column
int wEndPos = getColumnPosition(wColIndex) + getColumnWidth(wColIndex); // Position X of the end of column
int wDisplayIndex = getColumnDisplayIndexFromX(event->x());
int wStartPos = getColumnPosition(wDisplayIndex); // Position X of the start of column
int wEndPos = wStartPos + getColumnWidth(wColIndex); // Position X of the end of column
bool wHandle = ((wColIndex != 0) && (event->x() >= wStartPos) && (event->x() <= (wStartPos + 2))) || ((event->x() <= wEndPos) && (event->x() >= (wEndPos - 2)));
if(wColIndex == getColumnCount() - 1 && event->x() > viewport()->width()) //last column
wHandle = false;
@ -460,7 +461,8 @@ void AbstractTableView::mousePressEvent(QMouseEvent* event)
if(mColResizeData.splitHandle == true)
{
int wColIndex = getColumnDisplayIndexFromX(event->x());
int wStartPos = getColumnPosition(mColumnOrder[wColIndex]); // Position X of the start of column
int wDisplayIndex = getColumnDisplayIndexFromX(event->x());
int wStartPos = getColumnPosition(wDisplayIndex); // Position X of the start of column
mGuiState = AbstractTableView::ResizeColumnState;
@ -893,7 +895,10 @@ int AbstractTableView::getColumnIndexFromX(int x)
{
int col = mColumnOrder[wColIndex];
if(getColumnHidden(col))
{
wColIndex++;
continue;
}
wX += getColumnWidth(col);
if(x <= wX)
@ -924,7 +929,10 @@ int AbstractTableView::getColumnDisplayIndexFromX(int x)
{
int col = mColumnOrder[wColIndex];
if(getColumnHidden(col))
{
wColIndex++;
continue;
}
wX += getColumnWidth(col);
if(x <= wX)
@ -953,7 +961,6 @@ int AbstractTableView::getColumnPosition(int index)
if((index >= 0) && (index < getColumnCount()))
{
index = mColumnOrder[index];
for(int i = 0; i < index; i++)
if(!getColumnHidden(mColumnOrder[i]))
posX += getColumnWidth(mColumnOrder[i]);

View File

@ -16,12 +16,12 @@ ColumnReorderDialog::ColumnReorderDialog(AbstractTableView* parent) :
if(parent->getColumnHidden(i))
{
ui->listAvailable->addItem(parent->getColTitle(i));
ui->listAvailable->item(ui->listAvailable->count() - 1)->setData(Qt::UserRole, QVariant(j));
ui->listAvailable->item(ui->listAvailable->count() - 1)->setData(Qt::UserRole, QVariant(i));
}
else
{
ui->listDisplayed->addItem(parent->getColTitle(i));
ui->listDisplayed->item(ui->listDisplayed->count() - 1)->setData(Qt::UserRole, QVariant(j));
ui->listDisplayed->item(ui->listDisplayed->count() - 1)->setData(Qt::UserRole, QVariant(i));
}
}
if(ui->listAvailable->count() == 0)