create new folder added
This commit is contained in:
@@ -39,6 +39,10 @@ void Item::add_child(Item* c)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->parent_ != nullptr) {
|
||||
c->parent_->remove_child(c);
|
||||
}
|
||||
|
||||
children_.append(c);
|
||||
c->parent_ = this;
|
||||
}
|
||||
|
||||
@@ -376,6 +376,21 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProjectViewModel::AddChild(Item *parent, Item *child)
|
||||
{
|
||||
QModelIndex parent_index;
|
||||
|
||||
if (parent != project_->root()) {
|
||||
parent_index = CreateIndexFromItem(parent);
|
||||
}
|
||||
|
||||
beginInsertRows(parent_index, parent->child_count(), parent->child_count());
|
||||
|
||||
parent->add_child(child);
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
int ProjectViewModel::IndexOfChild(Item *item) const
|
||||
{
|
||||
// Find parent's index within its own parent
|
||||
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
virtual QStringList mimeTypes() const override;
|
||||
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
/** Other model functions */
|
||||
void AddChild(Item* parent, Item* child);
|
||||
private:
|
||||
/**
|
||||
* @brief Retrieve the index of `item` in its parent
|
||||
|
||||
Reference in New Issue
Block a user