mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-16 18:14:40 +02:00
Bug 2412 fixed
This commit is contained in:
@@ -56,9 +56,7 @@ AskLibForCopyDialog::AskLibForCopyDialog( QWidget *parent, FWObjectDatabase *db,
|
||||
|
||||
void AskLibForCopyDialog::loadObjects()
|
||||
{
|
||||
FWObject *firstUserLib=NULL;
|
||||
list<FWObject*> ll = m_db->getByType( Library::TYPENAME );
|
||||
int ind = 0;
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
FWObject *lib = (*i);
|
||||
@@ -100,7 +98,7 @@ int AskLibForCopyDialog::addLib( FWObject *lib)
|
||||
m_dialog->libs->setCurrentIndex(idx);
|
||||
|
||||
idxToLibs.insert(i1,lib);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
FWObject *AskLibForCopyDialog::getChoosenLib()
|
||||
@@ -109,4 +107,4 @@ FWObject *AskLibForCopyDialog::getChoosenLib()
|
||||
if (0 <= ind)
|
||||
return idxToLibs[ind];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ private:
|
||||
libfwbuilder::FWObject *m_curr;
|
||||
Ui::asklibforcopydialog_q *m_dialog;
|
||||
|
||||
AskLibForCopyDialog( QWidget *parent, libfwbuilder::FWObjectDatabase *db,
|
||||
libfwbuilder::FWObject *curr = 0);
|
||||
int getIdxForLib(libfwbuilder::FWObject* lib);
|
||||
void loadObjects();
|
||||
int addLib( libfwbuilder::FWObject *lib);
|
||||
libfwbuilder::FWObject *getChoosenLib();
|
||||
public:
|
||||
AskLibForCopyDialog( QWidget *parent, libfwbuilder::FWObjectDatabase *db,
|
||||
libfwbuilder::FWObject *curr = 0);
|
||||
~AskLibForCopyDialog();
|
||||
static libfwbuilder::FWObject *askLibForCopyDialog( QWidget *parent,
|
||||
libfwbuilder::FWObjectDatabase *db, libfwbuilder::FWObject *curr = 0);
|
||||
|
||||
@@ -2430,11 +2430,13 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
||||
|
||||
|
||||
FWObject* ObjectManipulator::copyObj2Tree(const QString &objType, const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom)
|
||||
libfwbuilder::FWObject *copyFrom, bool askLib)
|
||||
{
|
||||
if (!validateDialog()) return NULL;
|
||||
|
||||
FWObject *lib = AskLibForCopyDialog::askLibForCopyDialog(m_project, m_project->db());;
|
||||
FWObject *lib = getCurrentLib();
|
||||
if (askLib)
|
||||
lib = AskLibForCopyDialog::askLibForCopyDialog(m_project, m_project->db(), lib);
|
||||
if (!lib)
|
||||
return 0;
|
||||
FWObject *parent=m_project->getStandardSlotForObject(lib, objType);
|
||||
|
||||
@@ -163,7 +163,7 @@ public slots:
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom=NULL);
|
||||
libfwbuilder::FWObject * copyObj2Tree(const QString &objType, const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom);
|
||||
libfwbuilder::FWObject *copyFrom, bool ask4Lib=true);
|
||||
|
||||
void newLibrary();
|
||||
void newObject();
|
||||
|
||||
+38
-111
@@ -334,8 +334,6 @@ void ObjectTreeView::updateTreeItems()
|
||||
|
||||
void ObjectTreeView::startDrag(Qt::DropActions supportedActions)
|
||||
{
|
||||
qDebug("ObjectTreeView::dragObject"); // !!!!!
|
||||
|
||||
QTreeWidgetItem *ovi = currentItem();
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi);
|
||||
|
||||
@@ -457,129 +455,58 @@ void ObjectTreeView::dragEnterEvent( QDragEnterEvent *ev)
|
||||
ev->setDropAction(Qt::MoveAction);
|
||||
}
|
||||
|
||||
bool ObjectTreeView::isCurrReadOnly(QDragMoveEvent *ev)
|
||||
{
|
||||
// the tree can accept drop only if it goes into a group and if that group
|
||||
// validates the object and tree is not read-only
|
||||
QTreeWidgetItem *ovi = itemAt(ev->pos());
|
||||
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi);
|
||||
FWObject *trobj = otvi->getFWObject();
|
||||
|
||||
return (trobj->isReadOnly()); //m_project->isSystem(trobj) ||
|
||||
}
|
||||
|
||||
void ObjectTreeView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
{
|
||||
bool acceptE = false;
|
||||
if (ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE))
|
||||
{
|
||||
int hy;
|
||||
if (isCurrReadOnly(ev) ||
|
||||
!ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE))
|
||||
{
|
||||
qDebug("ObjectTreeView::itemOpened");
|
||||
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);
|
||||
|
||||
// hy=header()->height(); // if header is shown
|
||||
hy=0;
|
||||
|
||||
QTreeWidgetItem *ovi = itemAt( ev->pos() );
|
||||
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi);
|
||||
if (otvi==NULL)
|
||||
if (m_project->isSystem(dragobj))
|
||||
{
|
||||
qDebug("dragMoveEvent %d", acceptE);// !!!!!
|
||||
ev->setAccepted(acceptE);
|
||||
// can not drop system folder anywhere
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
FWObject *trobj = otvi->getFWObject();
|
||||
|
||||
qDebug("Group::cast(trobj)!=NULL %d", Group::cast(trobj)!=NULL);// !!!!!
|
||||
qDebug("!m_project->isSystem(trobj) %d", !m_project->isSystem(trobj));// !!!!!
|
||||
qDebug("!trobj->isReadOnly() %d", !trobj->isReadOnly());// !!!!!
|
||||
/* the tree can accept drop only if it goes into a group and if that group
|
||||
* validates the object and tree is not read-only
|
||||
*/
|
||||
if (Group::cast(trobj)!=NULL &&
|
||||
!m_project->isSystem(trobj) &&
|
||||
!trobj->isReadOnly()
|
||||
)
|
||||
{
|
||||
acceptE = true;
|
||||
qDebug("dragMoveEvent %d", acceptE);// !!!!!
|
||||
|
||||
Group *g = Group::cast(trobj);
|
||||
list<FWObject*> dragol;
|
||||
if (FWObjectDrag::decode(ev, dragol))
|
||||
{
|
||||
for (list<FWObject*>::iterator i=dragol.begin();
|
||||
i!=dragol.end(); ++i)
|
||||
{
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj!=NULL);
|
||||
|
||||
if (m_project->isSystem(dragobj))
|
||||
{
|
||||
/* can not drop system folder anywhere */
|
||||
acceptE = false;
|
||||
break;
|
||||
}
|
||||
|
||||
bool t= g->validateChild(dragobj);
|
||||
if (!t)
|
||||
{
|
||||
acceptE = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (g->getPath(true) == "Services/Groups" && t)
|
||||
ovi->setExpanded(true);
|
||||
|
||||
if (g->getPath(true) == "Objects/Groups" && t)
|
||||
ovi->setExpanded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ev->setAccepted(acceptE);
|
||||
ev->setAccepted(true);
|
||||
}
|
||||
|
||||
void ObjectTreeView::dropEvent(QDropEvent *ev)
|
||||
{
|
||||
QTreeWidgetItem *ovi = itemAt( ev->pos() );
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi);
|
||||
if (otvi==NULL) return;
|
||||
FWObject *trobj = otvi->getFWObject();
|
||||
|
||||
/* the tree can accept drop only if it goes into a group and if that group
|
||||
* validates the object and the tree is not read-only
|
||||
*/
|
||||
if (Group::cast(trobj)!=NULL &&
|
||||
!m_project->isSystem(trobj) &&
|
||||
!trobj->isReadOnly()
|
||||
)
|
||||
list<FWObject*> dragol;
|
||||
if (FWObjectDrag::decode(ev, dragol))
|
||||
{
|
||||
Group *g=Group::cast(trobj);
|
||||
item_before_drag_started=NULL;
|
||||
list<FWObject*> dragol;
|
||||
|
||||
if (FWObjectDrag::decode(ev, dragol))
|
||||
for (list<FWObject*>::iterator i=dragol.begin();
|
||||
i!=dragol.end(); ++i)
|
||||
{
|
||||
for (list<FWObject*>::iterator i=dragol.begin();
|
||||
i!=dragol.end(); ++i)
|
||||
{
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj!=NULL);
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj);
|
||||
|
||||
/* check for duplicates */
|
||||
const string cp_id=dragobj->getId();
|
||||
qDebug("dropEvent allowed %s", cp_id.c_str());// !!!!!
|
||||
list<FWObject*>::iterator j;
|
||||
for(j=g->begin(); j!=g->end(); ++j)
|
||||
{
|
||||
FWObject *o1=*j;
|
||||
if(cp_id==o1->getId()) continue;
|
||||
|
||||
FWReference *ref;
|
||||
if( (ref=FWReference::cast(o1))!=NULL &&
|
||||
cp_id==ref->getPointerId()) return;
|
||||
}
|
||||
|
||||
QString n=QString::fromUtf8(dragobj->getName().c_str());
|
||||
m_project->copyObj2Tree(dragobj->getTypeName().c_str(), n, dragobj);
|
||||
//g->addRef(dragobj);
|
||||
}
|
||||
|
||||
clearSelection();
|
||||
setCurrentItem(ovi);
|
||||
ovi->setSelected(true);
|
||||
|
||||
// emit objectDropped_sign(g);
|
||||
QString n=QString::fromUtf8(dragobj->getName().c_str());
|
||||
m_project->copyObj2Tree(dragobj->getTypeName().c_str(), n, dragobj, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class ObjectTreeView : public QTreeWidget {
|
||||
|
||||
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
||||
ProjectPanel* m_project;
|
||||
bool isCurrReadOnly(QDragMoveEvent *ev);
|
||||
protected:
|
||||
|
||||
bool event( QEvent *event );
|
||||
|
||||
@@ -1228,9 +1228,9 @@ libfwbuilder::FWObject* ProjectPanel::createObject(libfwbuilder::FWObject *paren
|
||||
|
||||
|
||||
FWObject* ProjectPanel::copyObj2Tree(const QString &objType, const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
FWObject *copyFrom, bool ask4Lib)
|
||||
{
|
||||
return m_panel->om->copyObj2Tree(objType, objName, copyFrom);
|
||||
return m_panel->om->copyObj2Tree(objType, objName, copyFrom, ask4Lib);
|
||||
}
|
||||
|
||||
void ProjectPanel::moveObject(libfwbuilder::FWObject *target,
|
||||
|
||||
@@ -118,7 +118,8 @@ public:
|
||||
|
||||
libfwbuilder::FWObject* copyObj2Tree(const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom=NULL);
|
||||
libfwbuilder::FWObject *copyFrom=NULL,
|
||||
bool ask4Lib = true);
|
||||
|
||||
void moveObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj);
|
||||
|
||||
+1
-1
@@ -646,7 +646,7 @@ int main( int argc, char ** argv )
|
||||
|
||||
if (fwbdebug) qDebug("loading translation for the current locale ...");
|
||||
|
||||
QString local = "en_US";//QLocale::system().name();
|
||||
QString local = QLocale::system().name();//"en_US";//
|
||||
QTranslator translator(0);
|
||||
translator.load(QLatin1String("fwbuilder_") +
|
||||
QString(local), localepath.c_str());
|
||||
|
||||
Reference in New Issue
Block a user