Moved disassembly popup to AbstractTableView and added its support in StdTable
This commit is contained in:
parent
6705ce1af3
commit
707cd444ae
|
@ -999,3 +999,26 @@ void AbstractStdTable::reloadData()
|
|||
}
|
||||
AbstractTableView::reloadData();
|
||||
}
|
||||
|
||||
duint AbstractStdTable::getDisassemblyPopupAddress(int mousex, int mousey)
|
||||
{
|
||||
int c = getColumnIndexFromX(mousex);
|
||||
int r = getTableOffset() + getIndexOffsetFromY(transY(mousey));
|
||||
if(r < getRowCount())
|
||||
{
|
||||
QString cell = getCellContent(r, c);
|
||||
duint addr;
|
||||
bool ok = false;
|
||||
#ifdef _WIN64
|
||||
addr = cell.toULongLong(&ok, 16);
|
||||
#else //x86
|
||||
addr = cell.toULong(&ok, 16);
|
||||
#endif //_WIN64
|
||||
if(!ok)
|
||||
return 0;
|
||||
else
|
||||
return addr;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
virtual QString getCellContent(int r, int c) = 0;
|
||||
virtual bool isValidIndex(int r, int c) = 0;
|
||||
virtual void sortRows(int column, bool ascending) = 0;
|
||||
duint getDisassemblyPopupAddress(int mousex, int mousey) override;
|
||||
|
||||
//context menu helpers
|
||||
void setupCopyMenu(QMenu* copyMenu);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ColumnReorderDialog.h"
|
||||
#include "CachedFontMetrics.h"
|
||||
#include "Bridge.h"
|
||||
#include "DisassemblyPopup.h"
|
||||
#include <windows.h>
|
||||
|
||||
int AbstractTableView::mMouseWheelScrollDelta = 0;
|
||||
|
@ -28,7 +29,8 @@ void AbstractTableScrollBar::leaveEvent(QEvent* event)
|
|||
|
||||
AbstractTableView::AbstractTableView(QWidget* parent)
|
||||
: QAbstractScrollArea(parent),
|
||||
mFontMetrics(nullptr)
|
||||
mFontMetrics(nullptr),
|
||||
mDisassemblyPopup(nullptr)
|
||||
{
|
||||
// Class variable initialization
|
||||
mTableOffset = 0;
|
||||
|
@ -369,16 +371,21 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
|
|||
mColResizeData.splitHandle = true;
|
||||
mGuiState = AbstractTableView::ReadyToResize;
|
||||
}
|
||||
if((wHandle == false) && (wHasCursor == true))
|
||||
else if((wHandle == false) && (wHasCursor == true))
|
||||
{
|
||||
unsetCursor();
|
||||
mColResizeData.splitHandle = false;
|
||||
mGuiState = AbstractTableView::NoState;
|
||||
}
|
||||
else if(wHandle == false && wHasCursor == false)
|
||||
{
|
||||
if(event->y() > getHeaderHeight())
|
||||
ShowDisassemblyPopup(getDisassemblyPopupAddress(event->x(), event->y()), event->x(), event->y());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QWidget::mouseMoveEvent(event);
|
||||
QAbstractScrollArea::mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -596,6 +603,7 @@ void AbstractTableView::wheelEvent(QWheelEvent* event)
|
|||
else // -1 : one screen at a time
|
||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
|
||||
}
|
||||
QAbstractScrollArea::wheelEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
@ -614,7 +622,13 @@ void AbstractTableView::resizeEvent(QResizeEvent* event)
|
|||
emit viewableRowsChanged(getViewableRowsCount());
|
||||
mShouldReload = true;
|
||||
}
|
||||
QWidget::resizeEvent(event);
|
||||
QAbstractScrollArea::resizeEvent(event);
|
||||
}
|
||||
|
||||
void AbstractTableView::leaveEvent(QEvent* event)
|
||||
{
|
||||
ShowDisassemblyPopup(0, 0, 0);
|
||||
QAbstractScrollArea::leaveEvent(event);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -1256,3 +1270,39 @@ void AbstractTableView::prepareData()
|
|||
dsint wRemainingRowsCount = getRowCount() - mTableOffset;
|
||||
mNbrOfLineToPrint = (dsint)wRemainingRowsCount > (dsint)wViewableRowsCount ? (int)wViewableRowsCount : (int)wRemainingRowsCount;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
DisassemblyPopup
|
||||
************************************************************************************/
|
||||
duint AbstractTableView::getDisassemblyPopupAddress(int mousex, int mousey)
|
||||
{
|
||||
return 0; //Default is no disassembly popup
|
||||
}
|
||||
|
||||
void AbstractTableView::ShowDisassemblyPopup(duint addr, int x, int y)
|
||||
{
|
||||
if(!addr)
|
||||
{
|
||||
if(mDisassemblyPopup)
|
||||
mDisassemblyPopup->hide();
|
||||
return;
|
||||
}
|
||||
if(!mDisassemblyPopup)
|
||||
mDisassemblyPopup = new DisassemblyPopup(this);
|
||||
if(mDisassemblyPopup->getAddress() == addr)
|
||||
return;
|
||||
if(DbgFunctions()->MemIsCodePage(addr, false))
|
||||
{
|
||||
mDisassemblyPopup->move(mapToGlobal(QPoint(x + 20, y + fontMetrics().height() * 2)));
|
||||
mDisassemblyPopup->setAddress(addr);
|
||||
mDisassemblyPopup->show();
|
||||
}
|
||||
else
|
||||
mDisassemblyPopup->hide();
|
||||
}
|
||||
|
||||
void AbstractTableView::hideEvent(QHideEvent* event)
|
||||
{
|
||||
ShowDisassemblyPopup(0, 0, 0);
|
||||
QAbstractScrollArea::hideEvent(event);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "ActionHelpers.h"
|
||||
|
||||
class CachedFontMetrics;
|
||||
class DisassemblyPopup;
|
||||
|
||||
//Hacky class that fixes a really annoying cursor problem
|
||||
class AbstractTableScrollBar : public QScrollBar
|
||||
|
@ -64,6 +65,8 @@ public:
|
|||
void wheelEvent(QWheelEvent* event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void leaveEvent(QEvent* event) override;
|
||||
void hideEvent(QHideEvent* event) override;
|
||||
|
||||
// ScrollBar Management
|
||||
virtual dsint sliderMovedHook(int type, dsint value, dsint delta);
|
||||
|
@ -120,6 +123,8 @@ public:
|
|||
// Update/Reload/Refresh/Repaint
|
||||
virtual void prepareData();
|
||||
|
||||
virtual duint getDisassemblyPopupAddress(int mousex, int mousey);
|
||||
|
||||
signals:
|
||||
void enterPressedSignal();
|
||||
void headerButtonPressed(int col);
|
||||
|
@ -218,6 +223,10 @@ protected:
|
|||
// Font metrics
|
||||
CachedFontMetrics* mFontMetrics;
|
||||
void invalidateCachedFont();
|
||||
|
||||
// Disassembly Popup
|
||||
DisassemblyPopup* mDisassemblyPopup;
|
||||
void ShowDisassemblyPopup(duint addr, int x, int y);
|
||||
};
|
||||
|
||||
#endif // ABSTRACTTABLEVIEW_H
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
#include "StdSearchListView.h"
|
||||
#include "StdTable.h"
|
||||
//#include "CachedFontMetrics.h"
|
||||
#include "DisassemblyPopup.h"
|
||||
|
||||
void StdTableMouseMove::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
emit mouseMoveSignal(event);
|
||||
}
|
||||
|
||||
class StdTableSearchList : public AbstractSearchList
|
||||
{
|
||||
public:
|
||||
friend class StdSearchListView;
|
||||
|
||||
StdTableSearchList() : mList(new StdTableMouseMove()), mSearchList(new StdTableMouseMove()) { }
|
||||
StdTableSearchList() : mList(new StdTable()), mSearchList(new StdTable()) { }
|
||||
~StdTableSearchList() {delete mList; delete mSearchList; }
|
||||
|
||||
void lock() override { }
|
||||
|
@ -42,17 +35,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
StdTableMouseMove* mList;
|
||||
StdTableMouseMove* mSearchList;
|
||||
StdTable* mList;
|
||||
StdTable* mSearchList;
|
||||
};
|
||||
|
||||
StdSearchListView::StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock)
|
||||
: SearchListView(parent, mSearchListData = new StdTableSearchList(), enableRegex, enableLock)
|
||||
{
|
||||
setAddressColumn(0);
|
||||
mDisassemblyPopup = nullptr;
|
||||
connect(mSearchListData->mList, SIGNAL(mouseMoveSignal(QMouseEvent*)), this, SLOT(mouseMoveSlot(QMouseEvent*)));
|
||||
connect(mSearchListData->mSearchList, SIGNAL(mouseMoveSignal(QMouseEvent*)), this, SLOT(mouseMoveSlot(QMouseEvent*)));
|
||||
}
|
||||
|
||||
StdSearchListView::~StdSearchListView()
|
||||
|
@ -134,60 +124,3 @@ StdTable* StdSearchListView::stdSearchList()
|
|||
{
|
||||
return mSearchListData->mSearchList;
|
||||
}
|
||||
|
||||
void StdSearchListView::mouseMoveSlot(QMouseEvent* event)
|
||||
{
|
||||
StdTable* that;
|
||||
that = qobject_cast<StdTable*>(sender());
|
||||
if(that)
|
||||
{
|
||||
int column = that->getColumnIndexFromX(event->x());
|
||||
int row = that->getIndexOffsetFromY(that->transY(event->y()));
|
||||
duint addr = 0;
|
||||
if(row < that->getRowCount())
|
||||
{
|
||||
bool ok = false;
|
||||
QString addrStr = that->getCellContent(row, column);
|
||||
GuiAddStatusBarMessage((addrStr + "\n").toUtf8().constData());
|
||||
#ifdef _WIN64
|
||||
addr = addrStr.toULongLong(&ok, 16);
|
||||
#else //x86
|
||||
addr = addrStr.toULong(&ok, 16);
|
||||
#endif //_WIN64
|
||||
if(ok && DbgFunctions()->MemIsCodePage(addr, false))
|
||||
ShowDisassemblyPopup(addr, event->x(), event->y());
|
||||
else //not a code section, clear addr to reset default behaviour
|
||||
addr = 0;
|
||||
}
|
||||
ShowDisassemblyPopup(addr, event->x(), event->y());
|
||||
}
|
||||
else
|
||||
ShowDisassemblyPopup(0, 0, 0);
|
||||
}
|
||||
|
||||
void StdSearchListView::leaveEvent(QEvent* event)
|
||||
{
|
||||
ShowDisassemblyPopup(0, 0, 0);
|
||||
}
|
||||
|
||||
void StdSearchListView::ShowDisassemblyPopup(duint addr, int x, int y)
|
||||
{
|
||||
if(!addr)
|
||||
{
|
||||
if(mDisassemblyPopup)
|
||||
mDisassemblyPopup->hide();
|
||||
return;
|
||||
}
|
||||
if(!mDisassemblyPopup)
|
||||
mDisassemblyPopup = new DisassemblyPopup(this);
|
||||
if(mDisassemblyPopup->getAddress() == addr)
|
||||
return;
|
||||
if(DbgFunctions()->MemIsCodePage(addr, false))
|
||||
{
|
||||
mDisassemblyPopup->move(mapToGlobal(QPoint(x + 20, y + stdList()->fontMetrics().height() * 2)));
|
||||
mDisassemblyPopup->setAddress(addr);
|
||||
mDisassemblyPopup->show();
|
||||
}
|
||||
else
|
||||
mDisassemblyPopup->hide();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "SearchListView.h"
|
||||
#include "StdTable.h"
|
||||
class DisassemblyPopup;
|
||||
|
||||
class StdTableSearchList;
|
||||
|
||||
|
@ -27,32 +26,14 @@ public slots:
|
|||
void setCellContent(int r, int c, QString s);
|
||||
void reloadData();
|
||||
void setSearchStartCol(int col);
|
||||
void mouseMoveSlot(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
StdTableSearchList* mSearchListData;
|
||||
DisassemblyPopup* mDisassemblyPopup;
|
||||
|
||||
void leaveEvent(QEvent* event);
|
||||
|
||||
protected:
|
||||
friend class SymbolView;
|
||||
friend class Bridge;
|
||||
StdTable* stdList();
|
||||
StdTable* stdSearchList();
|
||||
void ShowDisassemblyPopup(duint addr, int x, int y);
|
||||
};
|
||||
|
||||
//Hacked class to recieve mouse move event. This class must be placed in a header file, otherwise Qt won't create its internal functions.
|
||||
class StdTableMouseMove : public StdTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StdTableMouseMove(QWidget* parent = 0) : StdTable(parent) { }
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
//int fontHeight() const {return mFontMetrics->height();}
|
||||
|
||||
signals:
|
||||
void mouseMoveSignal(QMouseEvent* event);
|
||||
};
|
||||
#endif // STDSEARCHLISTVIEW_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SNOWMANVIEW_H
|
||||
#define SNOWMANVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
class QWidget;
|
||||
|
||||
struct SnowmanRange
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue