Example #1
0
bool EntityInstanceCompare::precede(const EntityInstance &e1, const EntityInstance &e2, const PropertyPrecedeOrderList &s, const EntityInfo &inf)
{
    QVariant a1,a2;
    int t1,t2;
    foreach(PropertyPrecedeOrder so, s){
        a1= e1.get(so.first);
        a2= e2.get(so.first);
        t1= a1.userType();
        if(t1==QMetaType::UnknownType && inf.propertyInfo(so.first).dataType()!=QMetaType::UnknownType){
            t1= inf.propertyInfo(so.first).dataType();
            a1= inf.propertyInfo(so.first).defaultValue();
        }
        t2= a2.userType();
        if(t2==QMetaType::UnknownType && inf.propertyInfo(so.first).dataType()!=QMetaType::UnknownType){
            t2= inf.propertyInfo(so.first).dataType();
            a2= inf.propertyInfo(so.first).defaultValue();
        }
        if(t1== QMetaType::UnknownType && t2== QMetaType::UnknownType) continue;
        if(so.second == def::Ascending){
            if(t1== QMetaType::UnknownType) return true;
            if(t2== QMetaType::UnknownType) return false;
            if(lessThan(a1,a2)) return true;
            else if(greaterThan(a1,a2)) return false;
        }else if(so.second == def::Descending){
            if(t1== QMetaType::UnknownType) return false;
            if(t2== QMetaType::UnknownType) return true;
            if(greaterThan(a1,a2)) return true;
            else if(lessThan(a1,a2)) return false;
        }
    }
Example #2
0
void priority_queue<Object,Container,Compare>::pop( )
{
    if( empty( ) )
        throw UnderflowException( "Cannot pop an empty priority queue" );

    int hole = 1;
    int child;
    Object tmp = theItems.back( );
    theItems.pop_back( );
    int theSize = size( );

    for( ; hole * 2 <= theSize; hole = child )
    {
        child = hole * 2;
        if( child != theSize &&
                lessThan( theItems[ child ], theItems[ child + 1 ] ) )
            child++;
        if( lessThan( tmp, theItems[ child ] ) )
            theItems[ hole ] = theItems[ child ];
        else
            break;
    }

    if( !empty( ) )
        theItems[ hole ] = tmp;
}
bool
PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
{
    PlayableItem* p1 = itemFromIndex( left );
    PlayableItem* p2 = itemFromIndex( right );

    if ( !p1 )
        return true;
    if ( !p2 )
        return false;

    if ( p1->query() && p2->query() )
    {
        if ( !m_headerStyle.contains( m_style ) || left.column() >= m_headerStyle[ m_style ].count() )
        {
            return lessThan( left.column(), p1->query(), p2->query() );
        }

        PlayableModel::Columns col = m_headerStyle[ m_style ].at( left.column() );
        return lessThan( col, p1->query(), p2->query() );
    }
    if ( p1->album() && p2->album() )
    {
        return lessThan( p1->album(), p2->album() );
    }

    return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
}
Example #4
0
bool WSortFilterProxyModel::Compare::operator()(int sourceRow1,
						int sourceRow2) const
{
  if (model->sortOrder_ == AscendingOrder)
    return lessThan(sourceRow1, sourceRow2);
  else
    return lessThan(sourceRow2, sourceRow1);
}
Example #5
0
int interseccao(ponto *p, segmento_ptr_pontos s1, segmento_ptr_pontos s2)
{


  GLfloat x1=s1.ponto1->x;
  GLfloat y1=s1.ponto1->y;
  GLfloat x2=s1.ponto2->x;
  GLfloat y2=s1.ponto2->y;
  GLfloat x3=s2.ponto1->x;
  GLfloat y3=s2.ponto1->y;
  GLfloat x4=s2.ponto2->x;
  GLfloat y4=s2.ponto2->y;

  GLfloat denominador = (y4 - y3)*(x2 - x1) - (x4 - x3)*(y2 - y1);

  // sao retas paralelas
  if (equal(denominador, 0.0)) {
  //Debug	printf("PARALLEL\n");
	return PARALLEL;
  }

 
  GLfloat ua = (x4 - x3)*(y1 - y3) - (y4 - y3)*(x1 - x3);
  ua /= denominador;

  GLfloat ub= (x2 - x1)*(y1 - y3) - (y2 - y1)*(x1 - x3);
  ub/= denominador;

  p->x = x1 + ua*(x2 - x1);
  p->y = y1 + ua*(y2 - y1);


  if ((greaterThan(ua, 0.0)) && (lessThan(ua, 1.0))) {
    if ((greaterThan(ub, 0.0)) && (lessThan(ub, 1.0))) {
  //Debug      printf("INSIDE BOTH\n");
      return INSIDE_BOTH;
    }
    else {
  //Debug      printf("INSIDE FIRST\n");
      return INSIDE_FIRST;
    }
  }
  else
    if ((greaterThan(ub, 0.0)) && (lessThan(ub, 1.0))) {
  //Debug      printf("INSIDE SECOND\n");
      return INSIDE_SECOND;
    }
    else {
  //Debug      printf("INSIDE NONE\n");
  //Debug      printf("ua=%f ub=%f\n", ua, ub);
      return INSIDE_NONE;
    }


}
bool NetStatsSortProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
    QVariant leftData = sourceModel()->data(left, Qt::UserRole);
    QVariant rightData = sourceModel()->data(right, Qt::UserRole);
    
    if (disappearedAtBottom) {
        QVariant lossLeft = sourceModel()->data(createIndex(left.row(), NetStatsModel::LOSS), Qt::UserRole);
        QVariant lossRight = sourceModel()->data(createIndex(right.row(), NetStatsModel::LOSS), Qt::UserRole);
        
        if (lossLeft.toDouble() == 1 and lossRight.toDouble() < 1) return false;
        if (lossRight.toDouble() == 1 and lossLeft.toDouble() < 1) return true;
    }
    
    switch (leftData.type()) {
        case QVariant::ByteArray:
            if (leftData.toByteArray() != rightData.toByteArray()) return leftData.toByteArray() < rightData.toByteArray();
            return lessThan(createIndex(left.row(), NetStatsModel::CHANNEL), createIndex(right.row(), NetStatsModel::CHANNEL));
        
        case QVariant::Double:
            if (leftData.toDouble() != rightData.toDouble()) return leftData.toDouble() < rightData.toDouble();
            return lessThan(createIndex(left.row(), NetStatsModel::CHANNEL), createIndex(right.row(), NetStatsModel::CHANNEL));
        
        case QVariant::Int:
            if (leftData.toInt() != rightData.toInt()) return leftData.toInt() < rightData.toInt();
            return lessThan(createIndex(left.row(), NetStatsModel::CHANNEL), createIndex(right.row(), NetStatsModel::CHANNEL));
        
        case QVariant::UInt: // Order by channel - Only channel is UInt
            if (leftData.toUInt() != rightData.toUInt()) return leftData.toUInt() < rightData.toUInt();
            
            // Same channel, try to order by BSSID
            leftData = sourceModel()->data(createIndex(left.row(), NetStatsModel::BSSID), Qt::UserRole);
            rightData = sourceModel()->data(createIndex(right.row(), NetStatsModel::BSSID), Qt::UserRole);
            
            if (leftData.toByteArray() != rightData.toByteArray()) return leftData.toByteArray() < rightData.toByteArray();
            
            // Same BSSID, order by SSID
            leftData = sourceModel()->data(createIndex(left.row(), NetStatsModel::SSID), Qt::UserRole);
            rightData = sourceModel()->data(createIndex(right.row(), NetStatsModel::SSID), Qt::UserRole);
            return leftData.toString().compare(rightData.toString(), Qt::CaseInsensitive) < 0;
            
        case QVariant::String:
          { int res = leftData.toString().compare(rightData.toString(), Qt::CaseInsensitive);
            if (res != 0) return res < 0;
            return lessThan(createIndex(left.row(), NetStatsModel::CHANNEL), createIndex(right.row(), NetStatsModel::CHANNEL)); }
        
        case QVariant::Bool:
            if (leftData.toBool() != rightData.toBool()) return leftData.toBool() < rightData.toBool();
            return lessThan(createIndex(left.row(), NetStatsModel::CHANNEL), createIndex(right.row(), NetStatsModel::CHANNEL));
        
        default:
            return true; // Error
    }
}
bool DesktopSortingStrategy::lessThanSeperateLaunchers(const AbstractGroupableItem *left, const AbstractGroupableItem *right)
{
    if (left->isStartupItem()) {
        if (right->isStartupItem()) {
            return left->name().toLower() < right->name().toLower();
        }
        return false;
    }

    if (right->isStartupItem()) {
        return true;
    }

    if (left->itemType() == LauncherItemType) {
        if (right->itemType() == LauncherItemType) {
            return left->name().toLower() < right->name().toLower();
        }
        return true;
    }

    if (right->itemType() == LauncherItemType) {
        return false;
    }

    return lessThan(left, right);
}
Example #8
0
	bool lessThan(const bignum &bn1, const bignum &bn2)
	{
		if (bn1.getBase() != bn2.getBase())
			return lessThan(bn1, bn2.getConverted(bn1.getBase()));

		if (bn1 == bn2)
			return false;

		if (bn1.isNegative() && !bn2.isNegative())
			return true;

		if (!bn1.isNegative() && bn2.isNegative())
			return false;

		if (bn1.isNegative() && bn2.isNegative())
			return (greaterThan(bn1.absolute(), bn2.absolute()));

		if (bn1.getDigitCount() < bn2.getDigitCount())
			return true;

		if (bn1.getDigitCount() > bn2.getDigitCount())
			return false;

		for (int i = bn1.getDigitCount() - 1; i >= 0; i--)
		{
			if (bn1.getDigit(i) < bn2.getDigit(i))
				return true;

			if (bn1.getDigit(i) > bn2.getDigit(i))
				return false;
		}

		return false;
	}
