WIP
parent
b16d806e12
commit
f5dc16cfa9
|
@ -34,21 +34,21 @@ public:
|
|||
cs = Qt::CaseSensitive;
|
||||
case FilterStartsWithTextCaseInsensitive:
|
||||
for(int i = startColumn; i < count; i++)
|
||||
if(list()->getCellContent(row, i).startsWith(filter, cs))
|
||||
if(list()->getCellContentUnsafe(row, i).startsWith(filter, cs))
|
||||
return true;
|
||||
break;
|
||||
case FilterContainsTextCaseSensitive:
|
||||
cs = Qt::CaseSensitive;
|
||||
case FilterContainsTextCaseInsensitive:
|
||||
for(int i = startColumn; i < count; i++)
|
||||
if(list()->getCellContent(row, i).contains(filter, cs))
|
||||
if(list()->getCellContentUnsafe(row, i).contains(filter, cs))
|
||||
return true;
|
||||
break;
|
||||
case FilterRegexCaseSensitive:
|
||||
cs = Qt::CaseSensitive;
|
||||
case FilterRegexCaseInsensitive:
|
||||
for(int i = startColumn; i < count; i++)
|
||||
if(list()->getCellContent(row, i).contains(QRegExp(filter, cs)))
|
||||
if(list()->getCellContentUnsafe(row, i).contains(QRegExp(filter, cs)))
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -26,7 +26,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
|
|||
{
|
||||
bool isaddr = DbgIsDebugging() && getRowCount() > 0 && col == mAddressColumn;
|
||||
bool wIsSelected = isSelected(rowBase, rowOffset);
|
||||
QString text = getCellContent(rowBase + rowOffset, col);
|
||||
QString text = getCellContentUnsafe(rowBase + rowOffset, col);
|
||||
|
||||
duint wVA = isaddr ? duint(text.toULongLong(&isaddr, 16)) : 0;
|
||||
auto wIsTraced = isaddr && DbgFunctions()->GetTraceRecordHitCount(wVA) != 0;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractTableView.h"
|
||||
#include <type_traits>
|
||||
|
||||
class AbstractStdTable : public AbstractTableView
|
||||
{
|
||||
|
@ -41,7 +42,31 @@ public:
|
|||
void addColumnAt(int width, QString title, bool isClickable, QString copyTitle = "");
|
||||
void deleteAllColumns() override;
|
||||
|
||||
virtual QString getCellContent(int r, int c) = 0;
|
||||
struct Unsafe {};
|
||||
|
||||
template<typename T>
|
||||
using SafetyOverride = typename std::enable_if<std::is_same<T, Unsafe>::value, bool>::type;
|
||||
|
||||
template<typename T>
|
||||
using IsInt = typename std::enable_if<std::is_integral<T>::value, bool>::type;
|
||||
|
||||
template<typename T>
|
||||
using IsEnum = typename std::enable_if<std::is_enum<T>::value, bool>::type;
|
||||
|
||||
template<typename T, IsInt<T> = true>
|
||||
QString getCellContent(int row, T column)
|
||||
{
|
||||
static_assert(std::is_enum<T>::value, "This interface is deprecated, use a Column enum instead.");
|
||||
}
|
||||
|
||||
template<typename T, IsEnum<T> = true>
|
||||
QString getCellContent(int row, T column)
|
||||
{
|
||||
static_assert(T::TableColumnEnum == static_cast<T>(-1), "Invalid Column enum.");
|
||||
return getCellContentUnsafe(row, (int)column);
|
||||
}
|
||||
|
||||
virtual QString getCellContentUnsafe(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;
|
||||
|
|
|
@ -129,7 +129,7 @@ bool SearchListView::findTextInList(AbstractStdTable* list, QString text, int ro
|
|||
if(startswith)
|
||||
{
|
||||
for(int i = startcol; i < count; i++)
|
||||
if(list->getCellContent(row, i).startsWith(text, Qt::CaseInsensitive))
|
||||
if(list->getCellContentUnsafe(row, i).startsWith(text, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -139,12 +139,12 @@ bool SearchListView::findTextInList(AbstractStdTable* list, QString text, int ro
|
|||
auto state = mRegexCheckbox->checkState();
|
||||
if(state != Qt::Unchecked)
|
||||
{
|
||||
if(list->getCellContent(row, i).contains(QRegExp(text, state == Qt::PartiallyChecked ? Qt::CaseInsensitive : Qt::CaseSensitive)))
|
||||
if(list->getCellContentUnsafe(row, i).contains(QRegExp(text, state == Qt::PartiallyChecked ? Qt::CaseInsensitive : Qt::CaseSensitive)))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list->getCellContent(row, i).contains(text, Qt::CaseInsensitive))
|
||||
if(list->getCellContentUnsafe(row, i).contains(text, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ void SearchListView::filterEntries()
|
|||
QString mLastFirstColValue;
|
||||
auto selList = mCurList->getSelection();
|
||||
if(!selList.empty() && mCurList->isValidIndex(selList[0], 0))
|
||||
mLastFirstColValue = mCurList->getCellContent(selList[0], 0);
|
||||
mLastFirstColValue = mCurList->getCellContentUnsafe(selList[0], 0);
|
||||
|
||||
// get the correct previous list instance
|
||||
auto mPrevList = mAbstractSearchList->list()->isVisible() ? mAbstractSearchList->list() : mAbstractSearchList->searchList();
|
||||
|
@ -207,7 +207,7 @@ void SearchListView::filterEntries()
|
|||
mCurList->setTableOffset(0);
|
||||
for(int i = 0; i < rows; i++)
|
||||
{
|
||||
if(mCurList->getCellContent(i, 0) == mLastFirstColValue)
|
||||
if(mCurList->getCellContentUnsafe(i, 0) == mLastFirstColValue)
|
||||
{
|
||||
if(rows > mCurList->getViewableRowsCount())
|
||||
{
|
||||
|
|
|
@ -82,13 +82,14 @@ void StdTable::setRowCount(dsint count)
|
|||
AbstractTableView::setRowCount(count);
|
||||
}
|
||||
|
||||
void StdTable::setCellContent(int r, int c, QString s)
|
||||
bool StdTable::isValidIndex(int r, int c)
|
||||
{
|
||||
if(isValidIndex(r, c))
|
||||
mData[r][c].text = std::move(s);
|
||||
if(r < 0 || c < 0 || r >= int(mData.size()))
|
||||
return false;
|
||||
return c < int(mData.at(r).size());
|
||||
}
|
||||
|
||||
QString StdTable::getCellContent(int r, int c)
|
||||
QString StdTable::getCellContentUnsafe(int r, int c)
|
||||
{
|
||||
if(isValidIndex(r, c))
|
||||
return mData[r][c].text;
|
||||
|
@ -96,6 +97,12 @@ QString StdTable::getCellContent(int r, int c)
|
|||
return QString("");
|
||||
}
|
||||
|
||||
void StdTable::setCellContent(int r, int c, QString s)
|
||||
{
|
||||
if(isValidIndex(r, c))
|
||||
mData[r][c].text = std::move(s);
|
||||
}
|
||||
|
||||
void StdTable::setCellUserdata(int r, int c, duint userdata)
|
||||
{
|
||||
if(isValidIndex(r, c))
|
||||
|
@ -107,13 +114,6 @@ duint StdTable::getCellUserdata(int r, int c)
|
|||
return isValidIndex(r, c) ? mData[r][c].userdata : 0;
|
||||
}
|
||||
|
||||
bool StdTable::isValidIndex(int r, int c)
|
||||
{
|
||||
if(r < 0 || c < 0 || r >= int(mData.size()))
|
||||
return false;
|
||||
return c < int(mData.at(r).size());
|
||||
}
|
||||
|
||||
void StdTable::sortRows(int column, bool ascending)
|
||||
{
|
||||
auto sortFn = mColumnSortFunctions.at(column);
|
||||
|
|
|
@ -22,11 +22,12 @@ public:
|
|||
void addColumnAt(int width, QString title, bool isClickable, QString copyTitle = "", SortBy::t sortFn = SortBy::AsText);
|
||||
void deleteAllColumns() override;
|
||||
void setRowCount(dsint count) override;
|
||||
QString getCellContentUnsafe(int r, int c) override;
|
||||
bool isValidIndex(int r, int c) override;
|
||||
// TODO: type safe interfaces
|
||||
void setCellContent(int r, int c, QString s);
|
||||
QString getCellContent(int r, int c) override;
|
||||
void setCellUserdata(int r, int c, duint userdata);
|
||||
duint getCellUserdata(int r, int c);
|
||||
bool isValidIndex(int r, int c) override;
|
||||
void sortRows(int column, bool ascending) override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -249,7 +249,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
{
|
||||
QString content;
|
||||
if(referenceManager->currentReferenceView())
|
||||
content = referenceManager->currentReferenceView()->stdList()->getCellContent((int)param1, (int)param2);
|
||||
content = referenceManager->currentReferenceView()->stdList()->getCellContentUnsafe((int)param1, (int)param2);
|
||||
auto bytes = content.toUtf8();
|
||||
auto data = BridgeAlloc(bytes.size() + 1);
|
||||
memcpy(data, bytes.constData(), bytes.size());
|
||||
|
@ -260,7 +260,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
{
|
||||
QString content;
|
||||
if(referenceManager->currentReferenceView())
|
||||
content = referenceManager->currentReferenceView()->mCurList->getCellContent((int)param1, (int)param2);
|
||||
content = referenceManager->currentReferenceView()->mCurList->getCellContentUnsafe((int)param1, (int)param2);
|
||||
auto bytes = content.toUtf8();
|
||||
auto data = BridgeAlloc(bytes.size() + 1);
|
||||
memcpy(data, bytes.constData(), bytes.size());
|
||||
|
|
|
@ -155,7 +155,7 @@ QString BreakpointsView::paintContent(QPainter* painter, dsint rowBase, int rowO
|
|||
painter->fillRect(QRect(x, y, w, h), QBrush(mDisasmBackgroundColor));
|
||||
auto index = bpIndex(rowBase + rowOffset);
|
||||
auto & bp = mBps.at(index);
|
||||
auto cellContent = getCellContent(rowBase + rowOffset, col);
|
||||
auto cellContent = getCellContentUnsafe(rowBase + rowOffset, col);
|
||||
if(col > ColType && !bp.addr && !bp.active)
|
||||
{
|
||||
auto mid = h / 2.0;
|
||||
|
|
|
@ -267,7 +267,7 @@ QString MemoryMapView::paintContent(QPainter* painter, dsint rowBase, int rowOff
|
|||
{
|
||||
if(col == 0) //address
|
||||
{
|
||||
QString wStr = getCellContent(rowBase + rowOffset, col);
|
||||
QString wStr = getCellContentUnsafe(rowBase + rowOffset, col);
|
||||
#ifdef _WIN64
|
||||
duint addr = wStr.toULongLong(0, 16);
|
||||
#else //x86
|
||||
|
|
|
@ -41,7 +41,7 @@ SourceView::~SourceView()
|
|||
clear();
|
||||
}
|
||||
|
||||
QString SourceView::getCellContent(int r, int c)
|
||||
QString SourceView::getCellContentUnsafe(int r, int c)
|
||||
{
|
||||
if(!isValidIndex(r, c))
|
||||
return QString();
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
SourceView(QString path, duint addr, QWidget* parent = nullptr);
|
||||
~SourceView();
|
||||
|
||||
QString getCellContent(int r, int c) override;
|
||||
QString getCellContentUnsafe(int r, int c) override;
|
||||
bool isValidIndex(int r, int c) override;
|
||||
void sortRows(int column, bool ascending) override;
|
||||
void prepareData() override;
|
||||
|
|
|
@ -45,7 +45,7 @@ ZehSymbolTable::ZehSymbolTable(QWidget* parent)
|
|||
Initialize();
|
||||
}
|
||||
|
||||
QString ZehSymbolTable::getCellContent(int r, int c)
|
||||
QString ZehSymbolTable::getCellContentUnsafe(int r, int c)
|
||||
{
|
||||
QMutexLocker lock(&mMutex);
|
||||
if(!isValidIndex(r, c))
|
||||
|
|
|
@ -9,7 +9,7 @@ class ZehSymbolTable : public AbstractStdTable
|
|||
public:
|
||||
ZehSymbolTable(QWidget* parent = nullptr);
|
||||
|
||||
QString getCellContent(int r, int c) override;
|
||||
QString getCellContentUnsafe(int r, int c) override;
|
||||
bool isValidIndex(int r, int c) override;
|
||||
void sortRows(int column, bool ascending) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue