comparison src/historywidget.cpp @ 555:a1d210c767ab find

Implement basic search function in both work and history tabs
author Chris Cannam
date Wed, 22 Feb 2012 14:54:30 +0000
parents a17c06f773cd
children d932ce55c364
comparison
equal deleted inserted replaced
554:930462068dcc 555:a1d210c767ab
239 239
240 if (toFocus) { 240 if (toFocus) {
241 toFocus->ensureVisible(); 241 toFocus->ensureVisible();
242 } 242 }
243 243
244 updateSearchStatus();
244 connectSceneSignals(); 245 connectSceneSignals();
245 } 246 }
246 247
247 void HistoryWidget::setChangesetParents() 248 void HistoryWidget::setChangesetParents()
248 { 249 {
292 csit->update(); 293 csit->update();
293 } 294 }
294 } 295 }
295 } 296 }
296 297
298 void HistoryWidget::setSearchText(QString text)
299 {
300 if (m_searchText == text) return;
301 m_searchText = text;
302 updateSearchStatus();
303 }
304
305 void HistoryWidget::updateSearchStatus()
306 {
307 QGraphicsScene *scene = m_panned->scene();
308 if (!scene) return;
309
310 ChangesetItem *toFocus = 0;
311
312 QList<QGraphicsItem *> items = scene->items();
313 foreach (QGraphicsItem *it, items) {
314
315 ChangesetItem *csit = dynamic_cast<ChangesetItem *>(it);
316 if (!csit) continue;
317
318 bool matched = csit->setSearchText(m_searchText);
319 if (matched && (!toFocus || csit->row() < toFocus->row())) {
320 toFocus = csit;
321 }
322 csit->update();
323 }
324
325 if (toFocus) {
326 toFocus->ensureVisible();
327 }
328 }
329
297 void HistoryWidget::connectSceneSignals() 330 void HistoryWidget::connectSceneSignals()
298 { 331 {
299 ChangesetScene *scene = qobject_cast<ChangesetScene *>(m_panned->scene()); 332 ChangesetScene *scene = qobject_cast<ChangesetScene *>(m_panned->scene());
300 if (!scene) return; 333 if (!scene) return;
301 334