connected basic navigation model; completed controller
This commit is contained in:
parent
8a81c48606
commit
717e131b75
10 changed files with 60 additions and 39 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#include "NavigationController.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include "../models/NavigationItemModel.h"
|
||||
#include "../models/NavigationListModel.h"
|
||||
|
||||
|
|
@ -13,7 +16,31 @@ NavigationController::NavigationController(QObject *parent) : QObject(parent),
|
|||
|
||||
void NavigationController::init(const QString &rootPath)
|
||||
{
|
||||
///@todo create item for each subfolder and append to root;
|
||||
auto rootDir = QDir(rootPath);
|
||||
if(!rootDir.exists()) return;
|
||||
mRootPath = rootPath;
|
||||
|
||||
///@todo recursively do the following for all subdirs
|
||||
auto subDirsNames = rootDir.entryList(QDir::AllDirs);
|
||||
qDebug() << subDirsNames;
|
||||
for(const auto& name : subDirsNames){
|
||||
if(name == "." || name == "..") continue;
|
||||
auto item = new NavigationItemModel(mRootItem);
|
||||
if(!item->setPath(mRootPath + name)) {
|
||||
item->deleteLater();
|
||||
continue;
|
||||
}
|
||||
mRootItem->appendChild(item);
|
||||
|
||||
}
|
||||
// just for testing!
|
||||
auto list = mRootItem->getChildren();
|
||||
for (const auto& elem: list){
|
||||
qDebug() << elem->getImageSource();
|
||||
}
|
||||
// end testing
|
||||
|
||||
mNavList->setModelItems(mRootItem->getChildren());
|
||||
}
|
||||
|
||||
void NavigationController::setContext(QQmlContext *context)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ private:
|
|||
|
||||
NavigationItemModel* mRootItem;
|
||||
NavigationListModel* mNavList;
|
||||
QString mRootPath = ".";
|
||||
|
||||
QQmlContext* mContext;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue