Remove redundant drag'n'drop interface

In the long time of parallel assembly development an own drag'n'drop interface has been added to master and assembly branch. After merge both have been available. This commit removes one and keeps the more extensive implementation
This commit is contained in:
Stefan Tröger 2016-08-27 12:25:15 +02:00 committed by wmayer
parent 0a539538de
commit cd53eb2280
7 changed files with 43 additions and 130 deletions

View File

@ -564,7 +564,6 @@ void TreeWidget::dropEvent(QDropEvent *event)
// now add the object to the target object
vp->dropObject(obj);
}
targetItemObj->drop(dropObjects,event->keyboardModifiers(),event->mouseButtons(),event->pos());
}
else if (targetitem->type() == TreeWidget::DocumentType) {
// Open command
@ -1444,15 +1443,6 @@ void DocumentObjectItem::testStatus()
this->setIcon(0, icon_mod);
}
bool DocumentObjectItem::allowDrop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos)
{
return viewObject->allowDrop(objList,keys,mouseBts,pos);
}
void DocumentObjectItem::drop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos)
{
viewObject->drop(objList,keys,mouseBts,pos);
}
void DocumentObjectItem::displayStatusInfo()
{
App::DocumentObject* Obj = viewObject->getObject();

View File

@ -203,9 +203,6 @@ public:
void setData(int column, int role, const QVariant & value);
bool isChildOfItem(DocumentObjectItem*);
bool allowDrop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos);
void drop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos);
protected:
void slotChangeIcon();
void slotChangeToolTip(const QString&);

View File

@ -284,26 +284,3 @@ PyObject* ViewProviderDocumentObject::getPyObject()
pyViewObject->IncRef();
return pyViewObject;
}
bool ViewProviderDocumentObject::allowDrop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos)
{
Q_UNUSED(objList);
Q_UNUSED(keys);
Q_UNUSED(mouseBts);
Q_UNUSED(pos);
return false;
}
void ViewProviderDocumentObject::drop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos)
{
Q_UNUSED(objList);
Q_UNUSED(keys);
Q_UNUSED(mouseBts);
Q_UNUSED(pos);
}

View File

@ -93,20 +93,6 @@ public:
virtual void finishRestoring();
//@}
/** @name drag & drop handling */
//@{
/// get called if the user hover over a object in the tree
virtual bool allowDrop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos);
/// get called if the user drops some objects
virtual void drop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos);
//@}
protected:
/*! Get the active mdi view of the document this view provider is part of.
@note The returned mdi view doesn't need to be a 3d view but can be e.g.

View File

@ -73,68 +73,6 @@ std::vector<std::string> ViewProviderDocumentObjectGroup::getDisplayModes(void)
return std::vector<std::string>();
}
bool ViewProviderDocumentObjectGroup::allowDrop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos)
Q_UNUSED(keys);
Q_UNUSED(mouseBts);
Q_UNUSED(pos);
for( std::vector<const App::DocumentObject*>::const_iterator it = objList.begin();it!=objList.end();++it)
if ((*it)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) {
if (static_cast<App::DocumentObjectGroup*>(getObject())->isChildOf(
static_cast<const App::DocumentObjectGroup*>(*it))) {
return false;
}
}
return true;*/
Base::Console().Message("allow drop called");
}
void ViewProviderDocumentObjectGroup::drop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos)
{
Q_UNUSED(keys);
Q_UNUSED(mouseBts);
Q_UNUSED(pos);
// Open command
App::DocumentObjectGroup* grp = static_cast<App::DocumentObjectGroup*>(getObject());
App::Document* doc = grp->getDocument();
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
gui->openCommand("Move object");
for( std::vector<const App::DocumentObject*>::const_iterator it = objList.begin();it!=objList.end();++it) {
// get document object
const App::DocumentObject* obj = *it;
const App::DocumentObject* par = App::DocumentObjectGroup::getGroupOfObject(obj);
if (par) {
// allow an object to be in one group only
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(par->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
}
// build Python command for execution
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(grp->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
}
gui->commitCommand();
}
bool ViewProviderDocumentObjectGroup::isShow(void) const
{
return Visibility.getValue();

View File

@ -47,16 +47,6 @@ public:
std::vector<std::string> getDisplayModes(void) const;
bool isShow(void) const;
/// get called if the user hover over a object in the tree
virtual bool allowDrop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos);
/// get called if the user drops some objects
virtual void drop(const std::vector<const App::DocumentObject*> &objList,
Qt::KeyboardModifiers keys,
Qt::MouseButtons mouseBts,
const QPoint &pos);
protected:
void getViewProviders(std::vector<ViewProviderDocumentObject*>&) const;

View File

@ -76,23 +76,58 @@ bool ViewProviderGroupExtension::extensionCanDropObjects() const {
bool ViewProviderGroupExtension::extensionCanDropObject(App::DocumentObject* obj) const {
//we cannot drop anything into the group. We need to find the correct App extension to ask
//if this is a supported type, there should only be one
auto vector = getExtendedViewProvider()->getObject()->getExtensionsDerivedFromType<App::GroupExtension>();
assert(vector.size() == 1);
if(vector[0]->allowObject(obj))
App::GroupExtension* group = vector.front();
//we cannot drop thing of this group into it again
if (group->hasObject(obj))
return false;
//group into group?
if (obj->hasExtension(App::GroupExtension::getClassTypeId()))
if (group->isChildOf(obj->getExtensionByType<App::GroupExtension>()))
return false;
//We need to find the correct App extension to ask if this is a supported type, there should only be one
if(group->allowObject(obj))
return true;
return false;
}
void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument(\"%s\").getObject(\"%s\").addObject("
"App.getDocument(\"%s\").getObject(\"%s\"))",
getExtendedViewProvider()->getObject()->getDocument()->getName(), getExtendedViewProvider()->getObject()->getNameInDocument(),
obj->getDocument()->getName(), obj->getNameInDocument() );
// Open command
App::DocumentObject* grp = static_cast<App::DocumentObject*>(getExtendedViewProvider()->getObject());
App::Document* doc = grp->getDocument();
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
gui->openCommand("Move object");
const App::DocumentObject* par = App::GroupExtension::getGroupOfObject(obj);
if (par) {
// allow an object to be in one group only
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(par->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
}
// build Python command for execution
QString cmd;
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(grp->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
gui->commitCommand();
}
std::vector< App::DocumentObject* > ViewProviderGroupExtension::extensionClaimChildren(void) const {