don't show folders that do not contain subfolders or audio files
hopefuly this will fix crash on RasPi
This commit is contained in:
parent
50deec22f1
commit
d251120275
7 changed files with 333 additions and 4 deletions
|
|
@ -54,6 +54,7 @@ void NavigationController::add(const QString &path, NavigationItemModel *parentI
|
|||
|
||||
for(const auto& name : subDirsNames){
|
||||
if(name == "." || name == "..") continue;
|
||||
if(!checkContent(path + "/" + name)) continue;
|
||||
auto item = new NavigationItemModel(parentItem);
|
||||
if(!item->setPath(path + "/" + name)) {
|
||||
item->deleteLater();
|
||||
|
|
@ -65,6 +66,26 @@ void NavigationController::add(const QString &path, NavigationItemModel *parentI
|
|||
}
|
||||
}
|
||||
|
||||
bool NavigationController::checkContent(const QString &path)
|
||||
{
|
||||
bool valid = false;
|
||||
auto dir =QDir(path);
|
||||
auto subDirsNames = dir.entryList(QDir::AllDirs);
|
||||
if(subDirsNames.length() > 0) {
|
||||
valid = true;
|
||||
} else {
|
||||
auto fileNames = dir.entryList(QDir::Files);
|
||||
int numAudio = 0;
|
||||
for(auto file:fileNames){
|
||||
if(file.endsWith(".flac") || file.endsWith(".mp3")){
|
||||
numAudio++;
|
||||
}
|
||||
}
|
||||
if(numAudio > 0) valid = true;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
void NavigationController::onNavigationRequest()
|
||||
{
|
||||
auto item = qobject_cast<NavigationItemModel*>(QObject::sender());
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public:
|
|||
private:
|
||||
void setContextProperties();
|
||||
void add(const QString & path, NavigationItemModel* parentItem);
|
||||
bool checkContent(const QString& path);
|
||||
|
||||
NavigationItemModel* mRootItem;
|
||||
NavigationListModel* mNavList;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue