GUI: fixed massive performance issue in the AppearanceDialog + added search result highlighting to the SearchListView (symbols+references) + fixed a small bug with inserting in the searchlistview
This commit is contained in:
parent
e9816c44ce
commit
a4584be52e
|
@ -68,7 +68,7 @@ void SearchListView::listKeyPressed(QKeyEvent* event)
|
|||
{
|
||||
char ch = event->text().toUtf8().constData()[0];
|
||||
if(isprint(ch)) //add a char to the search box
|
||||
mSearchBox->setText(mSearchBox->text() + QString(QChar(ch)));
|
||||
mSearchBox->setText(mSearchBox->text().insert(mSearchBox->cursorPosition(), QString(QChar(ch))));
|
||||
else if(event->key() == Qt::Key_Backspace) //remove a char from the search box
|
||||
{
|
||||
QString newText;
|
||||
|
@ -150,6 +150,7 @@ void SearchListView::searchTextChanged(const QString & arg1)
|
|||
break;
|
||||
}
|
||||
}
|
||||
mSearchList->highlightText = arg1;
|
||||
mSearchList->reloadData();
|
||||
mSearchList->setFocus();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
SearchListViewTable::SearchListViewTable(StdTable* parent) : StdTable(parent)
|
||||
{
|
||||
highlightText = "";
|
||||
}
|
||||
|
||||
QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h)
|
||||
|
@ -24,7 +25,7 @@ QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int
|
|||
{
|
||||
BPXTYPE bpxtype = DbgGetBpxTypeAt(wVA);
|
||||
bool isbookmark = DbgGetBookmarkAt(wVA);
|
||||
painter->setPen(ConfigColor("AbstractTableViewTextColor"));
|
||||
painter->setPen(textColor);
|
||||
if(!isbookmark)
|
||||
{
|
||||
if(bpxtype & bp_normal) //normal breakpoint
|
||||
|
@ -69,5 +70,38 @@ QString SearchListViewTable::paintContent(QPainter* painter, int_t rowBase, int
|
|||
painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, text);
|
||||
text = "";
|
||||
}
|
||||
if(highlightText.length() && text.contains(highlightText, Qt::CaseInsensitive))
|
||||
{
|
||||
//super smart way of splitting while keeping the delimiters (thanks to cypher for guidance)
|
||||
int index = -2;
|
||||
do
|
||||
{
|
||||
index = text.indexOf(highlightText, index + 2, Qt::CaseInsensitive);
|
||||
if(index != -1)
|
||||
{
|
||||
text = text.insert(index + highlightText.length(), QChar('\1'));
|
||||
text = text.insert(index, QChar('\1'));
|
||||
}
|
||||
}
|
||||
while(index != -1);
|
||||
QStringList split = text.split(QChar('\1'), QString::KeepEmptyParts, Qt::CaseInsensitive);
|
||||
|
||||
//create rich text list
|
||||
RichTextPainter::CustomRichText_t curRichText;
|
||||
curRichText.flags = RichTextPainter::FlagColor;
|
||||
curRichText.textColor = textColor;
|
||||
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
|
||||
QList<RichTextPainter::CustomRichText_t> richText;
|
||||
foreach(QString str, split)
|
||||
{
|
||||
curRichText.text = str;
|
||||
curRichText.highlight = !str.compare(highlightText, Qt::CaseInsensitive);
|
||||
richText.push_back(curRichText);
|
||||
}
|
||||
|
||||
//paint the rich text
|
||||
RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, &richText, getCharWidth());
|
||||
text = "";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ class SearchListViewTable : public StdTable
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchListViewTable(StdTable* parent = 0);
|
||||
QString highlightText;
|
||||
|
||||
protected:
|
||||
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
|
||||
|
|
|
@ -174,7 +174,7 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
|
|||
{
|
||||
(*colorMap)[id] = Qt::transparent;
|
||||
ui->buttonSave->setEnabled(true);
|
||||
Config()->writeColors();
|
||||
Config()->emitColorsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
|
|||
{
|
||||
(*colorMap)[id] = QColor(text);
|
||||
ui->buttonSave->setEnabled(true);
|
||||
Config()->writeColors();
|
||||
Config()->emitColorsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
}
|
||||
|
@ -216,6 +216,7 @@ void AppearanceDialog::on_editColor_textChanged(const QString & arg1)
|
|||
ui->editColor->setText("#" + arg1);
|
||||
text = ui->editColor->text();
|
||||
}
|
||||
|
||||
QString id = colorInfoList.at(colorInfoIndex).colorName;
|
||||
QString styleSheet;
|
||||
if(QColor(text).isValid())
|
||||
|
@ -225,7 +226,7 @@ void AppearanceDialog::on_editColor_textChanged(const QString & arg1)
|
|||
{
|
||||
(*colorMap)[id] = QColor(text);
|
||||
ui->buttonSave->setEnabled(true);
|
||||
Config()->writeColors();
|
||||
Config()->emitColorsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
}
|
||||
|
@ -320,6 +321,7 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
|
|||
void AppearanceDialog::on_buttonSave_clicked()
|
||||
{
|
||||
Config()->writeColors();
|
||||
Config()->writeFonts();
|
||||
GuiUpdateAllViews();
|
||||
GuiAddStatusBarMessage("Settings saved!\n");
|
||||
}
|
||||
|
@ -515,6 +517,7 @@ void AppearanceDialog::colorInfoListInit()
|
|||
colorInfoListAppend("Current Thread", "ThreadCurrentColor", "ThreadCurrentBackgroundColor");
|
||||
colorInfoListAppend("Memory Map Breakpoint", "MemoryMapBreakpointColor", "MemoryMapBreakpointBackgroundColor");
|
||||
colorInfoListAppend("Memory Map Section Text", "MemoryMapSectionTextColor", "");
|
||||
colorInfoListAppend("Search Highlight Color", "SearchListViewHighlightColor", "");
|
||||
|
||||
//dev helper
|
||||
const QMap<QString, QColor>* Colors = &Config()->defaultColors;
|
||||
|
@ -655,7 +658,7 @@ void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -672,7 +675,7 @@ void AppearanceDialog::on_fontAbstractTablesStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -684,7 +687,7 @@ void AppearanceDialog::on_fontAbstractTablesSize_currentIndexChanged(const QStri
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -696,7 +699,7 @@ void AppearanceDialog::on_fontDisassembly_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -713,7 +716,7 @@ void AppearanceDialog::on_fontDisassemblyStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -725,7 +728,7 @@ void AppearanceDialog::on_fontDisassemblySize_currentIndexChanged(const QString
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -737,7 +740,7 @@ void AppearanceDialog::on_fontHexDump_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -754,7 +757,7 @@ void AppearanceDialog::on_fontHexDumpStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -766,7 +769,7 @@ void AppearanceDialog::on_fontHexDumpSize_currentIndexChanged(const QString & ar
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -778,7 +781,7 @@ void AppearanceDialog::on_fontStack_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -795,7 +798,7 @@ void AppearanceDialog::on_fontStackStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -807,7 +810,7 @@ void AppearanceDialog::on_fontStackSize_currentIndexChanged(const QString & arg1
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -819,7 +822,7 @@ void AppearanceDialog::on_fontRegisters_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -836,7 +839,7 @@ void AppearanceDialog::on_fontRegistersStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -848,7 +851,7 @@ void AppearanceDialog::on_fontRegistersSize_currentIndexChanged(const QString &
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -860,7 +863,7 @@ void AppearanceDialog::on_fontHexEdit_currentFontChanged(const QFont & f)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -877,7 +880,7 @@ void AppearanceDialog::on_fontHexEditStyle_currentIndexChanged(int index)
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -889,7 +892,7 @@ void AppearanceDialog::on_fontHexEditSize_currentIndexChanged(const QString & ar
|
|||
(*fontMap)[id] = font;
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -904,7 +907,7 @@ void AppearanceDialog::on_buttonApplicationFont_clicked()
|
|||
ui->labelApplicationFont->setText(fontDialog.currentFont().family());
|
||||
if(isInit)
|
||||
return;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
|
@ -914,15 +917,15 @@ void AppearanceDialog::on_buttonFontDefaults_clicked()
|
|||
isInit = true;
|
||||
fontInit();
|
||||
isInit = false;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
||||
void AppearanceDialog::rejectedSlot()
|
||||
{
|
||||
Config()->Colors = colorBackupMap;
|
||||
Config()->writeColors();
|
||||
Config()->emitColorsUpdated();
|
||||
Config()->Fonts = fontBackupMap;
|
||||
Config()->writeFonts();
|
||||
Config()->emitFontsUpdated();
|
||||
GuiUpdateAllViews();
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ Configuration::Configuration() : QObject()
|
|||
defaultColors.insert("MemoryMapBreakpointColor", QColor("#FFFBF0"));
|
||||
defaultColors.insert("MemoryMapBreakpointBackgroundColor", QColor("#FF0000"));
|
||||
defaultColors.insert("MemoryMapSectionTextColor", QColor("#8B671F"));
|
||||
defaultColors.insert("SearchListViewHighlightColor", QColor("#FF0000"));
|
||||
|
||||
//bool settings
|
||||
QMap<QString, bool> disassemblyBool;
|
||||
|
@ -305,6 +306,11 @@ void Configuration::writeColors()
|
|||
emit colorsUpdated();
|
||||
}
|
||||
|
||||
void Configuration::emitColorsUpdated()
|
||||
{
|
||||
emit colorsUpdated();
|
||||
}
|
||||
|
||||
void Configuration::readBools()
|
||||
{
|
||||
Bools = defaultBools;
|
||||
|
@ -392,6 +398,11 @@ void Configuration::writeFonts()
|
|||
emit fontsUpdated();
|
||||
}
|
||||
|
||||
void Configuration::emitFontsUpdated()
|
||||
{
|
||||
emit fontsUpdated();
|
||||
}
|
||||
|
||||
void Configuration::readShortcuts()
|
||||
{
|
||||
Shortcuts = defaultShortcuts;
|
||||
|
|
|
@ -42,12 +42,14 @@ public:
|
|||
void save();
|
||||
void readColors();
|
||||
void writeColors();
|
||||
void emitColorsUpdated();
|
||||
void readBools();
|
||||
void writeBools();
|
||||
void readUints();
|
||||
void writeUints();
|
||||
void readFonts();
|
||||
void writeFonts();
|
||||
void emitFontsUpdated();
|
||||
void readShortcuts();
|
||||
void writeShortcuts();
|
||||
|
||||
|
|
Loading…
Reference in New Issue