QModelIndex ApiTraceModel::callIndex(int callNum) const
{
ApiTraceCall *call = m_trace->callWithIndex(callNum);
+ return indexForCall(call);
+}
+QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const
+{
if (!call) {
- qDebug()<<"couldn't find call at "<<callNum;
return QModelIndex();
}
int row = frame->calls.indexOf(call);
if (row < 0) {
- qDebug() << "Couldn't find call num "<<callNum<<" inside parent!";
+ qDebug() << "Couldn't find call num "<<call->index<<" inside parent!";
return QModelIndex();
}
return createIndex(row, 0, call);
void MainWindow::slotSearchNext(const QString &str, Qt::CaseSensitivity sensitivity)
{
QModelIndex index = m_ui.callView->currentIndex();
- ApiTraceEvent *event =
- index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ ApiTraceEvent *event = 0;
+
+
+ if (!index.isValid()) {
+ index = m_proxyModel->index(0, 0, QModelIndex());
+ if (!index.isValid()) {
+ qDebug()<<"no currently valid index";
+ m_searchWidget->setFound(false);
+ return;
+ }
+ }
+
+ event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
ApiTraceCall *call = 0;
if (event->type() == ApiTraceCall::Call)
ApiTraceCall *testCall = calls[i];
QString txt = testCall->filterText();
if (txt.contains(str, sensitivity)) {
- QModelIndex index = m_proxyModel->callIndex(testCall->index);
+ QModelIndex index = m_proxyModel->indexForCall(testCall);
/* if it's not valid it means that the proxy model has already
* filtered it out */
if (index.isValid()) {
void MainWindow::slotSearchPrev(const QString &str, Qt::CaseSensitivity sensitivity)
{
QModelIndex index = m_ui.callView->currentIndex();
- ApiTraceEvent *event =
- index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ ApiTraceEvent *event = 0;
+
+
+ if (!index.isValid()) {
+ index = m_proxyModel->index(0, 0, QModelIndex());
+ if (!index.isValid()) {
+ qDebug()<<"no currently valid index";
+ m_searchWidget->setFound(false);
+ return;
+ }
+ }
+
+ event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
ApiTraceCall *call = 0;
if (event->type() == ApiTraceCall::Call)
ApiTraceCall *testCall = calls[i];
QString txt = testCall->filterText();
if (txt.contains(str, sensitivity)) {
- QModelIndex index = m_proxyModel->callIndex(testCall->index);
+ QModelIndex index = m_proxyModel->indexForCall(testCall);
/* if it's not valid it means that the proxy model has already
* filtered it out */
if (index.isValid()) {
void SearchWidget::showEvent(QShowEvent *event)
{
- m_ui.lineEdit->selectAll();
- m_ui.lineEdit->setFocus(Qt::ShortcutFocusReason);
- m_ui.lineEdit->setPalette(m_origPalette);
return QWidget::showEvent(event);
}
m_ui.notFoundLabel->setVisible(!found);
}
+void SearchWidget::show()
+{
+ QWidget::show();
+ m_ui.lineEdit->selectAll();
+ m_ui.lineEdit->setFocus(Qt::ShortcutFocusReason);
+ m_ui.lineEdit->setPalette(m_origPalette);
+}
+
#include "searchwidget.moc"