heuristic to import into selected folder
This commit is contained in:
@@ -23,6 +23,24 @@
|
||||
Project::Project()
|
||||
{
|
||||
name_ = tr("(untitled)");
|
||||
|
||||
// FIXME: Test code
|
||||
Folder* f1 = new Folder();
|
||||
f1->set_name("F1");
|
||||
f1->set_parent(&root_);
|
||||
Folder* f2 = new Folder();
|
||||
f2->set_name("F2");
|
||||
f2->set_parent(f1);
|
||||
Folder* f3 = new Folder();
|
||||
f3->set_name("F3");
|
||||
f3->set_parent(&root_);
|
||||
Folder* f4 = new Folder();
|
||||
f4->set_name("F4");
|
||||
f4->set_parent(f1);
|
||||
Folder* f5 = new Folder();
|
||||
f5->set_name("F5");
|
||||
f5->set_parent(f3);
|
||||
// End Test code
|
||||
}
|
||||
|
||||
Folder *Project::root()
|
||||
|
||||
@@ -207,6 +207,24 @@ bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProjectViewModel::canFetchMore(const QModelIndex &parent) const
|
||||
{
|
||||
// Check if this is a valid index
|
||||
if (parent.isValid()) {
|
||||
Item* item = GetItemObjectFromIndex(parent);
|
||||
|
||||
// Check if this item is a kFolder type
|
||||
// If it's a folder, we always return TRUE in order to always show the "expand triangle" icon,
|
||||
// even when there are no "physical" children
|
||||
if (item->type() == Item::kFolder) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, return default behavior
|
||||
return QAbstractItemModel::canFetchMore(parent);
|
||||
}
|
||||
|
||||
Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
virtual bool canFetchMore(const QModelIndex &parent) const override;
|
||||
|
||||
/** Drag and drop support */
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Reference in New Issue
Block a user