New element panel : user can drag & drop item from project collection to another project collection

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4371 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-03-06 14:40:52 +00:00
parent 3192c8ccd7
commit 73e21c408d
6 changed files with 126 additions and 59 deletions

View File

@@ -208,13 +208,22 @@ bool ElementsCollectionModel::dropMimeData(const QMimeData *data, Qt::DropAction
ElementCollectionItem *eci = static_cast<ElementCollectionItem*> (parent.internalPointer());
if (!eci || eci->isElement()) return false;
connect(eci, &ElementCollectionItem::beginInsertRows, [this, &parent](ElementCollectionItem *eci, int first, int last){ Q_UNUSED(eci); this->beginInsertRows(parent, first, last); });
connect(eci, &ElementCollectionItem::endInsertRows, [this, &parent](){ this->endInsertRows(); });
connect(eci, &ElementCollectionItem::beginRemoveRows, [this, &parent](ElementCollectionItem *eci, int first, int last){ Q_UNUSED(eci); this->beginRemoveRows(parent, first, last); });
connect(eci, &ElementCollectionItem::endRemoveRows, [this, &parent](){ this->endRemoveRows(); });
m_parent_at_drop = parent;
connect(eci, &ElementCollectionItem::beginInsertRows, this, &ElementsCollectionModel::bir);
connect(eci, &ElementCollectionItem::endInsertRows, this, &ElementsCollectionModel::endInsertRows);
connect(eci, &ElementCollectionItem::beginRemoveRows, this, &ElementsCollectionModel::brr);
connect(eci, &ElementCollectionItem::endRemoveRows, this, &ElementsCollectionModel::endRemoveRows);
bool rb = eci->dropMimeData(data, action, row, column);
disconnect(eci, &ElementCollectionItem::beginInsertRows, this, &ElementsCollectionModel::bir);
disconnect(eci, &ElementCollectionItem::endInsertRows, this, &ElementsCollectionModel::endInsertRows);
disconnect(eci, &ElementCollectionItem::beginRemoveRows, this, &ElementsCollectionModel::brr);
disconnect(eci, &ElementCollectionItem::endRemoveRows, this, &ElementsCollectionModel::endRemoveRows);
m_parent_at_drop = QModelIndex();
return rb;
}
@@ -349,3 +358,17 @@ void ElementsCollectionModel::elementIntegratedToCollection(QETProject *project,
eci->insertNewItem(collection_name);
endInsertRows();
}
void ElementsCollectionModel::bir(ElementCollectionItem *eci, int first, int last)
{
Q_UNUSED(eci);
if (!m_parent_at_drop.isValid()) return;
beginInsertRows(m_parent_at_drop, first, last);
}
void ElementsCollectionModel::brr(ElementCollectionItem *eci, int first, int last)
{
Q_UNUSED(eci);
if (!m_parent_at_drop.isValid()) return;
beginRemoveRows(m_parent_at_drop, first, last);
}