Esempio n. 1
0
/*!
  \reimp
*/
void QStringListModel::sort(int, Qt::SortOrder order)
{
    emit layoutAboutToBeChanged();

    QList<QPair<QString, int> > list;
    for (int i = 0; i < lst.count(); ++i)
        list.append(QPair<QString, int>(lst.at(i), i));

    if (order == Qt::AscendingOrder)
        qSort(list.begin(), list.end(), ascendingLessThan);
    else
        qSort(list.begin(), list.end(), decendingLessThan);

    lst.clear();
    QVector<int> forwarding(list.count());
    for (int i = 0; i < list.count(); ++i) {
        lst.append(list.at(i).first);
        forwarding[list.at(i).second] = i;
    }

    QModelIndexList oldList = persistentIndexList();
    QModelIndexList newList;
    for (int i = 0; i < oldList.count(); ++i)
        newList.append(index(forwarding.at(oldList.at(i).row()), 0));
    changePersistentIndexList(oldList, newList);

    emit layoutChanged();
}
Esempio n. 2
0
QModelIndex KrVfsModel::addItem(vfile * vf)
{
    emit layoutAboutToBeChanged();

    if(lastSortOrder() == KrViewProperties::NoColumn) {
        int idx = _vfiles.count();
        _vfiles.append(vf);
        _vfileNdx[vf] = index(idx, 0);
        _nameNdx[vf->vfile_getName()] = index(idx, 0);
        emit layoutChanged();
        return index(idx, 0);
    }

    QModelIndexList oldPersistentList = persistentIndexList();

    KrSort::Sorter sorter(createSorter());

    int insertIndex = sorter.insertIndex(vf, vf == _dummyVfile, customSortData(vf));
    if (insertIndex != _vfiles.count())
        _vfiles.insert(insertIndex, vf);
    else
        _vfiles.append(vf);

    for (int i = insertIndex; i < _vfiles.count(); ++i) {
        _vfileNdx[ _vfiles[ i ] ] = index(i, 0);
        _nameNdx[ _vfiles[ i ]->vfile_getName()] = index(i, 0);
    }

    QModelIndexList newPersistentList;
    foreach(const QModelIndex &mndx, oldPersistentList) {
        int newRow = mndx.row();
        if (newRow >= insertIndex)
            newRow++;
        newPersistentList << index(newRow, mndx.column());
    }
void FormGenBagModel::setCompareOperator(const Compare &comparison)
{
    emit layoutAboutToBeChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint);

    QHash<int, int> persistentRows;
    {
        auto tmp = persistentIndexList();
        for( const auto &idx: tmp )
            persistentRows.insert(idx.row(), -1);
    }

    mItems.setCompareOperatorGetReorderMap(comparison, &persistentRows);

    {
        QModelIndexList oldList, newList;
        oldList.reserve(persistentRows.size());
        newList.reserve(persistentRows.size());
        for( auto it = persistentRows.cbegin(); it != persistentRows.cend(); ++it ) {
            //changePersistentIndex(index(it.key()), index(it.value()));
            oldList.append(index(it.key()));
            newList.append(index(it.value()));
        }
        changePersistentIndexList(oldList, newList);
    }

    emit layoutChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint);
}
Esempio n. 4
0
void FeedbackModel::sort( int column, Qt::SortOrder order )
{
	if ( rowCount() == 0 ) {
		return;
	}
	
	emit layoutAboutToBeChanged();
	
	const QModelIndexList oldIndexes = persistentIndexList();
	QModelIndexList newIndexes;
	
	QMap<int, Feedback> oldMapping;
	QMap<Feedback, int> newMapping;
	
	for ( int i = 0; i < d->feedbacks.count(); i++ ) {
		oldMapping[ i ] = d->feedbacks[ i ];
	}
	
	switch ( order ) {
		case Qt::AscendingOrder: {
			if ( column == 0 ) {
				qSort( d->feedbacks.begin(), d->feedbacks.end() );
			}
			else if ( column == 1 ) {
				qSort( d->feedbacks.begin(), d->feedbacks.end(), FeedbackModelPrivate::lessThanMessage );
			}
			
			break;
		}
		
		case Qt::DescendingOrder: {
			if ( column == 0 ) {
				qSort( d->feedbacks.begin(), d->feedbacks.end(), qGreater<Feedback>() );
			}
			else if ( column == 1 ) {
				qSort( d->feedbacks.begin(), d->feedbacks.end(), FeedbackModelPrivate::greaterThanMessage );
			}
			
			break;
		}
	}
	
	for ( int i = 0; i < d->feedbacks.count(); i++ ) {
		newMapping[ d->feedbacks[ i ] ] = i;
	}
	
	for ( int i = 0; i < oldIndexes.count(); i++ ) {
		const QModelIndex& index = oldIndexes[ i ];
		const Feedback& feedback = oldMapping[ index.row() ];
		newIndexes << QAbstractTableModel::index( newMapping[ feedback ], index.column() );
	}
	
	changePersistentIndexList( oldIndexes, newIndexes );
	
	emit layoutChanged();
}
Esempio n. 5
0
QModelIndexList LibraryModel::dirNodeModelIndexes() const
{
    QModelIndexList dirNodeList;
    for(QModelIndex ind : persistentIndexList()) {
        if(entryFromIndex(ind)->isDirNode()) {
            dirNodeList << ind;
        }
    }
    return dirNodeList;
}
Esempio n. 6
0
    bool DragDropModel::dropMimeData(const QMimeData *data,
                                     Qt::DropAction /*action*/, int row, int /*column*/, const QModelIndex &parent)
    {
        if (!data->hasFormat("text/plain"))
            return false;

        QByteArray encodedData = data->data("text/plain");
        QDataStream stream(&encodedData, QIODevice::ReadOnly);

        qint64 _id;
        int _row;
        int _column;

        stream >> _id >> _row >> _column;

        QModelIndexList pers = persistentIndexList();
        foreach(const QModelIndex &idx, pers)
        {
            if (idx.row() == _row && idx.column() == _column && idx.internalId() == _id )
            {
                if ( idx.parent().internalId() == parent.internalId() )
                    return false;

                Tree *child = static_cast<Tree*>(idx.internalPointer());
                if ( child == 0 )
                    return false;

                Tree *oldParent = child->parent();
                if ( oldParent == 0 )
                    return false;

                Tree *newParent = static_cast<Tree*>(parent.internalPointer());
                if ( newParent == 0 )
                    return false;

                beginMoveRows(idx.parent(), idx.row(), idx.row(), parent, parent.row());

                try
                {
                    oldParent->removeChild(idx.row());
                    newParent->addChild(child, row);
                    child->setParent(newParent);
                }
                catch (SqlError&){}

                endMoveRows();

                return true;
            }
        }

        return true;
    }
