| 41 | #include <thread> |
| 42 | |
| 43 | RamSearchWindow::RamSearchWindow(Context* c, HexViewWindow* view, RamWatchWindow* ram, QWidget *parent) : QDialog(parent), context(c), hexViewWindow(view), ramWatchWindow(ram) |
| 44 | { |
| 45 | setWindowTitle("Ram Search"); |
| 46 | |
| 47 | /* Get monospace font */ |
| 48 | const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); |
| 49 | |
| 50 | /* Table */ |
| 51 | ramSearchView = new QTableView(this); |
| 52 | ramSearchView->setSelectionBehavior(QAbstractItemView::SelectRows); |
| 53 | ramSearchView->setSelectionMode(QAbstractItemView::SingleSelection); |
| 54 | ramSearchView->setShowGrid(false); |
| 55 | ramSearchView->setAlternatingRowColors(true); |
| 56 | ramSearchView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
| 57 | ramSearchView->horizontalHeader()->setHighlightSections(false); |
| 58 | ramSearchView->verticalHeader()->hide(); |
| 59 | ramSearchView->setFont(fixedFont); |
| 60 | |
| 61 | ramSearchModel = new RamSearchModel(context); |
| 62 | ramSearchView->setModel(ramSearchModel); |
| 63 | |
| 64 | /* Progress bar */ |
| 65 | searchProgress = new QProgressBar(); |
| 66 | connect(&ramSearchModel->memscanner, &MemScanner::signalProgress, searchProgress, &QProgressBar::setValue); |
| 67 | |
| 68 | watchCount = new QLabel(); |
| 69 | // watchCount->setHeight(searchProgress->height()); |
| 70 | |
| 71 | /* Buttons */ |
| 72 | newButton = new QPushButton(tr("New")); |
| 73 | connect(newButton, &QAbstractButton::clicked, this, &RamSearchWindow::slotNew); |
| 74 | |
| 75 | searchButton = new QPushButton(tr("Search")); |
| 76 | connect(searchButton, &QAbstractButton::clicked, this, &RamSearchWindow::slotSearch); |
| 77 | searchButton->setDisabled(true); |
| 78 | |
| 79 | stopButton = new QPushButton(tr("Force Stop")); |
| 80 | connect(stopButton, &QAbstractButton::clicked, this, &RamSearchWindow::slotStop); |
| 81 | stopButton->setDisabled(true); |
| 82 | |
| 83 | QPushButton *addButton = new QPushButton(tr("Add Watch")); |
| 84 | connect(addButton, &QAbstractButton::clicked, this, &RamSearchWindow::slotAdd); |
| 85 | |
| 86 | QPushButton *hexButton = new QPushButton(tr("Hex View")); |
| 87 | connect(hexButton, &QAbstractButton::clicked, this, &RamSearchWindow::slotHex); |
| 88 | |
| 89 | QDialogButtonBox *buttonBox = new QDialogButtonBox(); |
| 90 | buttonBox->addButton(newButton, QDialogButtonBox::ActionRole); |
| 91 | buttonBox->addButton(searchButton, QDialogButtonBox::ActionRole); |
| 92 | buttonBox->addButton(stopButton, QDialogButtonBox::ActionRole); |
| 93 | buttonBox->addButton(addButton, QDialogButtonBox::ActionRole); |
| 94 | buttonBox->addButton(hexButton, QDialogButtonBox::ActionRole); |
| 95 | |
| 96 | QVBoxLayout *watchLayout = new QVBoxLayout; |
| 97 | watchLayout->addWidget(ramSearchView); |
| 98 | watchLayout->addWidget(searchProgress); |
| 99 | watchLayout->addWidget(watchCount); |
| 100 | watchLayout->addWidget(buttonBox); |