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

View File

@ -187,6 +187,7 @@ protected:
QColor separatorColor; QColor separatorColor;
QColor headerTextColor; QColor headerTextColor;
QColor selectionColor; QColor selectionColor;
bool mAllowPainting;
}; };
#endif // ABSTRACTTABLEVIEW_H #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() //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) void HexDump::appendResetDescriptor(int width, QString title, bool clickable, ColumnDescriptor_t descriptor)
{ {
mAllowPainting = false;
if(mDescriptor.size()) if(mDescriptor.size())
{ {
int_t wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset; int_t wRVA = getTableOffset() * getBytePerRowCount() - mByteOffset;
@ -984,6 +985,7 @@ void HexDump::appendResetDescriptor(int width, QString title, bool clickable, Co
} }
else else
appendDescriptor(width, title, clickable, descriptor); appendDescriptor(width, title, clickable, descriptor);
mAllowPainting = true;
} }
void HexDump::clearDescriptors() void HexDump::clearDescriptors()