Example #9
0
int main() {

	Time t1(6, 30);
	Time t2(8, 51);

	bool isGreaterThan = greaterThan(t1, t2);
	if (isGreaterThan) cout << "t1 > t2: TRUE" << endl;
	else cout << "t1 > t2: FALSE" << endl;

	bool isLessThan = lessThan(t1, t2);
	if (isLessThan) cout << "t1 < t2: TRUE" << endl;
	else cout << "t1 < t2: FALSE" << endl;

	bool isEqual = equals(t1, t2);
	if (isEqual) cout << "t1 = t2: TRUE" << endl;
	else cout << "t1 = t2: FALSE" << endl;

	Time t3 = addTimes(t1, t2);
	cout << "t3 - minutes: " << t3.getMinutes() << " seconds: " << t3.getSeconds() << endl;

	Time t4 = subtractTimes(t1, t2);
	cout << "t4 - minutes: " << t4.getMinutes() << " seconds: " << t4.getSeconds() << endl;

	return 0;
}
Example #10
0
	bool greaterThan(const bignum &bn1, const bignum &bn2)
	{
		//if bases are different, convert the second and re-evaluate
		if (bn1.getBase() != bn2.getBase())
			return greaterThan(bn1, bn2.getConverted(bn1.getBase()));

		if (bn1 == bn2)
			return false;

		if (bn1.isNegative() && !bn2.isNegative())
			return false;

		if (!bn1.isNegative() && bn2.isNegative())
			return true;

		if (bn1.isNegative() && bn2.isNegative())
			return (lessThan(bn1.absolute(), bn2.absolute()));

		if (bn1.getDigitCount() > bn2.getDigitCount())
			return true;

		if (bn1.getDigitCount() < bn2.getDigitCount())
			return false;

		for (int i = bn1.getDigitCount() - 1; i >= 0; i--)
		{
			if (bn1.getDigit(i) > bn2.getDigit(i))
				return true;

			if (bn1.getDigit(i) < bn2.getDigit(i))
				return false;
		}

		return false;
	}
Example #11
0
SearchResult Search(const int * const items, const int n_items,
		const int ascending, const int key, const SearchType type,
		int* const index) {
	int i = 0;

	// If key with the matching search type is not found, index will be set to -1
	*index = -1;

	// Assuming if it is descending order (ascending = 0), else ascending order
	if (ascending == 0) {
		i = n_items - 1;
	}

	SearchResult result = NotFound;

	// Descending order is treated as reverse descending by starting from n_items - 1 to 0

	switch (type) {
	case LessThan:
		result = lessThan(items, n_items, ascending, key, type, &index, &i);
		break;

	case LessThanEquals:
		result = lessThan(items, n_items, ascending, key, type, &index, &i);
		if(equals(items, n_items, ascending, key, type, &index, &i) == FoundExact) {
			result = FoundExact;
		}
		break;

	case Equals:
		result = equals(items, n_items, ascending, key, type, &index, &i);
		break;

	case GreaterThan:
		result = greaterThan(items, n_items, ascending, key, type, &index, &i);
		break;

	case GreaterThanEquals:
		result = equals(items, n_items, ascending, key, type, &index, &i);
		if (result == FoundExact) {
			break;
		}
		result = greaterThan(items, n_items, ascending, key, type, &index, &i);
		break;
	}
	return result;
}
Example #12
0
        /*! @brief Return the relative ordering of two Values.
         @param[in] other The Value to be compared with.
         @returns The relative ordering of the two Values. */
        inline bool
        operator <
            (const Value &  other)
        {
            bool    valid = false;
            bool    result = lessThan(other, valid);

            return (valid && result);
        } // operator <