Esempio n. 7
0
void QCompletionModel::resetModel()
{
    if (rowCount() == 0) {
        reset();
        return;
    }

    emit layoutAboutToBeChanged();
    QModelIndexList piList = persistentIndexList();
    QModelIndexList empty;
    for (int i = 0; i < piList.size(); i++)
        empty.append(QModelIndex());
    changePersistentIndexList(piList, empty);
    emit layoutChanged();
}
Esempio n. 8
0
 foreach (AbstractInventoryItem *item, children)
 {
     if (item->GetItemType() == AbstractInventoryItem::Type_Folder)
     {
         InventoryFolder *folder = dynamic_cast<InventoryFolder*>(item);
         if (!folder)
             continue;
         CheckChildrenForDirtys(folder->GetChildren());
         if (!folder->IsDirty())
             continue;
         QModelIndexList all_items = persistentIndexList();
         foreach (QModelIndex index, all_items)
             if (item == reinterpret_cast<AbstractInventoryItem *>(index.internalPointer()))
                 emit IndexModelIsDirty(index);
         folder->SetDirty(false);
     }
Esempio n. 9
0
void DistrictModel::sort( int column, Qt::SortOrder order )
{
	Q_UNUSED( column );
	
	if ( rowCount() == 0 ) {
		return;
	}
	
	emit layoutAboutToBeChanged();
	
	const QModelIndexList oldIndexes = persistentIndexList();
	QModelIndexList newIndexes;
	
	QMap<int, District> oldMapping;
	QMap<District, int> newMapping;
	
	for ( int i = 0; i < d->districts.count(); i++ ) {
		oldMapping[ i ] = d->districts[ i ];
	}
	
	switch ( order ) {
		case Qt::AscendingOrder: {
			qSort( d->districts.begin(), d->districts.end() );
			break;
		}
		
		case Qt::DescendingOrder: {
			qSort( d->districts.begin(), d->districts.end(), qGreater<District>() );
			break;
		}
	}
	
	for ( int i = 0; i < d->districts.count(); i++ ) {
		newMapping[ d->districts[ i ] ] = i;
	}
	
	for ( int i = 0; i < oldIndexes.count(); i++ ) {
		const QModelIndex& index = oldIndexes[ i ];
		const District& district = oldMapping[ index.row() ];
		newIndexes << QAbstractTableModel::index( newMapping[ district ], index.column() );
	}
	
	changePersistentIndexList( oldIndexes, newIndexes );
	
	emit layoutChanged();
}
Esempio n. 10
0
void pOpenedFileModel::rebuildMapping( const QList<pAbstractChild*>& oldList, const QList<pAbstractChild*>& newList )
{
    emit layoutAboutToBeChanged();
    const QModelIndexList pOldIndexes = persistentIndexList();
    QModelIndexList pIndexes;
    QMap<int, pAbstractChild*> documentsMapping;
    QMap<int, int> mapping;

    // build old mapping
    for ( int i = 0; i < pOldIndexes.count(); i++ )
    {
        const QModelIndex& index = pOldIndexes.at( i );
        const int row = index.row();
        documentsMapping[ row ] = oldList.at( row );
        mapping[ row ] = row;
    }

    mDocuments = newList;

    // build new mapping
    for ( int i = 0; i < pOldIndexes.count(); i++ )
    {
        const QModelIndex& pIndex = pOldIndexes.at( i );
        const int row = pIndex.row();
        pAbstractChild* document = documentsMapping[ row ];
        const int index = mDocuments.indexOf( document );
        mapping[ row ] = index;
    }

    for ( int i = 0; i < pOldIndexes.count(); i++ )
    {
        const QModelIndex& pIndex = pOldIndexes.at( i );
        const int row = pIndex.row();
        const int index = mapping[ row ];

        if ( pOldIndexes.at( i ).isValid() )
            pIndexes << createIndex( index, pIndex.column(), mDocuments.at( index ) );
        else
            pIndexes << QModelIndex();
    }

    changePersistentIndexList( pOldIndexes, pIndexes );
    emit layoutChanged();
}
Esempio n. 11
0
void MessageModel::replaceMeWithSubtree(const QModelIndex &parent, MessagePart *partToReplace, MessagePart::Ptr tree)
{
    Q_ASSERT(!parent.isValid() || parent.model() == this);
    auto *part = translatePtr(parent);
    Q_ASSERT(part);

#ifdef MIME_TREE_DEBUG
    qDebug() << "Whole tree:\n" << *m_rootPart;
    qDebug() << "Replacing:\n" << (void*)(partToReplace);
    qDebug() << "New items:\n" << *(tree.get());
#endif

    Q_ASSERT(partToReplace);
    Q_ASSERT(tree->row() == partToReplace->row());

    auto it = part->m_children.find(partToReplace->row());
    Q_ASSERT(it != part->m_children.end());
    Q_ASSERT(it->second->row() == partToReplace->row());
    Q_ASSERT(partToReplace->row() == tree->row());

    emit layoutAboutToBeChanged(QList<QPersistentModelIndex>() << parent);

    auto oldIndexes = persistentIndexList();
    auto newIndexes = oldIndexes;
    for (int i = 0; i < oldIndexes.size(); ++i) {
        const auto &index = oldIndexes[i];
        if (index.parent() == parent && index.column() == 0 && index.row() == tree->row()) {
            newIndexes[i] = createIndex(tree->row(), 0, tree.get());
        }
    }
    changePersistentIndexList(oldIndexes, newIndexes);

    tree->m_parent = part;
    MessagePart::Ptr partGoingAway = std::move(it->second);
    it->second = std::move(tree);
    emit layoutChanged(QList<QPersistentModelIndex>() << parent);

    emit dataChanged(parent, parent);

#ifdef MIME_TREE_DEBUG
    qDebug() << "After replacement:\n" << *m_rootPart;
#endif
}
Esempio n. 12
0
void SolutionModel::sort(int column, Qt::SortOrder order) {
  sortColumn = column;
  sortOrder = order;

  for (int i=0; i<solutions.size(); i++)
    solutions[i].solutionIndex = i;

  emit layoutAboutToBeChanged();

  qStableSort(solutions.begin(), solutions.end(), SolutionCompare(sortColumn, sortOrder));

  QVector<int> ids(solutions.size());
  for (int i=0; i<solutions.size(); i++) {
    ids[solutions.at(i).solutionIndex]=i;
  }

  QModelIndexList oldPersistentIndices = persistentIndexList();
  QModelIndexList newPersistentIndices;
  foreach (QModelIndex idx, oldPersistentIndices) {
    newPersistentIndices << index(ids.at(idx.row()), idx.column(), idx.parent());
  }
Esempio n. 13
0
void KrVfsModel::sort(int column, Qt::SortOrder order)
{
    _view->sortModeUpdated(column, order);

    if(lastSortOrder() == KrViewProperties::NoColumn)
        return;

    emit layoutAboutToBeChanged();

    QModelIndexList oldPersistentList = persistentIndexList();

    KrSort::Sorter sorter(createSorter());
    sorter.sort();

    _vfiles.clear();
    _vfileNdx.clear();
    _nameNdx.clear();

    bool sortOrderChanged = false;
    QHash<int, int> changeMap;
    for (int i = 0; i < sorter.items().count(); ++i) {
        const KrSort::SortProps *props = sorter.items()[i];
        _vfiles.append(props->vf());
        changeMap[ props->originalIndex() ] = i;
        if (i != props->originalIndex())
            sortOrderChanged = true;
        _vfileNdx[ props->vf()] = index(i, 0);
        _nameNdx[ props->vf()->vfile_getName()] = index(i, 0);
    }

    QModelIndexList newPersistentList;
    foreach(const QModelIndex &mndx, oldPersistentList)
        newPersistentList << index(changeMap[ mndx.row()], mndx.column());

    changePersistentIndexList(oldPersistentList, newPersistentList);

    emit layoutChanged();
    if (sortOrderChanged)
        _view->makeItemVisible(_view->getCurrentKrViewItem());
}
Esempio n. 14
0
void KrVfsModel::clear()
{
    if(!_vfiles.count())
        return;
    emit layoutAboutToBeChanged();
    // clear persistent indexes
    QModelIndexList oldPersistentList = persistentIndexList();
    QModelIndexList newPersistentList;
#if QT_VERSION >= 0x040700
    newPersistentList.reserve(oldPersistentList.size());
#endif
    for (int i=0; i< oldPersistentList.size(); ++i)
        newPersistentList.append(QModelIndex());
    changePersistentIndexList(oldPersistentList, newPersistentList);

    _vfiles.clear();
    _vfileNdx.clear();
    _nameNdx.clear();
    _dummyVfile = 0;

    emit layoutChanged();
}
Esempio n. 15
0
QModelIndexList TreeModel::getPersistentIndexList() const
{
  return persistentIndexList();
}
Esempio n. 16
0
 QModelIndexList per() const
 {
     return persistentIndexList();
 }
Esempio n. 17
0
/*
  Return[0]: totalFile
  Return[1]: totalSize
  Return[2]: currentFile
  */
QList<quint64> TransferModel::synchronizeItems(const QList<Ultracopier::ReturnActionOnCopyList>& returnActions)
{
    const QModelIndexList oldIndexes = persistentIndexList();
    QModelIndexList newIndexes=oldIndexes;
    loop_size=returnActions.size();
    index_for_loop=0;
    totalFile=0;
    totalSize=0;
    currentFile=0;
    emit layoutAboutToBeChanged();
    while(index_for_loop<loop_size)
    {
        const Ultracopier::ReturnActionOnCopyList& action=returnActions.at(index_for_loop);
        switch(action.type)
        {
        case Ultracopier::AddingItem:
        {
            TransfertItem newItem;
            newItem.id=action.addAction.id;
            newItem.source=action.addAction.sourceFullPath;
            newItem.size=facilityEngine->sizeToString(action.addAction.size);
            newItem.destination=action.addAction.destinationFullPath;
            transfertItemList<<newItem;
            totalFile++;
            totalSize+=action.addAction.size;
        }
        break;
        case Ultracopier::MoveItem:
        {
            //bool current_entry=
            if(action.userAction.position<0)
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            if(action.userAction.position>(transfertItemList.size()-1))
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            if(action.userAction.moveAt<0)
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            if(action.userAction.moveAt>(transfertItemList.size()-1))
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            if(action.userAction.position==action.userAction.moveAt)
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, move at same position: %2").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            transfertItemList.move(action.userAction.position,action.userAction.moveAt);
            //newIndexes.move(action.userAction.position,action.userAction.moveAt);
        }
        break;
        case Ultracopier::RemoveItem:
        {
            if(currentIndexSearch>0 && action.userAction.position<=currentIndexSearch)
                currentIndexSearch--;
            if(action.userAction.position<0)
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            if(action.userAction.position>(transfertItemList.size()-1))
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
                break;
            }
            transfertItemList.removeAt(action.userAction.position);
            currentFile++;
            startId.remove(action.addAction.id);
            stopId.remove(action.addAction.id);
            internalRunningOperation.remove(action.addAction.id);
            //newIndexes.remove(action.userAction.moveAt);
        }
        break;
        case Ultracopier::PreOperation:
        {
            ItemOfCopyListWithMoreInformations tempItem;
            tempItem.currentReadProgression=0;
            tempItem.currentWriteProgression=0;
            tempItem.generalData=action.addAction;
            tempItem.actionType=action.type;
            internalRunningOperation[action.addAction.id]=tempItem;
        }
        break;
        case Ultracopier::Transfer:
        {
            if(!startId.contains(action.addAction.id))
                startId << action.addAction.id;
            stopId.remove(action.addAction.id);
            if(internalRunningOperation.contains(action.addAction.id))
                internalRunningOperation[action.addAction.id].actionType=action.type;
            else
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("unable to found entry for file %1: actionType: Transfer").arg(action.addAction.id));
        }
        break;
        case Ultracopier::PostOperation:
        {
            if(!stopId.contains(action.addAction.id))
                stopId << action.addAction.id;
            startId.remove(action.addAction.id);
        }
        break;
        case Ultracopier::CustomOperation:
        {
            bool custom_with_progression=(action.addAction.size==1);
            //without progression
            if(custom_with_progression)
            {
                if(startId.remove(action.addAction.id))
                    if(!stopId.contains(action.addAction.id))
                        stopId << action.addAction.id;
            }
            //with progression
            else
            {
                stopId.remove(action.addAction.id);
                if(!startId.contains(action.addAction.id))
                    startId << action.addAction.id;
            }
            if(internalRunningOperation.contains(action.addAction.id))
            {
                ItemOfCopyListWithMoreInformations &item=internalRunningOperation[action.addAction.id];
                item.actionType=action.type;
                item.custom_with_progression=custom_with_progression;
                item.currentReadProgression=0;
                item.currentWriteProgression=0;
            }
        }
        break;
        default:
            //unknow code, ignore it
            break;
        }
        index_for_loop++;
    }
    //changePersistentIndexList( oldIndexes, newIndexes );
    emit layoutChanged();
    return QList<quint64>() << totalFile << totalSize << currentFile;
}
Esempio n. 18
0
/*
  Return[0]: totalFile
  Return[1]: totalSize
  Return[2]: currentFile
  */
