Possbile fix for #1754998

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@172 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 17 years ago
parent 9de7489805
commit 5db29eafed
  1. 26
      src/lib/GroupView.cpp

@ -220,10 +220,6 @@ void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){
} }
void KeepassGroupView::entryDropEvent( QDropEvent * event ){ void KeepassGroupView::entryDropEvent( QDropEvent * event ){
if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
}
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos()); GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
if(!Item){ if(!Item){
event->ignore(); event->ignore();
@ -233,40 +229,41 @@ void KeepassGroupView::entryDropEvent( QDropEvent * event ){
if(Item->GroupHandle==((EntryViewItem*)(*EntryDragItems)[0])->EntryHandle->group()) if(Item->GroupHandle==((EntryViewItem*)(*EntryDragItems)[0])->EntryHandle->group())
return; return;
for(int i=0;i<EntryDragItems->size();i++){ for(int i=0;i<EntryDragItems->size();i++){
db->moveEntry(((EntryViewItem*)(*EntryDragItems)[i])->EntryHandle,Item->GroupHandle); db->moveEntry(((EntryViewItem*)(*EntryDragItems)[i])->EntryHandle,Item->GroupHandle);
} }
emit entriesDropped(); emit entriesDropped();
emit fileModified(); emit fileModified();
} }
} }
void KeepassGroupView::dropEvent( QDropEvent * event ){ void KeepassGroupView::dropEvent( QDropEvent * event ){
if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
}
if(DragType==EntryDrag){ if(DragType==EntryDrag){
entryDropEvent(event); entryDropEvent(event);
return; return;
} }
if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
}
if(InsLinePos!=-1){ if(InsLinePos!=-1){
int RemoveLine=InsLinePos; int RemoveLine=InsLinePos;
InsLinePos=-1; InsLinePos=-1;
viewport()->update(QRegion(0,RemoveLine-2,viewport()->width(),4)); viewport()->update(QRegion(0,RemoveLine-2,viewport()->width(),4));
} }
GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos()); GroupViewItem* Item=(GroupViewItem*)itemAt(event->pos());
if(!Item){ if(!Item){
qDebug("Append at the end"); qDebug("Append at the end");
db->moveGroup(DragItem->GroupHandle,NULL,-1); db->moveGroup(DragItem->GroupHandle,NULL,-1);
if(DragItem->parent()){ if(DragItem->parent()){
DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem)); DragItem->parent()->takeChild(DragItem->parent()->indexOfChild(DragItem));
} }
else{ else{
takeTopLevelItem(indexOfTopLevelItem(DragItem)); takeTopLevelItem(indexOfTopLevelItem(DragItem));
} }
insertTopLevelItem(topLevelItemCount(),DragItem); insertTopLevelItem(topLevelItemCount(),DragItem);
if(topLevelItemCount()>1){ if(topLevelItemCount()>1){
@ -278,6 +275,9 @@ void KeepassGroupView::dropEvent( QDropEvent * event ){
emit fileModified(); emit fileModified();
} }
else{ else{
if (DragItem->GroupHandle==Item->GroupHandle)
return;
QRect ItemRect=visualItemRect(Item); QRect ItemRect=visualItemRect(Item);
if(event->pos().y()>ItemRect.y()+2 && event->pos().y()<ItemRect.y()+ItemRect.height()-2){ if(event->pos().y()>ItemRect.y()+2 && event->pos().y()<ItemRect.y()+ItemRect.height()-2){
qDebug("Append as child of '%s'",((char*)Item->text(0).toUtf8().data())); qDebug("Append as child of '%s'",((char*)Item->text(0).toUtf8().data()));