Example #13
0
void 
addVertex (Site* s, float x, float y)
{
    Info_t*     ip;
    PtItem*   p;
    PtItem*   curr;
    PtItem*   prev;
    Point*    origin = &(s->coord);
    PtItem    tmp;

/* fprintf (stderr, "addVertex (%d, %f, %f)\n", s->sitenbr, x, y); */
    ip = nodeInfo + (s->sitenbr);
    curr = ip->verts;

    tmp.p.x = x;
    tmp.p.y = y;


    if (lessThan(origin, &tmp, curr)) {
        p = (PtItem *) getfree(&pfl);
        p->p.x = x;
        p->p.y = y;
        p->next = curr;
        ip->verts = p;
        return;
    }

    prev = curr;
    curr = curr->next;
    while (!lessThan (origin, &tmp, curr)) {
        prev = curr;
        curr = curr->next;
    }
    if ((x == prev->p.x) && (y == prev->p.y)) return;
    p = (PtItem *) getfree(&pfl);
    p->p.x = x;
    p->p.y = y;
    prev->next = p;
    p->next = curr;

    if (!sorted(origin,ip->verts)) 
      error (ip,s,x,y);
}
bool EventsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
    EventData *leftEvent = left.data(EventsModel::EventDataPtr).value<EventData *>();
    EventData *rightEvent = right.data(EventsModel::EventDataPtr).value<EventData *>();

    if (leftEvent && rightEvent)
        return lessThan(leftEvent, rightEvent, m_column);

    return QSortFilterProxyModel::lessThan(left, right);
}
TInt CDatabaseManagerServerSession::SetInterfaceDefaultL(const RMessage2& aMessage)
    {
    TInt ret;
    HBufC* serviceNameBuf = HBufC::New(aMessage.GetDesLength(0));
    HBufC* interfaceNameBuf = HBufC::New(aMessage.GetDesLength(1));
    if (!serviceNameBuf || !interfaceNameBuf)
        return KErrNoMemory;

    TPtr ptrToBuf(serviceNameBuf->Des());
    TPtr ptrToBuf2(interfaceNameBuf->Des());
    
    TRAP(ret, aMessage.ReadL(0, ptrToBuf));
    TRAPD(ret2, aMessage.ReadL(1, ptrToBuf2));
    if (ret != KErrNone || ret2 != KErrNone)
        {
        iDb->lastError().setError(DBError::UnknownError);
        aMessage.Write(2, LastErrorCode());
        delete serviceNameBuf;
        delete interfaceNameBuf;
        return (ret == KErrNone) ? ret2 : ret;
        }

    QString serviceName = QString::fromUtf16(ptrToBuf.Ptr(), ptrToBuf.Length());
    QString interfaceName = QString::fromUtf16(ptrToBuf2.Ptr(), ptrToBuf2.Length());
    
    QList<QServiceInterfaceDescriptor> descriptors;
    QServiceFilter filter;
    filter.setServiceName(serviceName);
    filter.setInterface(interfaceName);
    // Nothing should be returned, because we are checking on nonexistent service
    descriptors = iDb->getInterfaces(filter);

    //find the descriptor with the latest version
    int latestIndex = 0;
        for (int i = 1; i < descriptors.count(); ++i) {
            if (lessThan(descriptors[latestIndex], descriptors[i]))
                latestIndex = i;
    }

    if (!descriptors.isEmpty()) {
        iDb->setInterfaceDefault(descriptors[latestIndex]);     
    }
    else {
        aMessage.Write(2, TError(DBError::NotFound));
        delete serviceNameBuf;
        delete interfaceNameBuf;
        return KErrNotFound;
    }

    aMessage.Write(2, LastErrorCode());
    delete serviceNameBuf;
    delete interfaceNameBuf;
    
    return ret;
    }
