commit
0d17101ba8
|
@ -67,14 +67,14 @@ void ReferenceView::setupContextMenu()
|
|||
connect(mFollowApiAddress, SIGNAL(triggered()), this, SLOT(followApiAddress()));
|
||||
|
||||
mToggleBreakpoint = new QAction("Toggle Breakpoint", this);
|
||||
mToggleBreakpoint->setShortcutContext(Qt::WidgetShortcut);
|
||||
mToggleBreakpoint->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
addAction(mToggleBreakpoint);
|
||||
mList->addAction(mToggleBreakpoint);
|
||||
mSearchList->addAction(mToggleBreakpoint);
|
||||
connect(mToggleBreakpoint, SIGNAL(triggered()), this, SLOT(toggleBreakpoint()));
|
||||
|
||||
mToggleBookmark = new QAction("Toggle Bookmark", this);
|
||||
mToggleBookmark->setShortcutContext(Qt::WidgetShortcut);
|
||||
mToggleBookmark->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
addAction(mToggleBookmark);
|
||||
mList->addAction(mToggleBookmark);
|
||||
mSearchList->addAction(mToggleBookmark);
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
#include "ui_SearchListView.h"
|
||||
#include "FlickerThread.h"
|
||||
|
||||
|
||||
SearchListView::SearchListView(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SearchListView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
mCursorPosition = 0;
|
||||
|
||||
// Create the reference list
|
||||
mList = new SearchListViewTable();
|
||||
|
||||
|
@ -51,9 +49,7 @@ SearchListView::SearchListView(QWidget* parent) :
|
|||
for(int i = 0; i < ui->mainSplitter->count(); i++)
|
||||
ui->mainSplitter->handle(i)->setEnabled(false);
|
||||
|
||||
// Install eventFilter
|
||||
mList->installEventFilter(this);
|
||||
mSearchList->installEventFilter(this);
|
||||
// Install event filter
|
||||
mSearchBox->installEventFilter(this);
|
||||
|
||||
// Setup search menu action
|
||||
|
@ -61,13 +57,15 @@ SearchListView::SearchListView(QWidget* parent) :
|
|||
connect(mSearchAction, SIGNAL(triggered()), this, SLOT(searchSlot()));
|
||||
|
||||
// Slots
|
||||
// connect(mList, SIGNAL(keyPressedSignal(QKeyEvent*)), this, SLOT(listKeyPressed(QKeyEvent*)));
|
||||
connect(mList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
||||
connect(mList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
|
||||
// connect(mSearchList, SIGNAL(keyPressedSignal(QKeyEvent*)), this, SLOT(listKeyPressed(QKeyEvent*)));
|
||||
connect(mSearchList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
||||
connect(mSearchList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
|
||||
connect(mSearchBox, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
|
||||
|
||||
// List input should always be forwarded to the filter edit
|
||||
mSearchList->setFocusProxy(mSearchBox);
|
||||
mList->setFocusProxy(mSearchBox);
|
||||
}
|
||||
|
||||
SearchListView::~SearchListView()
|
||||
|
@ -117,10 +115,9 @@ void SearchListView::searchTextChanged(const QString & arg1)
|
|||
{
|
||||
mSearchList->hide();
|
||||
mList->show();
|
||||
if(ui->checkBoxRegex->checkState() != Qt::Checked)
|
||||
mList->setFocus();
|
||||
mCurList = mList;
|
||||
}
|
||||
mCurList->setSingleSelection(0);
|
||||
mSearchList->setRowCount(0);
|
||||
int rows = mList->getRowCount();
|
||||
int columns = mList->getColumnCount();
|
||||
|
@ -155,11 +152,13 @@ void SearchListView::searchTextChanged(const QString & arg1)
|
|||
if(rows == 0)
|
||||
emit emptySearchResult();
|
||||
|
||||
if(ui->checkBoxRegex->checkState() != Qt::Checked) //do not highlight with regex
|
||||
mSearchList->highlightText = arg1;
|
||||
mSearchList->reloadData();
|
||||
// Do not highlight with regex
|
||||
if(ui->checkBoxRegex->checkState() != Qt::Checked)
|
||||
mSearchList->setFocus();
|
||||
mSearchList->highlightText = arg1;
|
||||
else
|
||||
mSearchList->highlightText = "";
|
||||
|
||||
mSearchList->reloadData();
|
||||
}
|
||||
|
||||
void SearchListView::listContextMenu(const QPoint & pos)
|
||||
|
@ -186,123 +185,42 @@ void SearchListView::on_checkBoxRegex_toggled(bool checked)
|
|||
searchTextChanged(ui->searchBox->text());
|
||||
}
|
||||
|
||||
void SearchListView::addCharToSearchBox(char ch)
|
||||
{
|
||||
QString newText;
|
||||
newText = mSearchBox->text();
|
||||
|
||||
// If text is selected
|
||||
if(mSearchBox->hasSelectedText())
|
||||
{
|
||||
QString selectedText = mSearchBox->selectedText();
|
||||
int indexOfSelectedText = newText.indexOf(selectedText);
|
||||
|
||||
if(indexOfSelectedText != -1)
|
||||
{
|
||||
newText.replace(indexOfSelectedText, selectedText.length(), QString(ch));
|
||||
mCursorPosition = indexOfSelectedText + 1;
|
||||
|
||||
mSearchBox->setText(newText);
|
||||
}
|
||||
|
||||
}
|
||||
// No text selected
|
||||
else
|
||||
{
|
||||
mSearchBox->setText(mSearchBox->text().insert(mSearchBox->cursorPosition(), QString(ch)));
|
||||
mCursorPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchListView::deleteTextFromSearchBox(QKeyEvent* keyEvent)
|
||||
{
|
||||
QString newText;
|
||||
newText = mSearchBox->text();
|
||||
|
||||
// If Ctrl key pressed
|
||||
if(keyEvent->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
newText = "";
|
||||
mCursorPosition = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If text is selected
|
||||
if(mSearchBox->hasSelectedText())
|
||||
{
|
||||
QString selectedText = mSearchBox->selectedText();
|
||||
int indexOfSelectedText = newText.indexOf(selectedText);
|
||||
|
||||
if(indexOfSelectedText != -1)
|
||||
{
|
||||
newText.remove(indexOfSelectedText, selectedText.length());
|
||||
mCursorPosition = indexOfSelectedText;
|
||||
}
|
||||
}
|
||||
// No text selected
|
||||
else
|
||||
{
|
||||
// Backspace Key
|
||||
if(keyEvent->key() == Qt::Key_Backspace)
|
||||
{
|
||||
if(mCursorPosition > 0)
|
||||
newText.remove(mCursorPosition - 1, 1);
|
||||
|
||||
(mCursorPosition - 1) < 0 ? mCursorPosition = 0 : mCursorPosition--;
|
||||
}
|
||||
// Delete Key
|
||||
else
|
||||
{
|
||||
if(mCursorPosition < newText.length())
|
||||
newText.remove(mCursorPosition, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mSearchBox->setText(newText);
|
||||
}
|
||||
|
||||
bool SearchListView::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if(obj == mSearchBox && event->type() == QEvent::MouseButtonPress) // Click in searchBox
|
||||
{
|
||||
// Give focus to current list to avoid having it elsewhere when you click on a different searchbox
|
||||
mCurList->setFocus();
|
||||
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
QLineEdit* lineEdit = static_cast<QLineEdit*>(obj);
|
||||
|
||||
mCursorPosition = lineEdit->cursorPositionAt(mouseEvent->pos());
|
||||
lineEdit->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
else if((obj == mList || obj == mSearchList || obj == mSearchBox) && event->type() == QEvent::KeyPress) // KeyPress in List
|
||||
// Keyboard button press being sent to the QLineEdit
|
||||
if(obj == mSearchBox && event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
char ch = keyEvent->text().toUtf8().constData()[0];
|
||||
|
||||
//add a char to the search box
|
||||
if(isprint(ch))
|
||||
{
|
||||
addCharToSearchBox(ch);
|
||||
}
|
||||
else if(keyEvent->key() == Qt::Key_Backspace || keyEvent->key() == Qt::Key_Delete) //remove a char from the search box
|
||||
{
|
||||
deleteTextFromSearchBox(keyEvent);
|
||||
}
|
||||
else if((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)) // user pressed enter
|
||||
switch(keyEvent->key())
|
||||
{
|
||||
// The user pressed enter/return
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
if(mCurList->getCellContent(mCurList->getInitialSelection(), 0).length())
|
||||
emit enterPressedSignal();
|
||||
}
|
||||
else if(keyEvent->key() == Qt::Key_Escape) // Press escape, clears the search box
|
||||
{
|
||||
return true;
|
||||
|
||||
// Search box misc controls
|
||||
case Qt::Key_Escape:
|
||||
mSearchBox->clear();
|
||||
mCursorPosition = 0;
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Backspace:
|
||||
case Qt::Key_Delete:
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
// Update cursorPosition to avoid a weird bug
|
||||
mSearchBox->setCursorPosition(mCursorPosition);
|
||||
// Printable characters go to the search box
|
||||
char key = keyEvent->text().toUtf8().constData()[0];
|
||||
|
||||
if(isprint(key))
|
||||
return QWidget::eventFilter(obj, event);
|
||||
|
||||
// By default, all other keys are forwarded to the search view
|
||||
return QApplication::sendEvent(mCurList, event);
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,17 +41,14 @@ signals:
|
|||
void listContextMenuSignal(QMenu* wMenu);
|
||||
void emptySearchResult();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private:
|
||||
Ui::SearchListView* ui;
|
||||
QVBoxLayout* mListLayout;
|
||||
QWidget* mListPlaceHolder;
|
||||
QAction* mSearchAction;
|
||||
int mCursorPosition;
|
||||
void addCharToSearchBox(char ch);
|
||||
void deleteTextFromSearchBox(QKeyEvent* keyEvent);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
};
|
||||
|
||||
#endif // SEARCHLISTVIEW_H
|
||||
|
|
|
@ -92,7 +92,7 @@ void SymbolView::setupContextMenu()
|
|||
{
|
||||
//Symbols
|
||||
mFollowSymbolAction = new QAction("&Follow in Disassembler", this);
|
||||
mFollowSymbolAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
mFollowSymbolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
mFollowSymbolAction->setShortcut(QKeySequence("enter"));
|
||||
connect(mFollowSymbolAction, SIGNAL(triggered()), this, SLOT(symbolFollow()));
|
||||
|
||||
|
@ -100,14 +100,14 @@ void SymbolView::setupContextMenu()
|
|||
connect(mFollowSymbolDumpAction, SIGNAL(triggered()), this, SLOT(symbolFollowDump()));
|
||||
|
||||
mToggleBreakpoint = new QAction("Toggle Breakpoint", this);
|
||||
mToggleBreakpoint->setShortcutContext(Qt::WidgetShortcut);
|
||||
mToggleBreakpoint->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
this->addAction(mToggleBreakpoint);
|
||||
mSearchListView->mList->addAction(mToggleBreakpoint);
|
||||
mSearchListView->mSearchList->addAction(mToggleBreakpoint);
|
||||
connect(mToggleBreakpoint, SIGNAL(triggered()), this, SLOT(toggleBreakpoint()));
|
||||
|
||||
mToggleBookmark = new QAction("Toggle Bookmark", this);
|
||||
mToggleBookmark->setShortcutContext(Qt::WidgetShortcut);
|
||||
mToggleBookmark->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
this->addAction(mToggleBookmark);
|
||||
mSearchListView->mList->addAction(mToggleBookmark);
|
||||
mSearchListView->mSearchList->addAction(mToggleBookmark);
|
||||
|
@ -115,7 +115,7 @@ void SymbolView::setupContextMenu()
|
|||
|
||||
//Modules
|
||||
mFollowModuleAction = new QAction("&Follow in Disassembler", this);
|
||||
mFollowModuleAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
mFollowModuleAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
mFollowModuleAction->setShortcut(QKeySequence("enter"));
|
||||
connect(mFollowModuleAction, SIGNAL(triggered()), this, SLOT(moduleFollow()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue