Skip to content

Commit d969087

Browse files
committed
GUI: refactor StdSearchListView to allow passing a custom StdTableSearchList
1 parent 34318e3 commit d969087

File tree

5 files changed

+58
-45
lines changed

5 files changed

+58
-45
lines changed

src/gui/Src/BasicView/StdSearchListView.cpp

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,12 @@
11
#include "StdSearchListView.h"
2-
#include "StdTable.h"
3-
4-
class StdTableSearchList : public AbstractSearchList
5-
{
6-
public:
7-
friend class StdSearchListView;
8-
9-
StdTableSearchList() : mList(new StdTable()), mSearchList(new StdTable()) { }
10-
~StdTableSearchList() {delete mList; delete mSearchList; }
11-
12-
void lock() override { }
13-
void unlock() override { }
14-
AbstractStdTable* list() const override { return mList; }
15-
AbstractStdTable* searchList() const override { return mSearchList; }
16-
17-
void filter(const QString & filter, FilterType type, int startColumn) override
18-
{
19-
mSearchList->setRowCount(0);
20-
int rows = mList->getRowCount();
21-
int columns = mList->getColumnCount();
22-
for(int i = 0, j = 0; i < rows; i++)
23-
{
24-
if(rowMatchesFilter(filter, type, i, startColumn))
25-
{
26-
mSearchList->setRowCount(j + 1);
27-
for(int k = 0; k < columns; k++)
28-
{
29-
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
30-
mSearchList->setCellUserdata(j, k, mList->getCellUserdata(i, k));
31-
}
32-
j++;
33-
}
34-
}
35-
}
36-
37-
private:
38-
StdTable* mList;
39-
StdTable* mSearchList;
40-
};
412

423
StdSearchListView::StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock)
43-
: SearchListView(parent, mSearchListData = new StdTableSearchList(), enableRegex, enableLock)
4+
: StdSearchListView(parent, enableRegex, enableLock, new StdTableSearchList())
5+
{
6+
}
7+
8+
StdSearchListView::StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList)
9+
: SearchListView(parent, mSearchListData = tableSearchList, enableRegex, enableLock)
4410
{
4511
setAddressColumn(0);
4612
}

src/gui/Src/BasicView/StdSearchListView.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
#define STDSEARCHLISTVIEW_H
33

44
#include "SearchListView.h"
5-
#include "StdTable.h"
6-
7-
class StdTableSearchList;
5+
#include "StdTableSearchList.h"
86

97
class StdSearchListView : public SearchListView
108
{
119
Q_OBJECT
1210
public:
1311
StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock);
12+
StdSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList);
1413
~StdSearchListView() override;
1514

1615
void setInternalTitle(const QString & title);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "StdTableSearchList.h"
2+
3+
void StdTableSearchList::filter(const QString & filter, FilterType type, int startColumn)
4+
{
5+
mSearchList->setRowCount(0);
6+
int rows = mList->getRowCount();
7+
int columns = mList->getColumnCount();
8+
for(int i = 0, j = 0; i < rows; i++)
9+
{
10+
if(rowMatchesFilter(filter, type, i, startColumn))
11+
{
12+
mSearchList->setRowCount(j + 1);
13+
for(int k = 0; k < columns; k++)
14+
{
15+
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
16+
mSearchList->setCellUserdata(j, k, mList->getCellUserdata(i, k));
17+
}
18+
j++;
19+
}
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "AbstractSearchList.h"
4+
#include "StdTable.h"
5+
6+
class StdTableSearchList : public AbstractSearchList
7+
{
8+
public:
9+
friend class StdSearchListView;
10+
11+
StdTableSearchList() : StdTableSearchList(new StdTable(), new StdTable()) { }
12+
StdTableSearchList(StdTable* list, StdTable* searchList) : mList(list), mSearchList(searchList) { }
13+
~StdTableSearchList() { delete mList; delete mSearchList; }
14+
15+
void lock() override { }
16+
void unlock() override { }
17+
AbstractStdTable* list() const override { return mList; }
18+
AbstractStdTable* searchList() const override { return mSearchList; }
19+
20+
void filter(const QString & filter, FilterType type, int startColumn) override;
21+
22+
private:
23+
StdTable* mList;
24+
StdTable* mSearchList;
25+
};

src/gui/x64dbg.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ SOURCES += \
183183
Src/Gui/MultiItemsSelectWindow.cpp \
184184
Src/BasicView/AbstractStdTable.cpp \
185185
Src/Gui/ZehSymbolTable.cpp \
186-
Src/BasicView/StdSearchListView.cpp
186+
Src/BasicView/StdSearchListView.cpp \
187+
Src/BasicView/StdTableSearchList.cpp
187188

188189

189190
HEADERS += \
@@ -303,7 +304,8 @@ HEADERS += \
303304
Src/Gui/ZehSymbolTable.h \
304305
Src/BasicView/AbstractSearchList.h \
305306
Src/BasicView/StdSearchListView.h \
306-
Src/Gui/FileLines.h
307+
Src/Gui/FileLines.h \
308+
Src/BasicView/StdTableSearchList.h
307309

308310

309311
FORMS += \

0 commit comments

Comments
 (0)