Example #16
0
void priority_queue<Object,Container,Compare>::push( const Object & x )
{
    theItems.push_back( x );
    theItems[ 0 ] = x;   // initialize sentinel

    // Percolate up
    int hole = size( );
    for( ; lessThan( theItems[ hole / 2 ], x ); hole /= 2 )
        theItems[ hole ] = theItems[ hole / 2 ];
    theItems[ hole ] = x;
}
Example #17
0
vec4 grad4(float j, vec4 ip)
  {
  const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);
  vec4 p,s;

  p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;
  p.w = 1.5 - dot(abs(p.xyz), ones.xyz);
  s = vec4(lessThan(p, vec4(0.0)));
  p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www; 

  return p;
  }
Example #18
0
void CGDSApp::LoadDLLS()
{//@CODE_3648

	// for now hardcode path
	SearchDLLS(CString(_T(".\\PlugIns\\*.dlb")), DLLTYPE_BASE);

	SearchDLLS(CString(_T(".\\PlugIns\\*.dlo")), DLLTYPE_OBJECT);

	m_DLLS.sort(lessThan());

    InitAllDLLS();

}//@CODE_3648
boolean isBST (tree t, element minKey, element maxKey)
{

    if (emptyTree (t)) {
        return true;
    }
    if (lessThan (root (t), minKey) || greaterThan (root(t), maxKey)) {
        return false;
    }

    return ( isBST(left(t), minKey, root (t)) && isBST(right (t), root (t), maxKey));

}
Example #20
0
    bool AbstractNumberFilter::evaluate(double number) const {
      bool evaluation = true;

      // multiple threads reading the m_lineEditText so lock it
      QString text = *m_lineEditText;

      bool ok = false;
      double d = text.toDouble(&ok);

      if (ok)
        evaluation = !(inclusive() ^ lessThan() ^(d <= number));

      return evaluation;
    }
/* In-order insert */
tree insOrd( element el, tree t )
{
    /* P = { el ∉ t } */
    if ( emptyTree( t ) ) {
        return consTree( el, EMPTYTREE, EMPTYTREE );
    }

    else if ( lessThan( el, root( t ) ) ) {
        return consTree( root( t ), insOrd( el, left( t ) ), right( t ) );
    }
    /* greaterThan(el, root(t)) */
    else {
        return consTree( root( t ), left( t ), insOrd( el, right( t ) ) );
    }
}
Example #22
0
// returns true if:
//   minheap is true and the priority of second < first
//   minheap is false and the priority of second > first
bool heap::rotate(graph_object* first, graph_object* second)
{
  if(minheap)
  {
	if (lessThan(second, first)) // NB: arg order (swapped)
	  return true;
	return false;
  }
  else
  {
	  if(greaterThan(second, first)) // NB: arg order 
		  return true;
	  return false;
  }
}
Example #23
0
void FunctionListModel::computeTopList()
{
    beginResetModel();
    _topList.clear();
    if (_filteredList.isEmpty()) {
        endResetModel();
        return;
    }

    FunctionLessThan lessThan(_sortColumn, _sortOrder, _eventType);
    std::stable_sort(_filteredList.begin(), _filteredList.end(), lessThan);

    foreach(TraceFunction* f, _filteredList) {
        _topList.append(f);
        if (_topList.count() >= _maxCount) break;
    }
/* Recirsive version.
 * NULL is returned if element with corresponding key is not found.
 */
tree searchBST ( tree t, element key )
{

    if (emptyTree (t)) {
        return EMPTYTREE;
    }
    else if (root (t) == key) {
        return t;
    }
    else if (lessThan( key, root( t ))) {
        return (searchBST (left (t), key));
    }
    else {
        return (searchBST (right (t), key));
    }

}
    virtual void SetUp()
    {
        ANGLETest::SetUp();

        const std::string testVertexShaderSource = SHADER_SOURCE
                (
                    attribute highp vec4 position;
                    attribute highp vec4 test;
                    attribute highp vec4 expected;

                    varying highp vec4 color;

                    void main(void)
        {
            gl_Position = position;
            color = vec4(lessThan(abs(test - expected), vec4(1.0 / 64.0)));
        }
Example #26
0
    QString AbstractNumberFilter::descriptionSuffix() const {
      QString suffix;

      if (!inclusive())
        suffix += "not ";

      if (lessThan())
        suffix += "less than or equal to \"";
      else
        suffix += "greater than or equal to \"";

      suffix += *m_lineEditText;

      suffix += "\"";

      return suffix;
    }
Example #27
0
bool ClientUser::lessThanOverlay(const ClientUser *first, const ClientUser *second) {
	if (g.s.os.osSort == OverlaySettings::LastStateChange) {
		// Talkers above non-talkers
		if (first->tsState != Settings::Passive && second->tsState == Settings::Passive)
			return true;
		if (first->tsState == Settings::Passive && second->tsState != Settings::Passive)
			return false;

		// Valid time above invalid time (possible when there wasn't a state-change yet)
		if (first->tLastTalkStateChange.isStarted() && !second->tLastTalkStateChange.isStarted())
			return true;
		if (!first->tLastTalkStateChange.isStarted() && second->tLastTalkStateChange.isStarted())
			return false;

		// If both have a valid time
		if (first->tLastTalkStateChange.isStarted() && second->tLastTalkStateChange.isStarted()) {
			// Among talkers, long > short
			// (if two clients are talking, the client that started first is above the other)
			if (first->tsState != Settings::Passive && second->tsState != Settings::Passive)
				return first->tLastTalkStateChange > second->tLastTalkStateChange;

			// Among non-talkers, short -> long
			// (if two clients are passive, the client that most recently stopped talking is above)
			if (first->tsState == Settings::Passive && second->tsState == Settings::Passive)
				return first->tLastTalkStateChange < second->tLastTalkStateChange;
		}

		// If both times are invalid, fall back to alphabetically (continuing below)
	}

	if (first->cChannel == second->cChannel || first->cChannel == NULL || second->cChannel == NULL)
		return lessThan(first, second);

	// When sorting for the overlay always place the local users
	// channel above the others
	ClientUser *self = c_qmUsers.value(g.uiSession);
	if (self) {
		if (self->cChannel == first->cChannel)
			return true;
		else if (self->cChannel == second->cChannel)
			return false;
	}

	return Channel::lessThan(first->cChannel, second->cChannel);
}
Example #28
0
ostream& operator << (ostream& out, const constraint& c)
{
    char* fmt = new char[100];

    if(!equal(c.xCoef, 0))
        sprintf(fmt, "%lfx", c.xCoef);

    if(greaterThan(c.yCoef, 0))
        sprintf(fmt, "%s+%lfy", fmt, c.yCoef);

    if(lessThan(c.yCoef, 0))
        sprintf(fmt, "%s-%lfy", fmt, -1*c.yCoef);

    sprintf(fmt, "%s<=%lf", fmt, -1*c.bias);
    out << fmt;

    delete [] fmt;

    return out;
}
Example #29
0
 void Parser::relation() 
 {
     expression();
     if (Cradle::isRelOp(input.getChar())) {
         output.emitLine("MOVE D0,(SP)-");
         switch (input.getChar()) {
             case '=':
                 equals();
                 break;
             case '#':
                 notEquals();
                 break;
             case '<':
                 lessThan();
                 break;
             case '>':
                 greaterThan();
                 break;
         }
         output.emitLine("TST D0");
     }
 }
Example #30
0
QModelIndex FunctionListModel::indexForFunction(TraceFunction *f, bool add)
{
    if (!f) return QModelIndex();

    int row = _topList.indexOf(f);
    if (row<0) {
        // we only add a function from _list matching the filter
        if ( !add ||
             !_filteredList.contains(f) ) return QModelIndex();

        // find insertion point with current list order
        FunctionLessThan lessThan(_sortColumn, _sortOrder, _eventType);
        QList<TraceFunction*>::iterator insertPos;
        insertPos = std::lower_bound(_topList.begin(), _topList.end(),
                                     f, lessThan);
        row = insertPos - _topList.begin();
        beginInsertRows(QModelIndex(), row, row);
        _topList.insert(row, f);
        endInsertRows();
    }

    return createIndex(row, 0, (void*)f);
}