MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / on_previous

Method on_previous

DSView/pv/dock/searchdock.cpp:118–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void SearchDock::on_previous()
119{
120 bool ret;
121 int64_t last_pos;
122 bool last_hit;
123 const auto snapshot = _session->get_snapshot(SR_CHANNEL_LOGIC);
124 assert(snapshot);
125 const auto logic_snapshot = dynamic_cast<data::LogicSnapshot*>(snapshot);
126
127 if (logic_snapshot == NULL || logic_snapshot->empty()) {
128 QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_SAMPLE_DATA), "No Sample data!"));
129 MsgBox::Show(strMsg);
130 return;
131 }
132
133 const int64_t end = logic_snapshot->get_sample_count() - 1;
134 last_pos = _view.get_search_pos();
135 last_hit = _view.get_search_hit();
136 if (last_pos == 0) {
137 QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_SEARCH_AT_START), "Search cursor at the start position!"));
138 MsgBox::Show(strMsg);
139 return;
140 }
141 else {
142 QFuture<void> future;
143 future = QtConcurrent::run([&]{
144 last_pos -= last_hit;
145 ret = logic_snapshot->pattern_search(0, end, last_pos, _pattern, false);
146 });
147 Qt::WindowFlags flags = Qt::CustomizeWindowHint;
148 QProgressDialog dlg(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_SEARCH_PREVIOUS), "Search Previous..."),
149 L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CANCEL), "Cancel"),0,0,this,flags);
150 dlg.setWindowModality(Qt::WindowModal);
151 dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint |
152 Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
153 dlg.setCancelButton(NULL);
154
155 QFutureWatcher<void> watcher;
156 connect(&watcher,SIGNAL(finished()),&dlg,SLOT(cancel()));
157 watcher.setFuture(future);
158 dlg.exec();
159
160 if (!ret) {
161 QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PATTERN_NOT_FOUND), "Pattern not found!"));
162 MsgBox::Show(strMsg);
163 return;
164 } else {
165 _view.set_search_pos(last_pos, true);
166 }
167 }
168}
169
170void SearchDock::on_next()
171{

Callers

nothing calls this directly

Calls 9

ShowFunction · 0.85
get_snapshotMethod · 0.80
emptyMethod · 0.80
get_sample_countMethod · 0.80
get_search_posMethod · 0.80
get_search_hitMethod · 0.80
pattern_searchMethod · 0.80
set_search_posMethod · 0.80
execMethod · 0.45

Tested by

no test coverage detected