QList<quint64> TransferModel::synchronizeItems(const QList<Ultracopier::ReturnActionOnCopyList>& returnActions)
{
    loop_size=returnActions.size();
    index_for_loop=0;
    quint64 totalFile=0,totalSize=0,currentFile=0;
    totalFile=0;
    totalSize=0;
    currentFile=0;

    emit layoutAboutToBeChanged();
    const QModelIndexList oldIndexes = persistentIndexList();
    QModelIndexList newIndexes = oldIndexes;
    QMap<int, quint64> oldMapping;  // model index row in model before update, item id
    QMap<quint64, int> newMapping;  // item id, model index row in model after update

    for ( int i = 0; i < oldIndexes.count(); i++ ) {
        const QModelIndex& index = oldIndexes[ i ];
        oldMapping[ index.row() ] = index.data( Qt::UserRole ).value<quint64>();
    }

    while(index_for_loop<loop_size)
    {
        const Ultracopier::ReturnActionOnCopyList& action=returnActions.at(index_for_loop);
        switch(action.type)
        {
            case Ultracopier::AddingItem:
            {
                TransfertItem newItem;
                newItem.id=action.addAction.id;
                newItem.source=action.addAction.sourceFullPath;
                newItem.size=facilityEngine->sizeToString(action.addAction.size);
                newItem.destination=action.addAction.destinationFullPath;
                transfertItemList<<newItem;
                totalFile++;
                totalSize+=action.addAction.size;
            }
            break;
            case Ultracopier::MoveItem:
            {
                //bool current_entry=
                if(action.userAction.position<0)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                if(action.userAction.position>(transfertItemList.size()-1))
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                if(action.userAction.moveAt<0)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                if(action.userAction.moveAt>(transfertItemList.size()-1))
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, position is wrong: %2").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                if(action.userAction.position==action.userAction.moveAt)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("id: %1, move at same position: %2").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                transfertItemList.move(action.userAction.position,action.userAction.moveAt);
                //newIndexes.move(action.userAction.position,action.userAction.moveAt);
            }
            break;
            case Ultracopier::RemoveItem:
            {
                if(currentIndexSearch>0 && action.userAction.position<=currentIndexSearch)
                    currentIndexSearch--;
                if(action.userAction.position<0)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                if(action.userAction.position>(transfertItemList.size()-1))
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("id: %1, position is wrong: %3").arg(action.addAction.id).arg(action.userAction.position));
                    break;
                }
                transfertItemList.removeAt(action.userAction.position);
                currentFile++;
                startId.remove(action.addAction.id);
                stopId.remove(action.addAction.id);
                internalRunningOperation.remove(action.addAction.id);
                //newIndexes.remove(action.userAction.moveAt);
            }
            break;
            case Ultracopier::PreOperation:
            {
                ItemOfCopyListWithMoreInformations tempItem;
                tempItem.currentReadProgression=0;
                tempItem.currentWriteProgression=0;
                tempItem.generalData=action.addAction;
                tempItem.actionType=action.type;
                internalRunningOperation[action.addAction.id]=tempItem;
            }
            break;
            case Ultracopier::Transfer:
            {
                if(!startId.contains(action.addAction.id))
                    startId << action.addAction.id;
                stopId.remove(action.addAction.id);
                if(internalRunningOperation.contains(action.addAction.id))
                    internalRunningOperation[action.addAction.id].actionType=action.type;
                else
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("unable to found entry for file %1: actionType: Transfer").arg(action.addAction.id));
            }
            break;
            case Ultracopier::PostOperation:
            {
                if(!stopId.contains(action.addAction.id))
                    stopId << action.addAction.id;
                startId.remove(action.addAction.id);
            }
            break;
            case Ultracopier::CustomOperation:
            {
                bool custom_with_progression=(action.addAction.size==1);
                //without progression
                if(custom_with_progression)
                {
                    if(startId.remove(action.addAction.id))
                        if(!stopId.contains(action.addAction.id))
                            stopId << action.addAction.id;
                }
                //with progression
                else
                {
                    stopId.remove(action.addAction.id);
                    if(!startId.contains(action.addAction.id))
                        startId << action.addAction.id;
                }
                if(internalRunningOperation.contains(action.addAction.id))
                {
                    ItemOfCopyListWithMoreInformations &item=internalRunningOperation[action.addAction.id];
                    item.actionType=action.type;
                    item.custom_with_progression=custom_with_progression;
                    item.currentReadProgression=0;
                    item.currentWriteProgression=0;
                }
            }
            break;
            default:
                //unknow code, ignore it
            break;
        }
        index_for_loop++;
    }

    if(!oldIndexes.isEmpty())
    {
        const QSet<quint64> ids = oldMapping.values().toSet();

        for ( int i = 0; i < transfertItemList.count(); i++ ) {
            const TransferModel::TransfertItem& item = transfertItemList[ i ];

            if ( ids.contains( item.id ) ) {
                newMapping[ item.id ] = i;
            }
        }

        for ( int i = 0; i < oldIndexes.count(); i++ ) {
            const QModelIndex& index = oldIndexes[ i ];
            const int newRow = newMapping.value( oldMapping[ index.row() ], -1 );
            newIndexes[ i ] = newRow == -1 ? QModelIndex() : QAbstractTableModel::index( newRow, index.column(), index.parent() );
        }
    }

    changePersistentIndexList( oldIndexes, newIndexes );
    emit layoutChanged();
    return QList<quint64>() << totalFile << totalSize << currentFile;
}