1
0
Fork 0

actually fixed the bug

This commit is contained in:
Mr. eXoDia 2015-04-06 23:00:20 +02:00
parent 592c0a332a
commit d1491addc2
3 changed files with 16 additions and 17 deletions

View File

@ -27,6 +27,7 @@ AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(pare
mGuiState = AbstractTableView::NoState;
mShouldReload = true;
mAllowPainting = true;
// ScrollBar Init
setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar()));
@ -79,8 +80,8 @@ void AbstractTableView::fontsUpdated()
*/
void AbstractTableView::paintEvent(QPaintEvent* event)
{
int lastColumn = getColumnCount() - 1;
int lastColumnWidth = 0;
if(!mAllowPainting)
return;
if(getColumnCount()) //make sure the last column is never smaller than the window
{
int totalWidth = 0;
@ -91,10 +92,11 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
lastWidth += getColumnWidth(i);
int width = this->viewport()->width();
lastWidth = width > lastWidth ? width - lastWidth : 0;
int last = getColumnCount() - 1;
if(totalWidth < width)
lastColumnWidth = lastWidth;
setColumnWidth(last, lastWidth);
else
lastColumnWidth = getColumnWidth(lastColumn);
setColumnWidth(last, getColumnWidth(last));
}
Q_UNUSED(event);
@ -122,23 +124,20 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
{
for(int i = 0; i < getColumnCount(); i++)
{
int columnWidth = getColumnWidth(i);
if(i == lastColumn)
columnWidth = lastColumnWidth;
QStyleOptionButton wOpt;
if((mColumnList[i].header.isPressed == true) && (mColumnList[i].header.isMouseOver == true))
wOpt.state = QStyle::State_Sunken;
else
wOpt.state = QStyle::State_Enabled;
wOpt.rect = QRect(x, y, columnWidth, getHeaderHeight());
wOpt.rect = QRect(x, y, getColumnWidth(i), getHeaderHeight());
mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter, &mHeaderButtonSytle);
wPainter.setPen(headerTextColor);
wPainter.drawText(QRect(x + 4, y, columnWidth - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);
wPainter.drawText(QRect(x + 4, y, getColumnWidth(i) - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);
x += columnWidth;
x += getColumnWidth(i);
}
}
@ -148,32 +147,29 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
// Iterate over all columns and cells
for(int j = 0; j < getColumnCount(); j++)
{
int columnWidth = getColumnWidth(j);
if(j == lastColumn)
columnWidth = lastColumnWidth;
for(int i = 0; i < wViewableRowsCount; i++)
{
// Paints cell contents
if(i < mNbrOfLineToPrint)
{
QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, columnWidth, getRowHeight());
QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());
if(wStr.length())
{
wPainter.setPen(textColor);
wPainter.drawText(QRect(x + 4, y, columnWidth - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
}
}
// Paints cell right borders
wPainter.setPen(separatorColor);
wPainter.drawLine(x + columnWidth - 1, y, x + columnWidth - 1, y + getRowHeight() - 1);
wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);
// Update y for the next iteration
y += getRowHeight();
}
y = getHeaderHeight();
x += columnWidth;
x += getColumnWidth(j);
}
emit repainted();
}

View File

@ -187,6 +187,7 @@ protected:
QColor separatorColor;
QColor headerTextColor;
QColor selectionColor;
bool mAllowPainting;
};
#endif // ABSTRACTTABLEVIEW_H

View File

@ -975,6 +975,7 @@ void HexDump::appendDescriptor(int width, QString title, bool clickable, ColumnD
//Clears the descriptors, append a new descriptor and fix the tableOffset (use this instead of clearDescriptors()
void HexDump::appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor)
{
mAllowPainting = false;
if(mDescriptor.size())
{
int_t wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset;
@ -984,6 +985,7 @@ void HexDump::appendResetDescriptor(int width, QString title, bool clickable, Co
}
else
appendDescriptor(width, title, clickable, descriptor);
mAllowPainting = true;
}
void HexDump::clearDescriptors()