Example #1
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- the file-operation notifications handlers
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void OperationsModel::newOperationHandler( OperationId operationId, OperationId parentOperationId )
{
    // choosing the parent to work with
    Operation* theParent = isOperationValid(parentOperationId) ? parentOperationId : _rootItem;

    beginInsertRows( theParent->_modelIndex, theParent->childCount(), theParent->childCount()+1  );
    {
        theParent->appendChild( operationId );
        operationId->_parentItem = theParent; // doing the links between parent<-->child
        operationId->_modelIndex = QPersistentModelIndex( createIndex(operationId->row(),0,operationId) );
    }
    endInsertRows();
}
Example #2
0
int OperationsModel::rowCount( const QModelIndex& parent ) const
{
    Operation *parentItem;
     if( parent.column() > 0 )
         return 0;

     if( !parent.isValid() )
         parentItem = _rootItem;
     else
         parentItem = static_cast<Operation*>( parent.internalPointer() );

     return parentItem->childCount();
}