Exemplo n.º 1
0
void FunctionListModel::resetModelData(TraceData *data,
                                       TraceCostItem *group, QString filterString,
                                       EventType * eventType)
{
    _eventType = eventType;

    if (!group) {
        _list.clear();
        _groupType = ProfileContext::Function;
        if (data) {
            TraceFunctionMap::iterator i = data->functionMap().begin();
            while (i != data->functionMap().end()) {
                _list.append(&(i.value()));
                ++i;
            }
            foreach(TraceFunction* f, data->functionCycles())
                _list.append(f);
        }
    }
    else {
        _groupType = group->type();
        switch(_groupType) {
        case ProfileContext::Object:
        {
            TraceObject* o = dynamic_cast<TraceObject*>(group);
            Q_ASSERT(o != 0);
            _list = o->functions();
        }
            break;

        case ProfileContext::Class:
        {
            TraceClass* c = dynamic_cast<TraceClass*>(group);
            Q_ASSERT(c != 0);
            _list = c->functions();
        }
            break;

        case ProfileContext::File:
        {
            TraceFile* f = dynamic_cast<TraceFile*>(group);
            Q_ASSERT(f != 0);
            _list = f->functions();
        }
            break;

        case ProfileContext::FunctionCycle:
        {
            TraceFunctionCycle* c = dynamic_cast<TraceFunctionCycle*>(group);
            Q_ASSERT(c != 0);
            _list = c->members();
        }
            break;

        default:
            _list.clear();
            break;
        }
    }

    _filterString = filterString;
    _filter = QRegExp(_filterString, Qt::CaseInsensitive, QRegExp::Wildcard);

    computeFilteredList();
    computeTopList();
}