1 #ifndef TREE_COMPLETER_H 2 #define TREE_COMPLETER_H 8 #include <QStandardItem> 9 #include <QStandardItemModel> 48 _model(new QStandardItemModel()),
49 _root_tree_item(nullptr)
51 setModelSorting( QCompleter::CaseInsensitivelySortedModel );
53 _root_tree_item =
TreeItem(_model->invisibleRootItem());
59 _root_tree_item =
TreeItem(_model->invisibleRootItem());
62 QStringList
splitPath(
const QString &path)
const override {
63 return path.split(
'/');
69 for (QModelIndex it = index; it.isValid(); it = it.parent())
71 dataList.prepend(model()->
data(it, completionRole()).toString());
73 return dataList.join(
'/');
78 auto parts = name.split(
'/');
79 if( parts.size() == 0 )
84 TreeItem* tree_parent = & _root_tree_item;
85 QStandardItem *item_parent = tree_parent->
standardItem();
87 for (
const auto& part: parts)
92 tree_parent = matching_child;
97 QStandardItem* item =
new QStandardItem( part );
98 item_parent->appendRow(item);
112 #endif // TREE_COMPLETER_H TreeItem * appendChild(const QString &name, QStandardItem *item)
TreeModelCompleter(QObject *parent=0)
void addToCompletionTree(const QString &name)
TreeItem(QStandardItem *item)
QHash< QString, TreeItem > _child_items_map
TreeItem * findChild(const QString &name)
QStandardItem * standardItem()
QString pathFromIndex(const QModelIndex &index) const override
QStringList splitPath(const QString &path) const override
empty_struct data[sizeof(T)/sizeof(empty_struct)]
QStandardItemModel * _model