void CWidgetSearchTemplate::on_treeViewSearchResults_doubleClicked(const QModelIndex &index)
{
	Q_UNUSED(index);
	SearchTreeItem* itemSearch = m_pSearchModel->topLevelItemFromIndex(CurrentItem());

	if( itemSearch != NULL )
	{
		CQueryHit* pHits = 0;
		CQueryHit* pLast = 0;

		for(int i = 0; i < itemSearch->childCount(); ++i)
		{
			if( pLast )
			{
				pLast->m_pNext = new CQueryHit(itemSearch->child(i)->HitData.pQueryHit.data());
				pLast = pLast->m_pNext;
			}
			else
			{
				pHits = new CQueryHit(itemSearch->child(i)->HitData.pQueryHit.data());
				pLast = pHits;
			}
		}

		Downloads.m_pSection.lock();
		Downloads.add(pHits);
		Downloads.m_pSection.unlock();

		delete pHits;
	}
}
示例#2
0
QModelIndex SearchTreeModel::index( int row, int column, const QModelIndex& parent ) const
{
	if ( !hasIndex( row, column, parent ) )
	{
		return QModelIndex();
	}

	SearchTreeItem* parentItem;

	if ( !parent.isValid() )
	{
		parentItem = m_pRootItem;
	}
	else
	{
		parentItem = static_cast<SearchTreeItem*>( parent.internalPointer() );
	}

	SearchTreeItem* childItem = parentItem->child( row );
	if ( childItem )
	{
		return createIndex( row, column, childItem );
	}
	else
	{
		return QModelIndex();
	}
}
bool SearchSortFilterProxyModel::filterAcceptsRow( int sourceRow,
												   const QModelIndex& sourceParent ) const
{
	if ( sourceParent.isValid() )
	{
		SearchTreeItem* parentItem = static_cast<SearchTreeItem*>( sourceParent.internalPointer() );

		Q_ASSERT( parentItem );
		return parentItem->child( sourceRow )->visible();
	}
	else // parent is top level/root item
	{
		return ( ( SearchTreeModel* )sourceModel() )->fileVisible( sourceRow );
	}
}