MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / memSearchEdit

Method memSearchEdit

gui/qt/memorywidget.cpp:129–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void MainWindow::memSearchEdit(HexWidget *edit) {
130 if (edit == Q_NULLPTR) {
131 return;
132 }
133
134 SearchWidget search(m_searchStr, m_searchMode);
135 int searchMode, found = 0;
136 search.show();
137
138 if ((searchMode = search.exec()) == SearchWidget::Cancel) {
139 return;
140 }
141
142 m_searchMode = search.getType();
143 m_searchStr = search.getSearchString();
144
145 QString searchString;
146 if (m_searchMode == SearchWidget::Hex) {
147 searchString = m_searchStr;
148 } else {
149 searchString = QString::fromStdString(m_searchStr.toLatin1().toHex().toStdString());
150 }
151
152 edit->setFocus();
153 std::string s = searchString.toUpper().toStdString();
154 if (searchString.isEmpty() || (searchString.length() & 1) || s.find_first_not_of("0123456789ABCDEF") != std::string::npos) {
155 QMessageBox::critical(this, MSG_ERROR, tr("Error when reading input string"));
156 return;
157 }
158
159 QByteArray searchBa = QByteArray::fromHex(searchString.toLatin1());
160
161 switch (searchMode) {
162 default:
163 case SearchWidget::NextNot:
164 found = edit->indexNotOf(searchBa);
165 break;
166 case SearchWidget::Prev:
167 found = edit->indexPrevOf(searchBa);
168 break;
169 case SearchWidget::PrevNot:
170 found = edit->indexPrevNotOf(searchBa);
171 break;
172 case SearchWidget::Next:
173 found = edit->indexOf(searchBa);
174 break;
175 }
176
177 if (found == -1) {
178 QMessageBox::warning(this, MSG_WARNING, tr("String not found."));
179 }
180}
181
182void MainWindow::memGoto(HexWidget *edit, uint32_t address) {
183 if (edit == Q_NULLPTR) {

Callers

nothing calls this directly

Calls 6

getTypeMethod · 0.80
getSearchStringMethod · 0.80
indexNotOfMethod · 0.80
indexPrevOfMethod · 0.80
indexPrevNotOfMethod · 0.80
indexOfMethod · 0.80

Tested by

no test coverage detected