mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-20 18:27:16 +01:00
see #1980 Objects from Deleted Objects should not be allowed to be used in rules
This commit is contained in:
parent
7c1108204e
commit
498d9456ca
@ -1,5 +1,10 @@
|
||||
2011-01-24 Vadim Kurland <vadim@netcitadel.com>
|
||||
|
||||
* ObjectIconView.cpp (dragEnterEvent): see #1980 "Objects from
|
||||
Deleted Objects should not be allowed to be used in rules". Added
|
||||
checks to not allow drag&drop of an object from Deleted Objects
|
||||
library into rules and groups.
|
||||
|
||||
* NamedObject.cpp (createServiceObjectCommand): See #1958
|
||||
"consistently use "exit" to get out of nested context in pix
|
||||
config". Using "exit" to exit from nested context while adding
|
||||
|
||||
@ -343,6 +343,10 @@ void GroupObjectDialog::insertObject(FWObject *o)
|
||||
assert(g!=NULL);
|
||||
|
||||
if ( ! g->validateChild(o) || g->isReadOnly() ) return;
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
// note that we call insertObject() from dropEvent(), not only from paste()
|
||||
if (o->getLibrary()->getId() == FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
return;
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("Adding object %s to the group %s",
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "../../config.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "FWBTree.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectIconView.h"
|
||||
#include "ObjectIconViewItem.h"
|
||||
@ -147,7 +148,47 @@ void ObjectIconView::dragEnterEvent( QDragEnterEvent *ev)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectIconView::dragEnterEvent");
|
||||
ev->setAccepted( ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) );
|
||||
// ev->setAccepted( ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) );
|
||||
|
||||
QWidget *fromWidget = ev->source();
|
||||
|
||||
// The source of DnD object must be the same instance of fwbuilder
|
||||
if (!fromWidget)
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE))
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
list<FWObject*> dragol;
|
||||
if (!FWObjectDrag::decode(ev, dragol))
|
||||
ev->setAccepted(false);
|
||||
for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i)
|
||||
{
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj!=NULL);
|
||||
|
||||
if (FWBTree().isSystem(dragobj))
|
||||
{
|
||||
// can not drop system folder anywhere
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
if (dragobj->getLibrary()->getId() == FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ev->setAccepted(true);
|
||||
}
|
||||
|
||||
void ObjectIconView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
|
||||
#include "FWBTree.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectListView.h"
|
||||
#include "ObjectListViewItem.h"
|
||||
@ -160,7 +161,47 @@ void ObjectListView::dragEnterEvent( QDragEnterEvent *ev)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectListView::dragEnterEvent");
|
||||
ev->setAccepted( ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) );
|
||||
//ev->setAccepted( ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) );
|
||||
|
||||
QWidget *fromWidget = ev->source();
|
||||
|
||||
// The source of DnD object must be the same instance of fwbuilder
|
||||
if (!fromWidget)
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE))
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
list<FWObject*> dragol;
|
||||
if (!FWObjectDrag::decode(ev, dragol))
|
||||
ev->setAccepted(false);
|
||||
for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i)
|
||||
{
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj!=NULL);
|
||||
|
||||
if (FWBTree().isSystem(dragobj))
|
||||
{
|
||||
// can not drop system folder anywhere
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
if (dragobj->getLibrary()->getId() == FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ev->setAccepted(true);
|
||||
}
|
||||
|
||||
void ObjectListView::dropEvent(QDropEvent *ev)
|
||||
|
||||
@ -461,6 +461,7 @@ void ObjectTreeView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
list<FWObject*> dragol;
|
||||
if (!FWObjectDrag::decode(ev, dragol))
|
||||
ev->setAccepted(false);
|
||||
@ -475,6 +476,13 @@ void ObjectTreeView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
if (dragobj->getLibrary()->getId() == FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
{
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ev->setAccepted(true);
|
||||
|
||||
@ -742,7 +742,7 @@ void RuleSetView::addColumnRelatedMenu(QMenu *menu, const QModelIndex &index,
|
||||
FWObject *obj_in_clipboard =
|
||||
FWObjectClipboard::obj_clipboard->getObject();
|
||||
bool obj_deleted = (obj_in_clipboard &&
|
||||
obj_in_clipboard->getParent()->getId() ==
|
||||
obj_in_clipboard->getLibrary()->getId() ==
|
||||
FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
pasteID->setEnabled(obj_in_clipboard!=NULL && !obj_deleted);
|
||||
|
||||
@ -2213,7 +2213,8 @@ bool RuleSetView::validateForInsertionToInterfaceRE(RuleElementItf *re,
|
||||
bool RuleSetView::validateForInsertion(QModelIndex index, FWObject *obj)
|
||||
{
|
||||
ColDesc colDesc = index.data(Qt::UserRole).value<ColDesc>();
|
||||
if (colDesc.type != ColDesc::Object && colDesc.type != ColDesc::Time) return false;
|
||||
if (colDesc.type != ColDesc::Object && colDesc.type != ColDesc::Time)
|
||||
return false;
|
||||
|
||||
RuleElement *re = (RuleElement *)index.data(Qt::DisplayRole).value<void *>();
|
||||
assert (re!=NULL);
|
||||
@ -2224,6 +2225,10 @@ bool RuleSetView::validateForInsertion(RuleElement *re, FWObject *obj, bool quie
|
||||
{
|
||||
if (RuleSet::cast(obj)!=NULL) return false;
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
if (obj && obj->getLibrary()->getId() == FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
return false;
|
||||
|
||||
if (! re->validateChild(obj) )
|
||||
{
|
||||
if (!quiet)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user