GUI: removed unneeded painter->save() and painter->restore()
This commit is contained in:
parent
563af7797d
commit
9aa1ae95ed
|
|
@ -112,10 +112,8 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
|
|||
|
||||
mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter,&mHeaderButtonSytle);
|
||||
|
||||
wPainter.save();
|
||||
wPainter.setPen(headerTextColor);
|
||||
wPainter.drawText(QRect(x + 4, y, getColumnWidth(i) - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);
|
||||
wPainter.restore();
|
||||
|
||||
x += getColumnWidth(i);
|
||||
}
|
||||
|
|
@ -134,18 +132,14 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
|
|||
QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());
|
||||
if(wStr.length())
|
||||
{
|
||||
wPainter.save();
|
||||
wPainter.setPen(textColor);
|
||||
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
|
||||
wPainter.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// Paints cell right borders
|
||||
wPainter.save();
|
||||
wPainter.setPen(separatorColor);
|
||||
wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);
|
||||
wPainter.restore();
|
||||
|
||||
// Update y for the next iteration
|
||||
y += getRowHeight();
|
||||
|
|
|
|||
|
|
@ -68,14 +68,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
{
|
||||
if(mHighlightingMode)
|
||||
{
|
||||
painter->save();
|
||||
QPen pen(ConfigColor("InstructionHighlightColor"));
|
||||
pen.setWidth(2);
|
||||
painter->setPen(pen);
|
||||
QRect rect=viewport()->rect();
|
||||
rect.adjust(1, 1, -1, -1);
|
||||
painter->drawRect(rect);
|
||||
painter->restore();
|
||||
}
|
||||
int_t wRVA = mInstBuffer.at(rowOffset).rva;
|
||||
bool wIsSelected = isSelected(&mInstBuffer, rowOffset);
|
||||
|
|
@ -132,7 +130,6 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
*label=0;
|
||||
BPXTYPE bpxtype=DbgGetBpxTypeAt(cur_addr);
|
||||
bool isbookmark=DbgGetBookmarkAt(cur_addr);
|
||||
painter->save();
|
||||
if(mInstBuffer.at(rowOffset).rva == mCipRva) //cip
|
||||
{
|
||||
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyCipBackgroundColor")));
|
||||
|
|
@ -306,7 +303,6 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
}
|
||||
}
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -339,14 +335,12 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
int jumpsize = paintJumpsGraphic(painter, x + funcsize, y, wRVA); //jump line
|
||||
|
||||
//draw bytes
|
||||
painter->save();
|
||||
painter->setPen(ConfigColor("DisassemblyBytesColor"));
|
||||
QString wBytes = "";
|
||||
for(int i = 0; i < mInstBuffer.at(rowOffset).dump.size(); i++)
|
||||
wBytes += QString("%1").arg((unsigned char)(mInstBuffer.at(rowOffset).dump.at(i)), 2, 16, QChar('0')).toUpper()+" ";
|
||||
|
||||
painter->drawText(QRect(x + jumpsize + funcsize, y, getColumnWidth(col) - jumpsize - funcsize, getRowHeight()), 0, wBytes);
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -402,7 +396,6 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
char comment[MAX_COMMENT_SIZE]="";
|
||||
if(DbgGetCommentAt(mInstBuffer.at(rowOffset).rva+mBase, comment))
|
||||
{
|
||||
painter->save();
|
||||
painter->setPen(ConfigColor("DisassemblyCommentColor"));
|
||||
int width = QFontMetrics(this->font()).width(comment)+4;
|
||||
if(width > w)
|
||||
|
|
@ -410,7 +403,6 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse
|
|||
if(width)
|
||||
painter->fillRect(QRect(x + 2, y, width, h), QBrush(ConfigColor("DisassemblyCommentBackgroundColor"))); //fill bookmark color
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment));
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -726,8 +718,6 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
|
|||
}
|
||||
}
|
||||
|
||||
painter->save();
|
||||
|
||||
bool bIsExecute=DbgIsJumpGoingToExecute(instruction.rva+mBase);
|
||||
|
||||
if(branchType==JmpType) //unconditional
|
||||
|
|
@ -783,8 +773,6 @@ int Disassembly::paintJumpsGraphic(QPainter* painter, int x, int y, int_t addr)
|
|||
painter->drawPolyline(wPoints, 3);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
|
||||
return 7;
|
||||
}
|
||||
|
||||
|
|
@ -806,7 +794,6 @@ int Disassembly::paintFunctionGraphic(QPainter* painter, int x, int y, Function_
|
|||
{
|
||||
if(loop && funcType==Function_none)
|
||||
return 0;
|
||||
painter->save();
|
||||
painter->setPen(QPen(Qt::black, 2)); //thick black line
|
||||
int height=getRowHeight();
|
||||
int x_add=5;
|
||||
|
|
@ -874,7 +861,6 @@ int Disassembly::paintFunctionGraphic(QPainter* painter, int x, int y, Function_
|
|||
}
|
||||
break;
|
||||
}
|
||||
painter->restore();
|
||||
return x_add+line_width+end_add;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -221,10 +221,8 @@ void HexDump::printSelected(QPainter* painter, int_t rowBase, int rowOffset, int
|
|||
wSelectionX = x + wI * wItemPixWidth;
|
||||
wSelectionWidth = wItemPixWidth > w - (wSelectionX - x) ? w - (wSelectionX - x) : wItemPixWidth;
|
||||
wSelectionWidth = wSelectionWidth < 0 ? 0 : wSelectionWidth;
|
||||
painter->save();
|
||||
painter->setPen(textColor);
|
||||
painter->fillRect(QRect(wSelectionX, y, wSelectionWidth, h), QBrush(selectionColor));
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
|||
}
|
||||
else
|
||||
*label=0;
|
||||
painter->save();
|
||||
if(*label) //label
|
||||
{
|
||||
QColor background=ConfigColor("HexDumpLabelBackgroundColor");
|
||||
|
|
@ -176,7 +175,6 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
|
|||
painter->setPen(ConfigColor("HexDumpAddressColor")); //TODO: config
|
||||
}
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
|
||||
painter->restore();
|
||||
}
|
||||
else if(col && mDescriptor.at(col - 1).isData == false && mDescriptor.at(col -1).itemCount == 1) //print comments
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
|||
|
||||
if(col == 0) // paint stack address
|
||||
{
|
||||
painter->save();
|
||||
char label[MAX_LABEL_SIZE]="";
|
||||
QString addrText="";
|
||||
int_t curAddr = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset + this->mBase;
|
||||
|
|
@ -149,23 +148,19 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
|||
if(background.alpha())
|
||||
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background when defined
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, addrText);
|
||||
painter->restore();
|
||||
}
|
||||
else if(mDescriptor.at(col - 1).isData == true) //paint stack data
|
||||
{
|
||||
QString wStr=HexDump::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
|
||||
painter->save();
|
||||
if(wActiveStack)
|
||||
painter->setPen(QPen(textColor));
|
||||
else
|
||||
painter->setPen(QPen(ConfigColor("StackInactiveTextColor")));
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, wStr);
|
||||
painter->restore();
|
||||
}
|
||||
else if(DbgStackCommentGet(mMemPage->getBase()+wRva, &comment)) //paint stack comments
|
||||
{
|
||||
QString wStr = QString(comment.comment);
|
||||
painter->save();
|
||||
if(wActiveStack)
|
||||
{
|
||||
if(*comment.color)
|
||||
|
|
@ -176,7 +171,6 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
|
|||
else
|
||||
painter->setPen(QPen(ConfigColor("StackInactiveTextColor")));
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, wStr);
|
||||
painter->restore();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,7 +406,6 @@ void RegistersView::drawRegister(QPainter *p,REGISTER_NAME reg, uint_t value)
|
|||
//p->drawText(offset,mRowHeight*(mRegisterPlaces[reg].line+1),mRegisterMapping[reg]);
|
||||
|
||||
//set highlighting
|
||||
p->save();
|
||||
if(DbgIsDebugging() && mRegisterUpdates.contains(reg))
|
||||
p->setPen(ConfigColor("RegistersModifiedColor"));
|
||||
else
|
||||
|
|
@ -425,7 +424,6 @@ void RegistersView::drawRegister(QPainter *p,REGISTER_NAME reg, uint_t value)
|
|||
width = mCharWidth * valueText.length();
|
||||
p->drawText(x, y, width, mRowHeight, Qt::AlignVCenter, valueText);
|
||||
//p->drawText(x + (mRegisterPlaces[reg].labelwidth)*mCharWidth ,mRowHeight*(mRegisterPlaces[reg].line+1),QString("%1").arg(value, mRegisterPlaces[reg].valuesize, 16, QChar('0')).toUpper());
|
||||
p->restore(); //do not highlight the labels
|
||||
// do we have a label ?
|
||||
char label_text[MAX_LABEL_SIZE]="";
|
||||
char module_text[MAX_MODULE_SIZE]="";
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
|
|||
case 0: //line number
|
||||
{
|
||||
returnString=returnString.sprintf("%.4d", line);
|
||||
painter->save();
|
||||
if(line==mIpLine) //IP
|
||||
{
|
||||
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("DisassemblyCipBackgroundColor")));
|
||||
|
|
@ -86,7 +85,6 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
|
|||
painter->fillRect(QRect(x, y, w, h), QBrush(background)); //fill background
|
||||
}
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, returnString);
|
||||
painter->restore();
|
||||
returnString="";
|
||||
}
|
||||
break;
|
||||
|
|
@ -96,7 +94,6 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
|
|||
if(mEnableSyntaxHighlighting)
|
||||
{
|
||||
//initialize
|
||||
painter->save();
|
||||
int charwidth=QFontMetrics(this->font()).width(QChar(' '));
|
||||
int xadd=charwidth; //for testing
|
||||
QList<RichTextPainter::CustomRichText_t> richText;
|
||||
|
|
@ -255,7 +252,6 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
|
|||
|
||||
//paint the rich text
|
||||
RichTextPainter::paintRichText(painter, x+1, y, w, h, xadd, &richText, charwidth);
|
||||
painter->restore();
|
||||
returnString="";
|
||||
}
|
||||
else //no syntax highlighting
|
||||
|
|
|
|||
|
|
@ -199,11 +199,9 @@ QString ThreadView::paintContent(QPainter* painter, int_t rowBase, int rowOffset
|
|||
QString ret=StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
|
||||
if(rowBase+rowOffset==mCurrentThread && !col)
|
||||
{
|
||||
painter->save();
|
||||
painter->fillRect(QRect(x, y, w, h), QBrush(ConfigColor("ThreadCurrentBackgroundColor")));
|
||||
painter->setPen(QPen(ConfigColor("ThreadCurrentColor"))); //white text
|
||||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret);
|
||||
painter->restore();
|
||||
ret="";
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,35 +19,27 @@ void RichTextPainter::paintRichText(QPainter* painter, int x, int y, int w, int
|
|||
painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text);
|
||||
break;
|
||||
case FlagColor: //color only
|
||||
painter->save();
|
||||
painter->setPen(QPen(curRichText.textColor));
|
||||
painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text);
|
||||
painter->restore();
|
||||
break;
|
||||
case FlagBackground: //background only
|
||||
painter->save();
|
||||
if(backgroundWidth>0)
|
||||
painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground));
|
||||
painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text);
|
||||
painter->restore();
|
||||
break;
|
||||
case FlagAll: //color+background
|
||||
painter->save();
|
||||
if(backgroundWidth>0)
|
||||
painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground));
|
||||
painter->setPen(QPen(curRichText.textColor));
|
||||
painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text);
|
||||
painter->restore();
|
||||
break;
|
||||
}
|
||||
if(curRichText.highlight)
|
||||
{
|
||||
painter->save();
|
||||
QPen pen(curRichText.highlightColor);
|
||||
pen.setWidth(2);
|
||||
painter->setPen(pen);
|
||||
painter->drawLine(x+xinc+1, y+h-1, x+xinc+backgroundWidth-1, y+h-1);
|
||||
painter->restore();
|
||||
}
|
||||
xinc+=charwidth*curRichTextLength;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue