| 168 | } |
| 169 | |
| 170 | void SearchDock::on_next() |
| 171 | { |
| 172 | bool ret; |
| 173 | int64_t last_pos; |
| 174 | const auto snapshot = _session->get_snapshot(SR_CHANNEL_LOGIC); |
| 175 | assert(snapshot); |
| 176 | const auto logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot); |
| 177 | |
| 178 | if (logic_snapshot == NULL || logic_snapshot->empty()) { |
| 179 | QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_SAMPLE_DATA), "No Sample data!")); |
| 180 | MsgBox::Show(strMsg); |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | const int64_t end = logic_snapshot->get_sample_count() - 1; |
| 185 | last_pos = _view.get_search_pos() + _view.get_search_hit(); |
| 186 | if (last_pos >= end) { |
| 187 | QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SEARCH_AT_END), "Search cursor at the end position!")); |
| 188 | MsgBox::Show(strMsg); |
| 189 | return; |
| 190 | } else { |
| 191 | QFuture<void> future; |
| 192 | future = QtConcurrent::run([&]{ |
| 193 | ret = logic_snapshot->pattern_search(0, end, last_pos, _pattern, true); |
| 194 | }); |
| 195 | Qt::WindowFlags flags = Qt::CustomizeWindowHint; |
| 196 | QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SEARCH_NEXT), "Search Next..."), |
| 197 | L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags); |
| 198 | dlg.setWindowModality(Qt::WindowModal); |
| 199 | dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | |
| 200 | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); |
| 201 | dlg.setCancelButton(NULL); |
| 202 | |
| 203 | QFutureWatcher<void> watcher; |
| 204 | connect(&watcher,SIGNAL(finished()),&dlg,SLOT(cancel())); |
| 205 | watcher.setFuture(future); |
| 206 | dlg.exec(); |
| 207 | |
| 208 | if (!ret) { |
| 209 | QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PATTERN_NOT_FOUND), "Pattern not found!")); |
| 210 | MsgBox::Show(strMsg); |
| 211 | return; |
| 212 | } else { |
| 213 | _view.set_search_pos(last_pos, true); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | void SearchDock::on_set() |
| 219 | { |
nothing calls this directly
no test coverage detected