create new folder added

This commit is contained in:
itsmattkc
2019-07-05 11:04:23 -05:00
parent dae4310a7e
commit bc631c495d
10 changed files with 170 additions and 39 deletions
+4
View File
@@ -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;
}
+15
View File
@@ -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
+3
View File
@@ -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