Eureka ! Only one thing that I need to do just change dragDropMode in QTreeView from InternalMove to DragDrop. And Modified version of dropMimeData now looks like this :
@bool GroupsModel::dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int col, const QModelIndex & parent )
{
QByteArray encodedData = data->data("text/plain");
QDataStream stream(&encodedData, QIODevice::ReadOnly);
int takedGpIndex, takedSubIndex;
QModelIndexList deleteList;
while (!stream.atEnd()) {
stream >> takedGpIndex >> takedSubIndex;
if (takedGpIndex < 0 || takedSubIndex < 0)
continue;
// ********************************* take item calculations ***********************//
// get place in structure
Group * takedGp = m_groups.getGroupByIndex(takedGpIndex);
if (takedGp == NULL)
continue;
GroupSubscriber * sub = takedGp->getSubscriberByIndex(takedSubIndex);
if(sub == NULL)
continue;
// ********************************* drop place calculations ***********************//
// get place in structure
int putGpNdx = -1;
if (parent.isValid() && parent.internalId() <= 0)
putGpNdx = parent.row();
else
putGpNdx = row;
Group * putGp = m_groups.getGroupByIndex(putGpNdx);
if(putGp == NULL)
continue;
// put data
QModelIndex putParent = index(putGpNdx,eID,m_null);
if(takedGp == putGp)
{
if(row == -1)
continue;
if(row >= putGp->count())
{
int pRow = putGp->count();
beginInsertRows(putParent,pRow,pRow);
GroupSubscriber * newSub = new GroupSubscriber(*sub);
putGp->addSubscriber(newSub);
endInsertRows();
}
else
{
beginInsertRows(putParent,row,row);
takedGp->copySubscriber(takedSubIndex,row);
endInsertRows();
if(takedSubIndex>row)
takedSubIndex++;
}
}
else
{
if(row == -1)
{
int pRow = putGp->count();
beginInsertRows(putParent,pRow,pRow);
GroupSubscriber * newSub = new GroupSubscriber(*sub);
putGp->addSubscriber(newSub);
endInsertRows();
}
else
{
beginInsertRows(putParent,row,row);
GroupSubscriber * newSub = new GroupSubscriber(*sub);
putGp->insertSubscriber(newSub,row);
endInsertRows();
}
}
m_bChanged = true;
QModelIndex takeParent = index(takedGpIndex,eID,m_null);
deleteList.append(takeParent.child(takedSubIndex,eID));
}
if(action == Qt::MoveAction)
removeItems(deleteList,false);
return true;
}@