show child list on click
This commit is contained in:
parent
99a2d118c8
commit
0b9e8fa067
4 changed files with 29 additions and 4 deletions
|
|
@ -38,7 +38,6 @@ void NavigationController::setContextProperties()
|
|||
|
||||
void NavigationController::add(const QString &path, NavigationItemModel *parentItem, bool isCircleDelegate)
|
||||
{
|
||||
///@todo recursively do the following for all subdirs
|
||||
auto dir = QDir(path);
|
||||
if(!dir.exists()) return;
|
||||
|
||||
|
|
@ -48,12 +47,13 @@ void NavigationController::add(const QString &path, NavigationItemModel *parentI
|
|||
for(const auto& name : subDirsNames){
|
||||
if(name == "." || name == "..") continue;
|
||||
auto item = new NavigationItemModel(parentItem);
|
||||
item->setCircleDelegate(isCircleDelegate);
|
||||
if(!item->setPath(path + "/" + name)) {
|
||||
item->deleteLater();
|
||||
continue;
|
||||
}
|
||||
qDebug() << "appending item " << item->getPath();
|
||||
item->setCircleDelegate(isCircleDelegate);
|
||||
connect(item, &NavigationItemModel::clicked, this, &NavigationController::onNavigationRequest);
|
||||
parentItem->appendChild(item);
|
||||
add(item->getPath(), item, false);
|
||||
}
|
||||
|
|
@ -65,3 +65,12 @@ void NavigationController::add(const QString &path, NavigationItemModel *parentI
|
|||
}
|
||||
// end testing
|
||||
}
|
||||
|
||||
void NavigationController::onNavigationRequest()
|
||||
{
|
||||
auto item = qobject_cast<NavigationItemModel*>(QObject::sender());
|
||||
if(!item) return;
|
||||
|
||||
if(item->hasChildren())
|
||||
mNavList->setModelItems(item->getChildren());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue