1
0
Fork 0

Add support for getCellUserdata in StdSearchListView

This commit is contained in:
Duncan Ogilvie 2023-11-28 09:29:04 +01:00
parent 911329e8e6
commit ee13290541
10 changed files with 72 additions and 26 deletions

View File

@ -42,6 +42,7 @@ public:
void deleteAllColumns() override;
virtual QString getCellContent(duint row, duint column) = 0;
virtual duint getCellUserdata(duint row, duint column) = 0;
virtual bool isValidIndex(duint row, duint column) = 0;
virtual void sortRows(duint column, bool ascending) = 0;

View File

@ -182,7 +182,7 @@ void ReferenceView::addColumnAtRef(int width, QString title)
StdSearchListView::addColumnAt(width, title, true);
}
void ReferenceView::setRowCount(dsint count)
void ReferenceView::setRowCount(duint count)
{
if(!stdList()->getRowCount() && count) //from zero to N rows
searchSelectionChanged(0);

View File

@ -21,7 +21,7 @@ public:
public slots:
void addColumnAtRef(int width, QString title);
void setRowCount(dsint count) override;
void setRowCount(duint count) override;
void setSingleSelection(int index, bool scroll);
void addCommand(QString title, QString command);

View File

@ -57,16 +57,22 @@ void StdSearchListView::loadColumnFromConfig(const QString & viewName)
stdSearchList()->loadColumnFromConfig(viewName);
}
void StdSearchListView::setRowCount(dsint count)
void StdSearchListView::setRowCount(duint count)
{
//clearFilter();
stdList()->setRowCount(count);
}
void StdSearchListView::setCellContent(int r, int c, QString s)
void StdSearchListView::setCellContent(duint row, duint column, QString s)
{
//clearFilter();
stdList()->setCellContent(r, c, s);
stdList()->setCellContent(row, column, s);
}
void StdSearchListView::setCellUserdata(duint row, duint column, duint userdata)
{
//clearFilter();
stdList()->setCellUserdata(row, column, userdata);
}
void StdSearchListView::reloadData()

View File

@ -18,12 +18,13 @@ public:
void enableMultiSelection(bool enabled);
void setAddressColumn(int col, bool cipBase = false);
void loadColumnFromConfig(const QString & viewName);
virtual void setRowCount(duint count);
void setCellContent(duint row, duint column, QString s);
void setCellUserdata(duint row, duint column, duint userdata);
void setSearchStartCol(duint column);
public slots:
virtual void setRowCount(dsint count);
void setCellContent(int r, int c, QString s);
void reloadData();
void setSearchStartCol(duint col);
private:
StdTableSearchList* mSearchListData;

View File

@ -25,7 +25,7 @@ public:
void setCellContent(duint r, duint c, QString s, duint userdata);
QString getCellContent(duint r, duint c) override;
void setCellUserdata(duint r, duint c, duint userdata);
duint getCellUserdata(duint r, duint c);
duint getCellUserdata(duint r, duint c) override;
bool isValidIndex(duint r, duint c) override;
void sortRows(duint column, bool ascending) override;

View File

@ -41,12 +41,12 @@ SourceView::~SourceView()
clear();
}
QString SourceView::getCellContent(duint r, duint c)
QString SourceView::getCellContent(duint row, duint column)
{
if(!isValidIndex(r, c))
if(!isValidIndex(row, column))
return QString();
LineData & line = mLines.at(r - mPrepareTableOffset);
switch(c)
LineData & line = mLines.at(row - mPrepareTableOffset);
switch(column)
{
case ColAddr:
return line.addr ? ToPtrString(line.addr) : QString();
@ -59,13 +59,29 @@ QString SourceView::getCellContent(duint r, duint c)
return "INVALID";
}
bool SourceView::isValidIndex(duint r, duint c)
duint SourceView::getCellUserdata(duint row, duint column)
{
if(!isValidIndex(row, column))
return 0;
LineData & line = mLines.at(row - mPrepareTableOffset);
switch(column)
{
case ColAddr:
return line.addr;
case ColLine:
return line.index + 1;
default:
return 0;
}
}
bool SourceView::isValidIndex(duint row, duint column)
{
if(!mFileLines)
return false;
if(c < ColAddr || c > ColCode)
if(column < ColAddr || column > ColCode)
return false;
return r >= 0 && size_t(r) < mFileLines->size();
return row >= 0 && size_t(row) < mFileLines->size();
}
void SourceView::sortRows(duint column, bool ascending)

View File

@ -13,8 +13,9 @@ public:
SourceView(QString path, duint addr, QWidget* parent = nullptr);
~SourceView();
QString getCellContent(duint r, duint c) override;
bool isValidIndex(duint r, duint c) override;
QString getCellContent(duint row, duint column) override;
duint getCellUserdata(duint row, duint column) override;
bool isValidIndex(duint row, duint column) override;
void sortRows(duint column, bool ascending) override;
void prepareData() override;

View File

@ -56,20 +56,40 @@ ZehSymbolTable::ZehSymbolTable(QWidget* parent)
Initialize();
}
QString ZehSymbolTable::getCellContent(duint r, duint c)
QString ZehSymbolTable::getCellContent(duint row, duint column)
{
QMutexLocker lock(&mMutex);
if(!isValidIndex(r, c))
if(!isValidIndex(row, column))
return QString();
SymbolInfoWrapper info;
DbgGetSymbolInfo(&mData.at(r), info.put());
return symbolInfoString(info.get(), c);
DbgGetSymbolInfo(&mData.at(row), info.put());
return symbolInfoString(info.get(), column);
}
bool ZehSymbolTable::isValidIndex(duint r, duint c)
duint ZehSymbolTable::getCellUserdata(duint row, duint column)
{
QMutexLocker lock(&mMutex);
return r >= 0 && r < (int)mData.size() && c >= 0 && c <= ColUndecorated;
if(!isValidIndex(row, column))
return 0;
SymbolInfoWrapper info;
DbgGetSymbolInfo(&mData.at(row), info.put());
switch(column)
{
case ColAddr:
return info->addr;
case ColOrdinal:
return info->ordinal;
case ColType:
return info->type;
default:
return 0;
}
}
bool ZehSymbolTable::isValidIndex(duint row, duint column)
{
QMutexLocker lock(&mMutex);
return row >= 0 && row < (int)mData.size() && column >= 0 && column <= ColUndecorated;
}
void ZehSymbolTable::sortRows(duint column, bool ascending)

View File

@ -9,8 +9,9 @@ class ZehSymbolTable : public AbstractStdTable
public:
ZehSymbolTable(QWidget* parent = nullptr);
QString getCellContent(duint r, duint c) override;
bool isValidIndex(duint r, duint c) override;
QString getCellContent(duint row, duint column) override;
duint getCellUserdata(duint row, duint column) override;
bool isValidIndex(duint row, duint column) override;
void sortRows(duint column, bool ascending) override;
friend class SymbolView;